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.coloc;
19:
20: import java.util.SortedSet;
21: import java.util.TreeSet; //import java.util.ResourceBundle;
22: import java.util.logging.Level;
23: import java.util.logging.Logger;
24:
25: import org.apache.cxf.Bus; //import org.apache.cxf.common.i18n.BundleUtils;
26: import org.apache.cxf.interceptor.Fault;
27: import org.apache.cxf.interceptor.InterceptorChain;
28: import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
29: import org.apache.cxf.message.Exchange;
30: import org.apache.cxf.message.Message;
31: import org.apache.cxf.phase.AbstractPhaseInterceptor;
32: import org.apache.cxf.phase.Phase;
33: import org.apache.cxf.phase.PhaseManager;
34: import org.apache.cxf.service.model.BindingOperationInfo;
35: import org.apache.cxf.service.model.MessageInfo;
36:
37: public class ColocInInterceptor extends
38: AbstractPhaseInterceptor<Message> {
39:
40: // private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ColocInInterceptor.class);
41: private static final Logger LOG = Logger
42: .getLogger(ColocInInterceptor.class.getName());
43:
44: public ColocInInterceptor() {
45: super (Phase.INVOKE);
46: addAfter(ServiceInvokerInterceptor.class.getName());
47: }
48:
49: public void handleMessage(Message msg) throws Fault {
50: Exchange ex = msg.getExchange();
51: if (ex.isOneWay()) {
52: return;
53: }
54:
55: Bus bus = ex.get(Bus.class);
56: SortedSet<Phase> phases = new TreeSet<Phase>(bus.getExtension(
57: PhaseManager.class).getOutPhases());
58:
59: //TODO Set Coloc FaultObserver chain
60: ColocUtil.setPhases(phases, Phase.SETUP, Phase.USER_LOGICAL);
61: InterceptorChain chain = ColocUtil.getOutInterceptorChain(ex,
62: phases);
63:
64: if (LOG.isLoggable(Level.FINER)) {
65: LOG
66: .finer("Processing Message at collocated endpoint. Response message: "
67: + msg);
68: }
69:
70: //Initiate OutBound Processing
71: BindingOperationInfo boi = ex.get(BindingOperationInfo.class);
72: Message outBound = ex.getOutMessage();
73: if (boi != null) {
74: outBound.put(MessageInfo.class, boi.getOperationInfo()
75: .getOutput());
76: }
77:
78: outBound.put(Message.INBOUND_MESSAGE, Boolean.FALSE);
79: outBound.setInterceptorChain(chain);
80: chain.doIntercept(outBound);
81: }
82: }
|