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.jbi.interceptor;
19:
20: import java.util.ResourceBundle;
21: import java.util.logging.Logger;
22:
23: import javax.xml.namespace.QName;
24:
25: import org.apache.cxf.binding.jbi.JBIMessage;
26: import org.apache.cxf.common.i18n.Message;
27: import org.apache.cxf.common.logging.LogUtils;
28: import org.apache.cxf.endpoint.Endpoint;
29: import org.apache.cxf.interceptor.Fault;
30: import org.apache.cxf.message.Exchange;
31: import org.apache.cxf.phase.AbstractPhaseInterceptor;
32: import org.apache.cxf.phase.Phase;
33: import org.apache.cxf.service.model.BindingInfo;
34: import org.apache.cxf.service.model.BindingOperationInfo;
35: import org.apache.cxf.service.model.MessageInfo;
36: import org.apache.cxf.service.model.OperationInfo;
37:
38: public class JBIOperationInInterceptor extends
39: AbstractPhaseInterceptor<JBIMessage> {
40:
41: private static final Logger LOG = LogUtils
42: .getL7dLogger(JBIOperationInInterceptor.class);
43:
44: private static final ResourceBundle BUNDLE = LOG
45: .getResourceBundle();
46:
47: public JBIOperationInInterceptor() {
48: super (Phase.PRE_PROTOCOL);
49: }
50:
51: public void handleMessage(JBIMessage message) throws Fault {
52: Exchange ex = message.getExchange();
53: Endpoint ep = ex.get(Endpoint.class);
54: BindingOperationInfo boi = ex.get(BindingOperationInfo.class);
55: if (boi == null
56: && message.getJbiExchange().getOperation() != null) {
57: BindingInfo service = ep.getEndpointInfo().getBinding();
58: boi = getBindingOperationInfo(service, message
59: .getJbiExchange().getOperation());
60: if (boi == null) {
61: throw new Fault(new Message("UNKNOWN_OPERATION",
62: BUNDLE, message.getJbiExchange().getOperation()
63: .toString()));
64: }
65: ex.put(BindingOperationInfo.class, boi);
66: ex.put(OperationInfo.class, boi.getOperationInfo());
67: ex.setOneWay(boi.getOperationInfo().isOneWay());
68: message.put(MessageInfo.class, boi.getInput()
69: .getMessageInfo());
70: }
71: }
72:
73: protected BindingOperationInfo getBindingOperationInfo(
74: BindingInfo service, QName operation) {
75: return service.getOperation(operation);
76: }
77:
78: }
|