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.http.interceptor;
19:
20: import org.apache.cxf.binding.xml.interceptor.XMLMessageInInterceptor;
21: import org.apache.cxf.interceptor.DocLiteralInInterceptor;
22: import org.apache.cxf.interceptor.Fault;
23: import org.apache.cxf.interceptor.InterceptorChain;
24: import org.apache.cxf.interceptor.StaxInInterceptor;
25: import org.apache.cxf.interceptor.WrappedInInterceptor;
26: import org.apache.cxf.message.Message;
27: import org.apache.cxf.phase.AbstractPhaseInterceptor;
28: import org.apache.cxf.phase.Phase;
29:
30: public class DatabindingInSetupInterceptor extends
31: AbstractPhaseInterceptor<Message> {
32:
33: private static final WrappedInInterceptor WRAPPED_IN = new WrappedInInterceptor();
34: private static final XMLMessageInInterceptor XML_IN = new XMLMessageInInterceptor();
35: private static final DocLiteralInInterceptor DOCLIT_IN = new DocLiteralInInterceptor();
36: private static final URIParameterInInterceptor URI_IN = new URIParameterInInterceptor();
37: private static final StaxInInterceptor STAX_IN = new StaxInInterceptor();
38: private static final DispatchInterceptor DISPATCH_IN = new DispatchInterceptor();
39:
40: public DatabindingInSetupInterceptor() {
41: super (Phase.RECEIVE);
42: }
43:
44: public void handleMessage(Message message) throws Fault {
45: boolean client = Boolean.TRUE.equals(message
46: .get(Message.REQUESTOR_ROLE));
47: InterceptorChain chain = message.getInterceptorChain();
48:
49: if (client) {
50: chain.add(DOCLIT_IN);
51: chain.add(XML_IN);
52: chain.add(WRAPPED_IN);
53: chain.add(STAX_IN);
54: } else {
55: chain.add(URI_IN);
56: chain.add(DISPATCH_IN);
57: }
58: }
59:
60: }
|