01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.binding.object;
19:
20: import java.util.ResourceBundle;
21:
22: import javax.xml.namespace.QName;
23:
24: import org.apache.cxf.common.i18n.BundleUtils;
25: import org.apache.cxf.endpoint.Endpoint;
26: import org.apache.cxf.interceptor.Fault;
27: import org.apache.cxf.message.Message;
28: import org.apache.cxf.phase.AbstractPhaseInterceptor;
29: import org.apache.cxf.phase.Phase;
30: import org.apache.cxf.service.model.BindingInfo;
31: import org.apache.cxf.service.model.BindingOperationInfo;
32:
33: public class ObjectDispatchInInterceptor extends
34: AbstractPhaseInterceptor<Message> {
35: private static final ResourceBundle BUNDLE = BundleUtils
36: .getBundle(ObjectDispatchInInterceptor.class);
37:
38: public ObjectDispatchInInterceptor() {
39: super (Phase.READ);
40: }
41:
42: public void handleMessage(Message message) throws Fault {
43: if (Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE))) {
44: return;
45: }
46:
47: QName opName = (QName) message.get(ObjectBinding.OPERATION);
48: QName bindingName = (QName) message.get(ObjectBinding.BINDING);
49:
50: if (opName == null) {
51: throw new Fault(new org.apache.cxf.common.i18n.Message(
52: "NO_OPERATION", BUNDLE));
53: }
54:
55: Endpoint ep = message.getExchange().get(Endpoint.class);
56:
57: BindingInfo binding = null;
58:
59: if (bindingName == null) {
60: binding = ep.getEndpointInfo().getBinding();
61: } else {
62: binding = ep.getEndpointInfo().getService().getBinding(
63: bindingName);
64: }
65:
66: BindingOperationInfo bop = binding.getOperation(opName);
67:
68: message.getExchange().put(BindingOperationInfo.class, bop);
69:
70: }
71:
72: }
|