001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.jaxws.support;
019:
020: import java.util.List;
021:
022: import javax.xml.ws.Binding;
023:
024: import org.apache.cxf.Bus;
025: import org.apache.cxf.binding.soap.SoapBinding;
026: import org.apache.cxf.binding.xml.XMLBinding;
027: import org.apache.cxf.endpoint.EndpointException;
028: import org.apache.cxf.endpoint.EndpointImpl;
029: import org.apache.cxf.interceptor.Interceptor;
030: import org.apache.cxf.jaxws.binding.BindingImpl;
031: import org.apache.cxf.jaxws.binding.http.HTTPBindingImpl;
032: import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
033: import org.apache.cxf.jaxws.handler.logical.DispatchLogicalHandlerInterceptor;
034: import org.apache.cxf.jaxws.handler.logical.LogicalHandlerFaultInInterceptor;
035: import org.apache.cxf.jaxws.handler.logical.LogicalHandlerFaultOutInterceptor;
036: import org.apache.cxf.jaxws.handler.logical.LogicalHandlerInInterceptor;
037: import org.apache.cxf.jaxws.handler.logical.LogicalHandlerOutInterceptor;
038: import org.apache.cxf.jaxws.handler.soap.DispatchSOAPHandlerInterceptor;
039: import org.apache.cxf.jaxws.handler.soap.SOAPHandlerFaultInInterceptor;
040: import org.apache.cxf.jaxws.handler.soap.SOAPHandlerFaultOutInterceptor;
041: import org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor;
042: import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
043: import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
044: import org.apache.cxf.jaxws.interceptors.SwAInInterceptor;
045: import org.apache.cxf.jaxws.interceptors.SwAOutInterceptor;
046: import org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor;
047: import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
048: import org.apache.cxf.phase.Phase;
049: import org.apache.cxf.service.Service;
050: import org.apache.cxf.service.model.EndpointInfo;
051:
052: /**
053: * A JAX-WS specific implementation of the CXF {@link org.apache.cxf.endpoint.Endpoint} interface.
054: * Extends the interceptor provider functionality of its base class by adding
055: * interceptors in which to execute the JAX-WS handlers.
056: * Creates and owns an implementation of {@link Binding} in addition to the
057: * CXF {@link org.apache.cxf.binding.Binding}.
058: *
059: */
060: public class JaxWsEndpointImpl extends EndpointImpl {
061:
062: private Binding jaxwsBinding;
063: private JaxWsImplementorInfo implInfo;
064:
065: public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei)
066: throws EndpointException {
067: this (bus, s, ei, null);
068: }
069:
070: public JaxWsEndpointImpl(Bus bus, Service s, EndpointInfo ei,
071: JaxWsImplementorInfo implementorInfo)
072: throws EndpointException {
073: super (bus, s, ei);
074: this .implInfo = implementorInfo;
075:
076: createJaxwsBinding();
077:
078: List<Interceptor> in = super .getInInterceptors();
079: List<Interceptor> out = super .getOutInterceptors();
080:
081: if (implInfo != null && implInfo.isWebServiceProvider()) {
082: DispatchLogicalHandlerInterceptor slhi = new DispatchLogicalHandlerInterceptor(
083: jaxwsBinding, Phase.USER_LOGICAL);
084: in.add(slhi);
085: out
086: .add(new DispatchLogicalHandlerInterceptor(
087: jaxwsBinding));
088:
089: if (getBinding() instanceof SoapBinding) {
090: in
091: .add(new DispatchSOAPHandlerInterceptor(
092: jaxwsBinding));
093: out
094: .add(new DispatchSOAPHandlerInterceptor(
095: jaxwsBinding));
096: }
097: } else {
098: // Inbound chain
099: in.add(new LogicalHandlerInInterceptor(jaxwsBinding));
100: in.add(new WrapperClassInInterceptor());
101: in.add(new HolderInInterceptor());
102: if (getBinding() instanceof SoapBinding) {
103: in.add(new SOAPHandlerInterceptor(jaxwsBinding));
104: in.add(new SwAInInterceptor());
105: getOutInterceptors().add(new SwAOutInterceptor());
106: } else {
107: // TODO: what for non soap bindings?
108: }
109:
110: // Outbound chain
111: out.add(new LogicalHandlerOutInterceptor(jaxwsBinding));
112: out.add(new WrapperClassOutInterceptor());
113: out.add(new HolderOutInterceptor());
114: if (getBinding() instanceof SoapBinding) {
115: out.add(new SOAPHandlerInterceptor(jaxwsBinding));
116: }
117: }
118:
119: //Outbound fault chain
120: List<Interceptor> outFault = super .getOutFaultInterceptors();
121: outFault
122: .add(new LogicalHandlerFaultOutInterceptor(jaxwsBinding));
123: if (getBinding() instanceof SoapBinding) {
124: outFault.add(new SOAPHandlerFaultOutInterceptor(
125: jaxwsBinding));
126: }
127:
128: //Inbound fault chain
129: List<Interceptor> inFault = super .getInFaultInterceptors();
130: inFault.add(new LogicalHandlerFaultInInterceptor(jaxwsBinding));
131: if (getBinding() instanceof SoapBinding) {
132: inFault
133: .add(new SOAPHandlerFaultInInterceptor(jaxwsBinding));
134: }
135: }
136:
137: public Binding getJaxwsBinding() {
138: return jaxwsBinding;
139: }
140:
141: final void createJaxwsBinding() {
142: if (getBinding() instanceof SoapBinding) {
143: jaxwsBinding = new SOAPBindingImpl(getEndpointInfo()
144: .getBinding());
145: } else if (getBinding() instanceof XMLBinding) {
146: jaxwsBinding = new HTTPBindingImpl(getEndpointInfo()
147: .getBinding());
148: } else {
149: jaxwsBinding = new BindingImpl();
150: }
151: }
152: }
|