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 org.w3c.dom.Element;
import javax.jws.WebService;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Endpoint;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.handler.HandlerResolver;
import javax.xml.ws.soap.SOAPBinding;
import javax.xml.ws.spi.Provider;
import javax.xml.ws.spi.ServiceDelegate;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
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 final ThreadLocal threadPortRefs = new ThreadLocal();
public static void beforeCreate(final 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
final 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());
final 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(final List portRefMetaDatas, final 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;
}
@SuppressWarnings("unchecked")
@Override
public ServiceDelegate createServiceDelegate(final URL wsdlDocumentLocation, final QName serviceName, final Class serviceClass) {
ServiceDelegate serviceDelegate = delegate.createServiceDelegate(wsdlDocumentLocation, serviceName, serviceClass);
serviceDelegate = new ServiceDelegateWrapper(serviceDelegate);
return serviceDelegate;
}
@Override
public Endpoint createEndpoint(final String bindingId, final Object implementor) {
return delegate.createEndpoint(bindingId, implementor);
}
@Override
public Endpoint createAndPublishEndpoint(final String address, final Object implementor) {
return delegate.createAndPublishEndpoint(address, implementor);
}
@Override
public W3CEndpointReference createW3CEndpointReference(final String address,
final QName serviceName,
final QName portName,
final List metadata,
final String wsdlDocumentLocation,
final List referenceParameters) {
return (W3CEndpointReference) invoke21Delegate(delegate, createW3CEndpointReference,
address,
serviceName,
portName,
metadata,
wsdlDocumentLocation,
referenceParameters);
}
@Override
public EndpointReference readEndpointReference(final Source source) {
return (EndpointReference) invoke21Delegate(delegate, readEndpointReference, source);
}
@Override
@SuppressWarnings({"unchecked"})
public T getPort(final EndpointReference endpointReference, final Class serviceEndpointInterface, final WebServiceFeature... features) {
return (T) invoke21Delegate(delegate, providerGetPort, endpointReference, serviceEndpointInterface, features);
}
private class ServiceDelegateWrapper extends ServiceDelegate {
private final ServiceDelegate serviceDelegate;
public ServiceDelegateWrapper(final ServiceDelegate serviceDelegate) {
this.serviceDelegate = serviceDelegate;
}
@Override
public T getPort(final QName portName, final Class serviceEndpointInterface) {
final T t = serviceDelegate.getPort(portName, serviceEndpointInterface);
setProperties((BindingProvider) t, portName);
return t;
}
@Override
public T getPort(final Class serviceEndpointInterface) {
final T t = serviceDelegate.getPort(serviceEndpointInterface);
QName qname = null;
if (serviceEndpointInterface.isAnnotationPresent(WebService.class)) {
final WebService webService = serviceEndpointInterface.getAnnotation(WebService.class);
final String targetNamespace = webService.targetNamespace();
final 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;
}
@Override
public void addPort(final QName portName, final String bindingId, final String endpointAddress) {
serviceDelegate.addPort(portName, bindingId, endpointAddress);
}
@Override
public Dispatch createDispatch(final QName portName, final Class type, final Service.Mode mode) {
final Dispatch dispatch = serviceDelegate.createDispatch(portName, type, mode);
setProperties(dispatch, portName);
return dispatch;
}
@Override
public Dispatch