01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.cxf.client;
17:
18: import java.net.URI;
19: import java.util.Map;
20:
21: import javax.naming.NamingException;
22: import javax.xml.bind.JAXBException;
23: import javax.xml.namespace.QName;
24: import javax.xml.ws.handler.HandlerResolver;
25:
26: import org.apache.commons.logging.Log;
27: import org.apache.commons.logging.LogFactory;
28: import org.apache.cxf.jaxws.context.WebServiceContextImpl;
29: import org.apache.cxf.jaxws.javaee.HandlerChainsType;
30: import org.apache.geronimo.cxf.CXFHandlerResolver;
31: import org.apache.geronimo.cxf.CXFWebServiceContainer;
32: import org.apache.geronimo.gbean.AbstractName;
33: import org.apache.geronimo.jaxws.HandlerChainsUtils;
34: import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
35: import org.apache.geronimo.jaxws.JNDIResolver;
36: import org.apache.geronimo.jaxws.client.EndpointInfo;
37: import org.apache.geronimo.jaxws.client.JAXWSServiceReference;
38:
39: public class CXFServiceReference extends JAXWSServiceReference {
40:
41: private static final Log LOG = LogFactory
42: .getLog(CXFServiceReference.class);
43:
44: public CXFServiceReference(String serviceClassName,
45: String referenceClassName, URI wsdlURI, QName serviceQName,
46: AbstractName name, String handlerChainsXML,
47: Map<Object, EndpointInfo> seiInfoMap) {
48: super (handlerChainsXML, seiInfoMap, name, serviceQName,
49: wsdlURI, referenceClassName, serviceClassName);
50: }
51:
52: public Object getContent() throws NamingException {
53: CXFWebServiceContainer.getDefaultBus();
54: Object reference = super .getContent();
55: SAAJInterceptor.registerInterceptors();
56: return reference;
57: }
58:
59: protected HandlerChainsType getHandlerChains() {
60: try {
61: return HandlerChainsUtils.toHandlerChains(
62: this .handlerChainsXML, HandlerChainsType.class);
63: } catch (JAXBException e) {
64: // this should not happen
65: LOG.warn("Failed to deserialize handler chains", e);
66: return null;
67: }
68: }
69:
70: protected HandlerResolver getHandlerResolver(Class serviceClass) {
71: JAXWSAnnotationProcessor annotationProcessor = new JAXWSAnnotationProcessor(
72: new JNDIResolver(), new WebServiceContextImpl());
73: CXFHandlerResolver handlerResolver = new CXFHandlerResolver(
74: classLoader, serviceClass, getHandlerChains(),
75: annotationProcessor);
76: return handlerResolver;
77: }
78: }
|