Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.openejb.client;
import javax.xml.ws.spi.Provider;
import javax.xml.ws.spi.ServiceDelegate;
import javax.xml.ws.Endpoint;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.namespace.QName;
import javax.xml.bind.JAXBContext;
import javax.xml.transform.Source;
import javax.jws.WebService;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
import java.util.List;
import java.util.Properties;
import java.util.Collections;
import java.util.Enumeration;
import java.util.ArrayList;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.concurrent.Executor;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import org.w3c.dom.Element;
public class JaxWsProviderWrapper extends Provider {
private static final Logger logger = Logger.getLogger("OpenEJB.client");
//
// Magic to get our proider wrapper installed with the PortRefData
//
private static ThreadLocal threadPortRefs = new ThreadLocal();
public static void beforeCreate(List portRefMetaDatas) {
// Axis JAXWS api is non compliant and checks system property before classloader
// so we replace system property so this wrapper is selected. The original value
// is saved into an openejb property so we can load the class in the find method
String oldProperty = System.getProperty(JAXWSPROVIDER_PROPERTY);
if (oldProperty != null && !oldProperty.equals(JaxWsProviderWrapper.class.getName())) {
System.setProperty("openejb." + JAXWSPROVIDER_PROPERTY, oldProperty);
}
System.setProperty(JAXWSPROVIDER_PROPERTY, JaxWsProviderWrapper.class.getName());
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
if (oldClassLoader != null) {
Thread.currentThread().setContextClassLoader(new ProviderClassLoader(oldClassLoader));
} else {
Thread.currentThread().setContextClassLoader(new ProviderClassLoader());
}
threadPortRefs.set(new ProviderWrapperData(portRefMetaDatas, oldClassLoader));
}
public static void afterCreate() {
Thread.currentThread().setContextClassLoader(threadPortRefs.get().callerClassLoader);
threadPortRefs.set(null);
}
private static class ProviderWrapperData {
private final List portRefMetaData;
private final ClassLoader callerClassLoader;
public ProviderWrapperData(List portRefMetaDatas, ClassLoader callerClassLoader) {
this.portRefMetaData = portRefMetaDatas;
this.callerClassLoader = callerClassLoader;
}
}
//
// Provider wappre implementation
//
private final Provider delegate;
private final List portRefs;
public JaxWsProviderWrapper() {
delegate = findProvider();
portRefs = threadPortRefs.get().portRefMetaData;
}
public Provider getDelegate() {
return delegate;
}
public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class serviceClass) {
ServiceDelegate serviceDelegate = delegate.createServiceDelegate(wsdlDocumentLocation, serviceName, serviceClass);
serviceDelegate = new ServiceDelegateWrapper(serviceDelegate);
return serviceDelegate;
}
public Endpoint createEndpoint(String bindingId, Object implementor) {
return delegate.createEndpoint(bindingId, implementor);
}
public Endpoint createAndPublishEndpoint(String address, Object implementor) {
return delegate.createAndPublishEndpoint(address, implementor);
}
public W3CEndpointReference createW3CEndpointReference(String address,
QName serviceName,
QName portName,
List metadata,
String wsdlDocumentLocation,
List referenceParameters) {
return (W3CEndpointReference) invoke21Delegate(delegate, createW3CEndpointReference,
address,
serviceName,
portName,
metadata,
wsdlDocumentLocation,
referenceParameters);
}
public EndpointReference readEndpointReference(Source source){
return (EndpointReference) invoke21Delegate(delegate, readEndpointReference, source);
}
@SuppressWarnings({"unchecked"})
public T getPort(EndpointReference endpointReference, Class serviceEndpointInterface, WebServiceFeature... features) {
return (T) invoke21Delegate(delegate, providerGetPort, endpointReference, serviceEndpointInterface, features);
}
private class ServiceDelegateWrapper extends ServiceDelegate {
private final ServiceDelegate serviceDelegate;
public ServiceDelegateWrapper(ServiceDelegate serviceDelegate) {
this.serviceDelegate = serviceDelegate;
}
public T getPort(QName portName, Class serviceEndpointInterface) {
T t = serviceDelegate.getPort(portName, serviceEndpointInterface);
setProperties((BindingProvider) t, portName);
return t;
}
public T getPort(Class serviceEndpointInterface) {
T t = serviceDelegate.getPort(serviceEndpointInterface);
QName qname = null;
if (serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
String targetNamespace = webService.targetNamespace();
String name = webService.name();
if (targetNamespace != null && targetNamespace.length() > 0 && name != null && name.length() > 0) {
qname = new QName(targetNamespace, name);
}
}
setProperties((BindingProvider) t, qname);
return t;
}
public void addPort(QName portName, String bindingId, String endpointAddress) {
serviceDelegate.addPort(portName, bindingId, endpointAddress);
}
public Dispatch createDispatch(QName portName, Class type, Service.Mode mode) {
Dispatch dispatch = serviceDelegate.createDispatch(portName, type, mode);
setProperties(dispatch, portName);
return dispatch;
}
public Dispatch