JBossWS SVN: r13138 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 08:47:32 -0400 (Fri, 15 Oct 2010)
New Revision: 13138
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java
Removed:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
Log:
refactoring
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceObjectFactoryJAXWS.java 2010-10-15 12:47:32 UTC (rev 13138)
@@ -0,0 +1,487 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.stack.cxf.client.HandlerResolverImpl;
+import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
+ * for a given WSDL when the webservice client does a JNDI lookup.
+ *
+ * @see CXFServiceReferenceableJAXWS
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @author Richard.Opalka(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
+ */
+public class CXFServiceObjectFactoryJAXWS implements ObjectFactory
+{
+ protected final Logger log = Logger.getLogger(CXFServiceObjectFactoryJAXWS.class);
+
+ /**
+ * Creates an object using the location or reference information specified.
+ * <p/>
+ *
+ * @param obj The possibly null object containing location or reference
+ * information that can be used in creating an object.
+ * @param name The name of this object relative to <code>nameCtx</code>,
+ * or null if no name is specified.
+ * @param nameCtx The context relative to which the <code>name</code>
+ * parameter is specified, or null if <code>name</code> is
+ * relative to the default initial context.
+ * @param environment The possibly null environment that is used in
+ * creating the object.
+ * @return The object created; null if an object cannot be created.
+ * @throws Exception if this object factory encountered an exception
+ * while attempting to create an object, and no other object factories are
+ * to be tried.
+ * @see javax.naming.spi.NamingManager#getObjectInstance
+ * @see javax.naming.spi.NamingManager#getURLContext
+ */
+ @SuppressWarnings(value = "unchecked")
+ public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
+ throws Exception
+ {
+ try
+ {
+ // references
+ final Reference ref = (Reference) obj;
+ final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ // class names
+ final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
+ final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
+ // class instances
+ final Class<?> serviceClass = this.getClass(serviceImplClass);
+ final Class<?> targetClass = this.getClass(targetClassName);
+ // clean thread local bus before constructing Service
+ BusFactory.setThreadDefaultBus(null);
+ try
+ {
+ // construct service
+ final Bus bus = this.createNewBus(serviceRef);
+ final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
+ if (serviceRef.getHandlerChain() != null)
+ {
+ serviceInstance.setHandlerResolver(new HandlerResolverImpl(bus, serviceRef.getHandlerChain(),
+ serviceInstance.getClass()));
+ }
+ // construct port
+ final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
+ if (instantiatePort)
+ {
+ final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
+ final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
+
+ return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
+ }
+
+ return serviceInstance;
+ }
+ finally
+ {
+ BusFactory.setThreadDefaultBus(null);
+ }
+ }
+ catch (Exception ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ }
+
+ return null;
+ }
+
+ private Class<?> getClass(final String className) throws ClassNotFoundException
+ {
+ if (className != null)
+ {
+ return Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+
+ return null;
+ }
+
+ private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final Bus bus;
+ final URL cxfConfig = this.getCXFConfiguration(serviceRefMD.getVfsRoot());
+ if (cxfConfig != null)
+ {
+ final SpringBusFactory busFactory = new JBossWSSpringBusFactory();
+ bus = busFactory.createBus(cxfConfig);
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ else
+ {
+ Bus threadBus = BusFactory.getThreadDefaultBus(false);
+ bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
+ }
+
+ //Add extension to configure stub properties using the UnifiedServiceRefMetaData
+ Configurer configurer = bus.getExtension(Configurer.class);
+ bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
+
+ return bus;
+ }
+
+ private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ String serviceClassName = serviceRefMD.getServiceImplClass();
+ if (serviceClassName == null)
+ serviceClassName = (String) ref.get(CXFServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
+
+ return serviceClassName;
+ }
+
+ private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
+ final String serviceImplClass)
+ {
+ String targetClassName = serviceRefMD.getServiceRefType();
+ if (targetClassName == null)
+ targetClassName = (String) ref.get(CXFServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
+
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ return targetClassName;
+ }
+
+ private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
+ final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
+ InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ Object retVal = null;
+
+ Object port = null;
+ if (serviceClass != Service.class)
+ {
+ for (Method method : serviceClass.getDeclaredMethods())
+ {
+ String methodName = method.getName();
+ Class<?> retType = method.getReturnType();
+ if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ retVal = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = getMethodFor(portQName, features, serviceClass);
+ Object[] args = getArgumentsFor(portQName, features, targetClass);
+ port = method.invoke(target, args);
+ retVal = port;
+ }
+
+ return retVal;
+ }
+
+ private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ final WebServiceFeature[] features = getFeatures(serviceRefMD);
+ final URL wsdlURL = serviceRefMD.getWsdlLocation();
+ final QName serviceQName = serviceRefMD.getServiceQName();
+
+ Service target = null;
+ if (serviceClass == Service.class)
+ {
+ // Generic javax.xml.ws.Service
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ target = Service.create(wsdlURL, serviceQName, features);
+ }
+ else
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
+ + serviceRefMD);
+ }
+ }
+ else
+ {
+ // Generated javax.xml.ws.Service subclass
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class, WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName, features});
+ }
+ else
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName});
+ }
+ }
+ else
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {features});
+ }
+ else
+ {
+ target = (Service) serviceClass.newInstance();
+ }
+ }
+ }
+
+ return target;
+ }
+
+ private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return getFeatures(portComponentRefMD);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private QName getPortQName(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return portComponentRefMD.getPortQName();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
+ throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class});
+ if ((portQName != null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class});
+ if ((portQName == null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class, WebServiceFeature[].class});
+ if ((portQName != null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class, WebServiceFeature[].class});
+
+ throw new IllegalStateException();
+ }
+
+ private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
+ final Class<?> targetClass) throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return new Object[]
+ {targetClass};
+ if ((portQName != null) && (features == null))
+ return new Object[]
+ {portQName, targetClass};
+ if ((portQName == null) && (features != null))
+ return new Object[]
+ {targetClass, features};
+ if ((portQName != null) && (features != null))
+ return new Object[]
+ {portQName, targetClass, features};
+
+ throw new IllegalStateException();
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+
+ // configure @Addressing feature
+ if (serviceRef.isAddressingEnabled())
+ {
+ final boolean required = serviceRef.isAddressingRequired();
+ final String refResponses = serviceRef.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (serviceRef.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (serviceRef.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ return wsFeatures;
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ // configure @Addressing feature
+ if (portComponentRefMD.isAddressingEnabled())
+ {
+ final boolean required = portComponentRefMD.isAddressingRequired();
+ final String refResponses = portComponentRefMD.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (portComponentRefMD.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (portComponentRefMD.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
+ NamingException
+ {
+ final UnifiedServiceRefMetaData sref;
+ final RefAddr refAddr = ref.get(CXFServiceReferenceableJAXWS.SERVICE_REF_META_DATA);
+ final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData) ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+
+ return sref;
+ }
+
+ private URL getCXFConfiguration(final UnifiedVirtualFile vfsRoot)
+ {
+ URL url = null;
+ try
+ {
+ url = vfsRoot.findChild("WEB-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e)
+ {
+ }
+
+ if (url == null)
+ {
+ try
+ {
+ url = vfsRoot.findChild("META-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ return url;
+ }
+}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java 2010-10-15 12:46:51 UTC (rev 13137)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java 2010-10-15 12:47:32 UTC (rev 13138)
@@ -38,6 +38,6 @@
protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
final UnifiedServiceRefMetaData serviceRefUMDM)
{
- return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
+ return new CXFServiceReferenceableJAXWS(serviceImplClass, targetClassName, serviceRefUMDM);
}
}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceReferenceableJAXWS.java 2010-10-15 12:47:32 UTC (rev 13138)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceReferenceableJAXWS;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class CXFServiceReferenceableJAXWS extends AbstractServiceReferenceableJAXWS<CXFServiceObjectFactoryJAXWS>
+{
+ public CXFServiceReferenceableJAXWS(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ super(serviceImplClass, targetClassName, serviceRefUMDM);
+ }
+
+ @Override
+ protected Class<CXFServiceObjectFactoryJAXWS> getObjectFactory()
+ {
+ return CXFServiceObjectFactoryJAXWS.class;
+ }
+}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java 2010-10-15 12:46:51 UTC (rev 13137)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java 2010-10-15 12:47:32 UTC (rev 13138)
@@ -1,487 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client.serviceref;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBindingFeature;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOMFeature;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.configuration.Configurer;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.stack.cxf.client.HandlerResolverImpl;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
-
-/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup.
- *
- * @see ServiceReferenceable
- *
- * @author Thomas.Diesler(a)jboss.com
- * @author Richard.Opalka(a)jboss.com
- * @author alessio.soldano(a)jboss.com
- */
-public class ServiceObjectFactory implements ObjectFactory
-{
- protected final Logger log = Logger.getLogger(ServiceObjectFactory.class);
-
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to <code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code> is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- @SuppressWarnings(value = "unchecked")
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
- throws Exception
- {
- try
- {
- // references
- final Reference ref = (Reference) obj;
- final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- // class names
- final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
- final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
- // class instances
- final Class<?> serviceClass = this.getClass(serviceImplClass);
- final Class<?> targetClass = this.getClass(targetClassName);
- // clean thread local bus before constructing Service
- BusFactory.setThreadDefaultBus(null);
- try
- {
- // construct service
- final Bus bus = this.createNewBus(serviceRef);
- final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
- if (serviceRef.getHandlerChain() != null)
- {
- serviceInstance.setHandlerResolver(new HandlerResolverImpl(bus, serviceRef.getHandlerChain(),
- serviceInstance.getClass()));
- }
- // construct port
- final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
- if (instantiatePort)
- {
- final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
- final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
-
- return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
- }
-
- return serviceInstance;
- }
- finally
- {
- BusFactory.setThreadDefaultBus(null);
- }
- }
- catch (Exception ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- }
-
- return null;
- }
-
- private Class<?> getClass(final String className) throws ClassNotFoundException
- {
- if (className != null)
- {
- return Thread.currentThread().getContextClassLoader().loadClass(className);
- }
-
- return null;
- }
-
- private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
- {
- final Bus bus;
- final URL cxfConfig = this.getCXFConfiguration(serviceRefMD.getVfsRoot());
- if (cxfConfig != null)
- {
- final SpringBusFactory busFactory = new JBossWSSpringBusFactory();
- bus = busFactory.createBus(cxfConfig);
- BusFactory.setThreadDefaultBus(bus);
- }
- else
- {
- Bus threadBus = BusFactory.getThreadDefaultBus(false);
- bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
- }
-
- //Add extension to configure stub properties using the UnifiedServiceRefMetaData
- Configurer configurer = bus.getExtension(Configurer.class);
- bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
-
- return bus;
- }
-
- private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
- {
- String serviceClassName = serviceRefMD.getServiceImplClass();
- if (serviceClassName == null)
- serviceClassName = (String) ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
-
- return serviceClassName;
- }
-
- private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
- final String serviceImplClass)
- {
- String targetClassName = serviceRefMD.getServiceRefType();
- if (targetClassName == null)
- targetClassName = (String) ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();
-
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- return targetClassName;
- }
-
- private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
- final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
- InstantiationException, IllegalAccessException, InvocationTargetException
- {
- Object retVal = null;
-
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class<?> retType = method.getReturnType();
- if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- retVal = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = getMethodFor(portQName, features, serviceClass);
- Object[] args = getArgumentsFor(portQName, features, targetClass);
- port = method.invoke(target, args);
- retVal = port;
- }
-
- return retVal;
- }
-
- private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- final WebServiceFeature[] features = getFeatures(serviceRefMD);
- final URL wsdlURL = serviceRefMD.getWsdlLocation();
- final QName serviceQName = serviceRefMD.getServiceQName();
-
- Service target = null;
- if (serviceClass == Service.class)
- {
- // Generic javax.xml.ws.Service
- if (wsdlURL != null)
- {
- if (features != null)
- {
- target = Service.create(wsdlURL, serviceQName, features);
- }
- else
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
- + serviceRefMD);
- }
- }
- else
- {
- // Generated javax.xml.ws.Service subclass
- if (wsdlURL != null)
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class, WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName, features});
- }
- else
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName});
- }
- }
- else
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {features});
- }
- else
- {
- target = (Service) serviceClass.newInstance();
- }
- }
- }
-
- return target;
- }
-
- private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return getFeatures(portComponentRefMD);
- }
- }
- }
-
- return null;
- }
-
- private QName getPortQName(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return portComponentRefMD.getPortQName();
- }
- }
- }
-
- return null;
- }
-
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
- throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class});
- if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class});
- if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class, WebServiceFeature[].class});
- if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class, WebServiceFeature[].class});
-
- throw new IllegalStateException();
- }
-
- private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
- final Class<?> targetClass) throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return new Object[]
- {targetClass};
- if ((portQName != null) && (features == null))
- return new Object[]
- {portQName, targetClass};
- if ((portQName == null) && (features != null))
- return new Object[]
- {targetClass, features};
- if ((portQName != null) && (features != null))
- return new Object[]
- {portQName, targetClass, features};
-
- throw new IllegalStateException();
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
-
- // configure @Addressing feature
- if (serviceRef.isAddressingEnabled())
- {
- final boolean required = serviceRef.isAddressingRequired();
- final String refResponses = serviceRef.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (serviceRef.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (serviceRef.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- return wsFeatures;
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- // configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
- {
- final boolean required = portComponentRefMD.isAddressingRequired();
- final String refResponses = portComponentRefMD.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (portComponentRefMD.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
- NamingException
- {
- final UnifiedServiceRefMetaData sref;
- final RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
- final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData) ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
- }
-
- return sref;
- }
-
- private URL getCXFConfiguration(final UnifiedVirtualFile vfsRoot)
- {
- URL url = null;
- try
- {
- url = vfsRoot.findChild("WEB-INF/jbossws-cxf.xml").toURL();
- }
- catch (Exception e)
- {
- }
-
- if (url == null)
- {
- try
- {
- url = vfsRoot.findChild("META-INF/jbossws-cxf.xml").toURL();
- }
- catch (Exception e)
- {
- }
- }
- return url;
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java 2010-10-15 12:46:51 UTC (rev 13137)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java 2010-10-15 12:47:32 UTC (rev 13138)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client.serviceref;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.*;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-
-/**
- * A JNDI reference to a javax.xml.ws.Service
- *
- * It holds the information to reconstrut the javax.xml.ws.Service
- * when the client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 06-Dec-2007
- */
-public class ServiceReferenceable implements Referenceable
-{
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
- public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
- public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
-
- private String serviceImplClass;
- private String targetClassName;
- private UnifiedServiceRefMetaData serviceRef;
-
- public ServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
- {
- this.serviceImplClass = serviceImplClass;
- this.targetClassName = targetClassName;
- this.serviceRef = serviceRef;
- }
-
- /**
- * Retrieves the Reference of this object.
- *
- * @return The non-null Reference of this object.
- * @throws javax.naming.NamingException If a naming exception was encountered while retrieving the reference.
- */
- public Reference getReference() throws NamingException
- {
- Reference myRef = new Reference(ServiceReferenceable.class.getName(), ServiceObjectFactory.class.getName(), null);
-
- myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
- myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
-
- return myRef;
- }
-
- private byte[] marshall(Object obj) throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot marshall object, cause: " + e.toString());
- }
- return baos.toByteArray();
- }
-
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("\n").append(getClass().getName());
- sb.append("\n serviceImplClass=" + serviceImplClass);
- sb.append("\n targetClassName=" + targetClassName);
- sb.append("\n serviceRef=" + this.serviceRef);
- return sb.toString();
- }
-}
14 years, 2 months
JBossWS SVN: r13137 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws: core/jaxws/spi and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 08:46:51 -0400 (Fri, 15 Oct 2010)
New Revision: 13137
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceReferenceableJAXWS.java
Removed:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceReferenceable.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
Log:
refactoring
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceObjectFactoryJAXWS.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -0,0 +1,454 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.core.jaxws.client;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.ConfigProvider;
+import org.jboss.ws.core.client.ServiceObjectFactory;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
+ * for a given WSDL when the webservice client does a JNDI lookup.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author Richard.Opalka(a)jboss.org
+ * @since 24-Oct-2004
+ */
+public class NativeServiceObjectFactoryJAXWS extends ServiceObjectFactory
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(NativeServiceObjectFactoryJAXWS.class);
+
+ // The ServiceRefMetaData association
+ private static ThreadLocal<UnifiedServiceRefMetaData> serviceRefAssociation = new ThreadLocal<UnifiedServiceRefMetaData>();
+
+ /**
+ * Creates an object using the location or reference information specified.
+ * <p/>
+ *
+ * @param obj The possibly null object containing location or reference
+ * information that can be used in creating an object.
+ * @param name The name of this object relative to <code>nameCtx</code>,
+ * or null if no name is specified.
+ * @param nameCtx The context relative to which the <code>name</code>
+ * parameter is specified, or null if <code>name</code> is
+ * relative to the default initial context.
+ * @param environment The possibly null environment that is used in
+ * creating the object.
+ * @return The object created; null if an object cannot be created.
+ * @throws Exception if this object factory encountered an exception
+ * while attempting to create an object, and no other object factories are
+ * to be tried.
+ * @see javax.naming.spi.NamingManager#getObjectInstance
+ * @see javax.naming.spi.NamingManager#getURLContext
+ */
+ @SuppressWarnings(value = "unchecked")
+ public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
+ throws Exception
+ {
+ try
+ {
+ // references
+ final Reference ref = (Reference) obj;
+ final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ // class names
+ final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
+ final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
+ // class instances
+ final Class<?> serviceClass = this.getClass(serviceImplClass);
+ final Class<?> targetClass = this.getClass(targetClassName);
+ final Service serviceInstance;
+ try
+ {
+ // Associate the ServiceRefMetaData with this thread
+ serviceRefAssociation.set(serviceRef);
+ // construct service
+ serviceInstance = this.instantiateService(serviceRef, serviceClass);
+ }
+ finally
+ {
+ serviceRefAssociation.set(null);
+ }
+ // Configure the service
+ configureService(serviceInstance, serviceRef);
+ // construct port
+ final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
+ if (instantiatePort)
+ {
+ final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
+ final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
+
+ return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
+ }
+
+ return serviceInstance;
+ }
+ catch (Exception ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ }
+
+ return null;
+ }
+
+ public static UnifiedServiceRefMetaData getServiceRefAssociation()
+ {
+ return serviceRefAssociation.get();
+ }
+
+ private void configureService(final Service service, final UnifiedServiceRefMetaData serviceRef)
+ {
+ final String configFile = serviceRef.getConfigFile();
+ final String configName = serviceRef.getConfigName();
+ if (service instanceof ConfigProvider)
+ {
+ if(log.isDebugEnabled()) log.debug("Configure Service: [configName=" + configName + ",configFile=" + configFile + "]");
+
+ final ConfigProvider cp = (ConfigProvider)service;
+ if (configName != null || configFile != null)
+ {
+ cp.setConfigName(configName, configFile);
+ }
+ }
+ }
+
+ private Class<?> getClass(final String className) throws ClassNotFoundException
+ {
+ if (className != null)
+ {
+ return SecurityActions.getContextClassLoader().loadClass(className);
+ }
+
+ return null;
+ }
+
+ private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ String serviceClassName = serviceRefMD.getServiceImplClass();
+ if (serviceClassName == null)
+ serviceClassName = (String) ref.get(NativeServiceReferenceableJAXWS.SERVICE_IMPL_CLASS).getContent();
+
+ return serviceClassName;
+ }
+
+ private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
+ final String serviceImplClass)
+ {
+ String targetClassName = serviceRefMD.getServiceRefType();
+ if (targetClassName == null)
+ targetClassName = (String) ref.get(NativeServiceReferenceableJAXWS.TARGET_CLASS_NAME).getContent();
+
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ return targetClassName;
+ }
+
+ private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
+ final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
+ InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ Object retVal = null;
+
+ Object port = null;
+ if (serviceClass != Service.class)
+ {
+ for (Method method : serviceClass.getDeclaredMethods())
+ {
+ String methodName = method.getName();
+ Class<?> retType = method.getReturnType();
+ if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ retVal = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = getMethodFor(portQName, features, serviceClass);
+ Object[] args = getArgumentsFor(portQName, features, targetClass);
+ port = method.invoke(target, args);
+ retVal = port;
+ }
+
+ return retVal;
+ }
+
+ private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ final WebServiceFeature[] features = getFeatures(serviceRefMD);
+ final URL wsdlURL = serviceRefMD.getWsdlLocation();
+ final QName serviceQName = serviceRefMD.getServiceQName();
+
+ Service target = null;
+ if (serviceClass == Service.class)
+ {
+ // Generic javax.xml.ws.Service
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ target = Service.create(wsdlURL, serviceQName, features);
+ }
+ else
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
+ + serviceRefMD);
+ }
+ }
+ else
+ {
+ // Generated javax.xml.ws.Service subclass
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class, WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName, features});
+ }
+ else
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName});
+ }
+ }
+ else
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {features});
+ }
+ else
+ {
+ target = (Service) serviceClass.newInstance();
+ }
+ }
+ }
+
+ return target;
+ }
+
+ private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return getFeatures(portComponentRefMD);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private QName getPortQName(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return portComponentRefMD.getPortQName();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
+ throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class});
+ if ((portQName != null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class});
+ if ((portQName == null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class, WebServiceFeature[].class});
+ if ((portQName != null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class, WebServiceFeature[].class});
+
+ throw new IllegalStateException();
+ }
+
+ private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
+ final Class<?> targetClass) throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return new Object[]
+ {targetClass};
+ if ((portQName != null) && (features == null))
+ return new Object[]
+ {portQName, targetClass};
+ if ((portQName == null) && (features != null))
+ return new Object[]
+ {targetClass, features};
+ if ((portQName != null) && (features != null))
+ return new Object[]
+ {portQName, targetClass, features};
+
+ throw new IllegalStateException();
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+
+ // configure @Addressing feature
+ if (serviceRef.isAddressingEnabled())
+ {
+ final boolean required = serviceRef.isAddressingRequired();
+ final String refResponses = serviceRef.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (serviceRef.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (serviceRef.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ return wsFeatures;
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ // configure @Addressing feature
+ if (portComponentRefMD.isAddressingEnabled())
+ {
+ final boolean required = portComponentRefMD.isAddressingRequired();
+ final String refResponses = portComponentRefMD.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (portComponentRefMD.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (portComponentRefMD.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
+ NamingException
+ {
+ final UnifiedServiceRefMetaData sref;
+ final RefAddr refAddr = ref.get(NativeServiceReferenceableJAXWS.SERVICE_REF_META_DATA);
+ final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData) ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+
+ return sref;
+ }
+}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 12:43:36 UTC (rev 13136)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -38,6 +38,6 @@
protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
final UnifiedServiceRefMetaData serviceRefUMDM)
{
- return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
+ return new NativeServiceReferenceableJAXWS(serviceImplClass, targetClassName, serviceRefUMDM);
}
}
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceReferenceableJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceReferenceableJAXWS.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceReferenceableJAXWS.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.core.jaxws.client;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceReferenceableJAXWS;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class NativeServiceReferenceableJAXWS extends AbstractServiceReferenceableJAXWS<NativeServiceObjectFactoryJAXWS>
+{
+ public NativeServiceReferenceableJAXWS(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ super(serviceImplClass, targetClassName, serviceRefUMDM);
+ }
+
+ @Override
+ protected Class<NativeServiceObjectFactoryJAXWS> getObjectFactory()
+ {
+ return NativeServiceObjectFactoryJAXWS.class;
+ }
+}
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java 2010-10-15 12:43:36 UTC (rev 13136)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -1,454 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.jaxws.client;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBindingFeature;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOMFeature;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.ConfigProvider;
-import org.jboss.ws.core.client.ServiceObjectFactory;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author Richard.Opalka(a)jboss.org
- * @since 24-Oct-2004
- */
-public class ServiceObjectFactoryJAXWS extends ServiceObjectFactory
-{
- // provide logging
- private static final Logger log = Logger.getLogger(ServiceObjectFactoryJAXWS.class);
-
- // The ServiceRefMetaData association
- private static ThreadLocal<UnifiedServiceRefMetaData> serviceRefAssociation = new ThreadLocal<UnifiedServiceRefMetaData>();
-
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to <code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code> is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- @SuppressWarnings(value = "unchecked")
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
- throws Exception
- {
- try
- {
- // references
- final Reference ref = (Reference) obj;
- final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- // class names
- final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
- final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
- // class instances
- final Class<?> serviceClass = this.getClass(serviceImplClass);
- final Class<?> targetClass = this.getClass(targetClassName);
- final Service serviceInstance;
- try
- {
- // Associate the ServiceRefMetaData with this thread
- serviceRefAssociation.set(serviceRef);
- // construct service
- serviceInstance = this.instantiateService(serviceRef, serviceClass);
- }
- finally
- {
- serviceRefAssociation.set(null);
- }
- // Configure the service
- configureService(serviceInstance, serviceRef);
- // construct port
- final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
- if (instantiatePort)
- {
- final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
- final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
-
- return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
- }
-
- return serviceInstance;
- }
- catch (Exception ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- }
-
- return null;
- }
-
- public static UnifiedServiceRefMetaData getServiceRefAssociation()
- {
- return serviceRefAssociation.get();
- }
-
- private void configureService(final Service service, final UnifiedServiceRefMetaData serviceRef)
- {
- final String configFile = serviceRef.getConfigFile();
- final String configName = serviceRef.getConfigName();
- if (service instanceof ConfigProvider)
- {
- if(log.isDebugEnabled()) log.debug("Configure Service: [configName=" + configName + ",configFile=" + configFile + "]");
-
- final ConfigProvider cp = (ConfigProvider)service;
- if (configName != null || configFile != null)
- {
- cp.setConfigName(configName, configFile);
- }
- }
- }
-
- private Class<?> getClass(final String className) throws ClassNotFoundException
- {
- if (className != null)
- {
- return SecurityActions.getContextClassLoader().loadClass(className);
- }
-
- return null;
- }
-
- private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
- {
- String serviceClassName = serviceRefMD.getServiceImplClass();
- if (serviceClassName == null)
- serviceClassName = (String) ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
-
- return serviceClassName;
- }
-
- private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
- final String serviceImplClass)
- {
- String targetClassName = serviceRefMD.getServiceRefType();
- if (targetClassName == null)
- targetClassName = (String) ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();
-
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- return targetClassName;
- }
-
- private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
- final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
- InstantiationException, IllegalAccessException, InvocationTargetException
- {
- Object retVal = null;
-
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class<?> retType = method.getReturnType();
- if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- retVal = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = getMethodFor(portQName, features, serviceClass);
- Object[] args = getArgumentsFor(portQName, features, targetClass);
- port = method.invoke(target, args);
- retVal = port;
- }
-
- return retVal;
- }
-
- private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- final WebServiceFeature[] features = getFeatures(serviceRefMD);
- final URL wsdlURL = serviceRefMD.getWsdlLocation();
- final QName serviceQName = serviceRefMD.getServiceQName();
-
- Service target = null;
- if (serviceClass == Service.class)
- {
- // Generic javax.xml.ws.Service
- if (wsdlURL != null)
- {
- if (features != null)
- {
- target = Service.create(wsdlURL, serviceQName, features);
- }
- else
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
- + serviceRefMD);
- }
- }
- else
- {
- // Generated javax.xml.ws.Service subclass
- if (wsdlURL != null)
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class, WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName, features});
- }
- else
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName});
- }
- }
- else
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {features});
- }
- else
- {
- target = (Service) serviceClass.newInstance();
- }
- }
- }
-
- return target;
- }
-
- private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return getFeatures(portComponentRefMD);
- }
- }
- }
-
- return null;
- }
-
- private QName getPortQName(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return portComponentRefMD.getPortQName();
- }
- }
- }
-
- return null;
- }
-
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
- throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class});
- if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class});
- if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class, WebServiceFeature[].class});
- if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class, WebServiceFeature[].class});
-
- throw new IllegalStateException();
- }
-
- private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
- final Class<?> targetClass) throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return new Object[]
- {targetClass};
- if ((portQName != null) && (features == null))
- return new Object[]
- {portQName, targetClass};
- if ((portQName == null) && (features != null))
- return new Object[]
- {targetClass, features};
- if ((portQName != null) && (features != null))
- return new Object[]
- {portQName, targetClass, features};
-
- throw new IllegalStateException();
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
-
- // configure @Addressing feature
- if (serviceRef.isAddressingEnabled())
- {
- final boolean required = serviceRef.isAddressingRequired();
- final String refResponses = serviceRef.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (serviceRef.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (serviceRef.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- return wsFeatures;
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- // configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
- {
- final boolean required = portComponentRefMD.isAddressingRequired();
- final String refResponses = portComponentRefMD.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (portComponentRefMD.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
- NamingException
- {
- final UnifiedServiceRefMetaData sref;
- final RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
- final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData) ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
- }
-
- return sref;
- }
-}
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceReferenceable.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceReferenceable.java 2010-10-15 12:43:36 UTC (rev 13136)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceReferenceable.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -1,104 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.jaxws.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import javax.naming.BinaryRefAddr;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-
-/**
- * A JNDI reference to a javax.xml.ws.Service
- *
- * It holds the information to reconstrut the javax.xml.ws.Service
- * when the client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 24-Oct-2006
- */
-public class ServiceReferenceable implements Referenceable
-{
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
- public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
- public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
-
- private String serviceImplClass;
- private String targetClassName;
- private UnifiedServiceRefMetaData serviceRef;
-
- public ServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
- {
- this.serviceImplClass = serviceImplClass;
- this.targetClassName = targetClassName;
- this.serviceRef = serviceRef;
- }
-
- /**
- * Retrieves the Reference of this object.
- *
- * @return The non-null Reference of this object.
- * @throws javax.naming.NamingException If a naming exception was encountered while retrieving the reference.
- */
- public Reference getReference() throws NamingException
- {
- Reference myRef = new Reference(ServiceReferenceable.class.getName(), ServiceObjectFactoryJAXWS.class.getName(), null);
-
- myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
- myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
-
- return myRef;
- }
-
- private byte[] marshall(Object obj) throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot marshall object, cause: " + e.toString());
- }
- return baos.toByteArray();
- }
-
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("\n").append(getClass().getName());
- sb.append("\n serviceImplClass=" + serviceImplClass);
- sb.append("\n targetClassName=" + targetClassName);
- sb.append("\n serviceRef=" + this.serviceRef);
- return sb.toString();
- }
-}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2010-10-15 12:43:36 UTC (rev 13136)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/spi/ServiceDelegateImpl.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -60,7 +60,7 @@
import org.jboss.ws.core.jaxws.client.ClientImpl;
import org.jboss.ws.core.jaxws.client.ClientProxy;
import org.jboss.ws.core.jaxws.client.DispatchImpl;
-import org.jboss.ws.core.jaxws.client.ServiceObjectFactoryJAXWS;
+import org.jboss.ws.core.jaxws.client.NativeServiceObjectFactoryJAXWS;
import org.jboss.ws.core.jaxws.handler.HandlerResolverImpl;
import org.jboss.ws.core.jaxws.wsaddressing.EndpointReferenceUtil;
import org.jboss.ws.core.jaxws.wsaddressing.NativeEndpointReference;
@@ -130,7 +130,7 @@
{
// If this Service was constructed through the ServiceObjectFactory
// this thread local association should be available
- usRef = ServiceObjectFactoryJAXWS.getServiceRefAssociation();
+ usRef = NativeServiceObjectFactoryJAXWS.getServiceRefAssociation();
UnifiedVirtualFile vfsRoot = (usRef != null ? vfsRoot = usRef.getVfsRoot() : new ResourceLoaderAdapter());
// Verify wsdl access if this is not a generic Service
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2010-10-15 12:43:36 UTC (rev 13136)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSClientMetaDataBuilder.java 2010-10-15 12:46:51 UTC (rev 13137)
@@ -35,7 +35,7 @@
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
import org.jboss.ws.annotation.EndpointConfig;
-import org.jboss.ws.core.jaxws.client.ServiceObjectFactoryJAXWS;
+import org.jboss.ws.core.jaxws.client.NativeServiceObjectFactoryJAXWS;
import org.jboss.ws.core.jaxws.wsaddressing.NativeEndpointReference;
import org.jboss.ws.extensions.policy.metadata.PolicyMetaDataBuilder;
import org.jboss.ws.extensions.wsrm.common.RMHelper;
@@ -219,7 +219,7 @@
*/
private void bufferServiceRefContributions(EndpointMetaData epMetaData)
{
- UnifiedServiceRefMetaData serviceRefMetaData = ServiceObjectFactoryJAXWS.getServiceRefAssociation();
+ UnifiedServiceRefMetaData serviceRefMetaData = NativeServiceObjectFactoryJAXWS.getServiceRefAssociation();
if (serviceRefMetaData != null)
{
14 years, 2 months
JBossWS SVN: r13136 - common/trunk/src/main/java/org/jboss/wsf/common/serviceref.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 08:43:36 -0400 (Fri, 15 Oct 2010)
New Revision: 13136
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java
Log:
refactoring
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceReferenceableJAXWS.java 2010-10-15 12:43:36 UTC (rev 13136)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.serviceref;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.naming.BinaryRefAddr;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * A JNDI reference to a javax.xml.ws.Service metadata.
+ *
+ * It holds all the information necessary to reconstruct the javax.xml.ws.Service
+ * instances when client does a JNDI lookup.
+ *
+ * @param <T> JNDI object factory type
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public abstract class AbstractServiceReferenceableJAXWS<T extends ObjectFactory> implements Referenceable
+{
+ public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
+
+ public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
+
+ public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
+
+ private final String serviceImplClass;
+
+ private final String targetClassName;
+
+ private final UnifiedServiceRefMetaData serviceRef;
+
+ public AbstractServiceReferenceableJAXWS(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRef)
+ {
+ this.serviceImplClass = serviceImplClass;
+ this.targetClassName = targetClassName;
+ this.serviceRef = serviceRef;
+ }
+
+ public Reference getReference() throws NamingException
+ {
+ final Reference myRef = new Reference(getClass().getName(), this.getObjectFactory().getName(), null);
+
+ myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, this.serviceImplClass));
+ myRef.add(new StringRefAddr(TARGET_CLASS_NAME, this.targetClassName));
+ myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, this.marshall(this.serviceRef)));
+
+ return myRef;
+ }
+
+ protected abstract Class<T> getObjectFactory();
+
+ private byte[] marshall(final Object obj) throws NamingException
+ {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+
+ try
+ {
+ final ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.close();
+ }
+ catch (final IOException e)
+ {
+ throw new NamingException("Cannot marshall object, cause: " + e.toString());
+ }
+
+ return baos.toByteArray();
+ }
+
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("\n").append(getClass().getName());
+ sb.append("\n serviceImplClass=" + serviceImplClass);
+ sb.append("\n targetClassName=" + targetClassName);
+ sb.append("\n serviceRef=" + this.serviceRef);
+
+ return sb.toString();
+ }
+}
14 years, 2 months
JBossWS SVN: r13135 - in stack/cxf/trunk/modules: client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 07:19:31 -0400 (Fri, 15 Oct 2010)
New Revision: 13135
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java
Removed:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java
Modified:
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
Log:
refactoring - optimization
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import javax.naming.Referenceable;
-
-import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXRPC;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * Binds a JAXRPC Service object to the client's ENC.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public final class CXFServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
-{
- @Override
- protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
- {
- throw new IllegalArgumentException("CXF does not support JAX-RPC");
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import javax.naming.Referenceable;
-
-import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXWS;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * Binds a JAXWS Service object to the client's ENC.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
- */
-public final class CXFServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
-{
- @Override
- protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
- final UnifiedServiceRefMetaData serviceRefUMDM)
- {
- return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,486 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBindingFeature;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOMFeature;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.configuration.Configurer;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
-
-/**
- * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
- * for a given WSDL when the webservice client does a JNDI lookup.
- *
- * @see ServiceReferenceable
- *
- * @author Thomas.Diesler(a)jboss.com
- * @author Richard.Opalka(a)jboss.com
- * @author alessio.soldano(a)jboss.com
- */
-public class ServiceObjectFactory implements ObjectFactory
-{
- protected final Logger log = Logger.getLogger(ServiceObjectFactory.class);
-
- /**
- * Creates an object using the location or reference information specified.
- * <p/>
- *
- * @param obj The possibly null object containing location or reference
- * information that can be used in creating an object.
- * @param name The name of this object relative to <code>nameCtx</code>,
- * or null if no name is specified.
- * @param nameCtx The context relative to which the <code>name</code>
- * parameter is specified, or null if <code>name</code> is
- * relative to the default initial context.
- * @param environment The possibly null environment that is used in
- * creating the object.
- * @return The object created; null if an object cannot be created.
- * @throws Exception if this object factory encountered an exception
- * while attempting to create an object, and no other object factories are
- * to be tried.
- * @see javax.naming.spi.NamingManager#getObjectInstance
- * @see javax.naming.spi.NamingManager#getURLContext
- */
- @SuppressWarnings(value = "unchecked")
- public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
- throws Exception
- {
- try
- {
- // references
- final Reference ref = (Reference) obj;
- final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
- // class names
- final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
- final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
- // class instances
- final Class<?> serviceClass = this.getClass(serviceImplClass);
- final Class<?> targetClass = this.getClass(targetClassName);
- // clean thread local bus before constructing Service
- BusFactory.setThreadDefaultBus(null);
- try
- {
- // construct service
- final Bus bus = this.createNewBus(serviceRef);
- final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
- if (serviceRef.getHandlerChain() != null)
- {
- serviceInstance.setHandlerResolver(new HandlerResolverImpl(bus, serviceRef.getHandlerChain(),
- serviceInstance.getClass()));
- }
- // construct port
- final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
- if (instantiatePort)
- {
- final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
- final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
-
- return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
- }
-
- return serviceInstance;
- }
- finally
- {
- BusFactory.setThreadDefaultBus(null);
- }
- }
- catch (Exception ex)
- {
- WSFException.rethrow("Cannot create service", ex);
- }
-
- return null;
- }
-
- private Class<?> getClass(final String className) throws ClassNotFoundException
- {
- if (className != null)
- {
- return Thread.currentThread().getContextClassLoader().loadClass(className);
- }
-
- return null;
- }
-
- private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
- {
- final Bus bus;
- final URL cxfConfig = this.getCXFConfiguration(serviceRefMD.getVfsRoot());
- if (cxfConfig != null)
- {
- final SpringBusFactory busFactory = new JBossWSSpringBusFactory();
- bus = busFactory.createBus(cxfConfig);
- BusFactory.setThreadDefaultBus(bus);
- }
- else
- {
- Bus threadBus = BusFactory.getThreadDefaultBus(false);
- bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
- }
-
- //Add extension to configure stub properties using the UnifiedServiceRefMetaData
- Configurer configurer = bus.getExtension(Configurer.class);
- bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
-
- return bus;
- }
-
- private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
- {
- String serviceClassName = serviceRefMD.getServiceImplClass();
- if (serviceClassName == null)
- serviceClassName = (String) ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
-
- return serviceClassName;
- }
-
- private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
- final String serviceImplClass)
- {
- String targetClassName = serviceRefMD.getServiceRefType();
- if (targetClassName == null)
- targetClassName = (String) ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();
-
- if (Service.class.getName().equals(targetClassName))
- targetClassName = serviceImplClass;
-
- return targetClassName;
- }
-
- private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
- final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
- InstantiationException, IllegalAccessException, InvocationTargetException
- {
- Object retVal = null;
-
- Object port = null;
- if (serviceClass != Service.class)
- {
- for (Method method : serviceClass.getDeclaredMethods())
- {
- String methodName = method.getName();
- Class<?> retType = method.getReturnType();
- if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- retVal = port;
- break;
- }
- }
- }
-
- if (port == null)
- {
- Method method = getMethodFor(portQName, features, serviceClass);
- Object[] args = getArgumentsFor(portQName, features, targetClass);
- port = method.invoke(target, args);
- retVal = port;
- }
-
- return retVal;
- }
-
- private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- final WebServiceFeature[] features = getFeatures(serviceRefMD);
- final URL wsdlURL = serviceRefMD.getWsdlLocation();
- final QName serviceQName = serviceRefMD.getServiceQName();
-
- Service target = null;
- if (serviceClass == Service.class)
- {
- // Generic javax.xml.ws.Service
- if (wsdlURL != null)
- {
- if (features != null)
- {
- target = Service.create(wsdlURL, serviceQName, features);
- }
- else
- {
- target = Service.create(wsdlURL, serviceQName);
- }
- }
- else
- {
- throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
- + serviceRefMD);
- }
- }
- else
- {
- // Generated javax.xml.ws.Service subclass
- if (wsdlURL != null)
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class, WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName, features});
- }
- else
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {URL.class, QName.class});
- target = (Service) ctor.newInstance(new Object[]
- {wsdlURL, serviceQName});
- }
- }
- else
- {
- if (features != null)
- {
- Constructor<?> ctor = serviceClass.getConstructor(new Class[]
- {WebServiceFeature[].class});
- target = (Service) ctor.newInstance(new Object[]
- {features});
- }
- else
- {
- target = (Service) serviceClass.newInstance();
- }
- }
- }
-
- return target;
- }
-
- private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return getFeatures(portComponentRefMD);
- }
- }
- }
-
- return null;
- }
-
- private QName getPortQName(final String targetClassName, final String serviceClassName,
- final UnifiedServiceRefMetaData serviceRefMD)
- {
- if (targetClassName != null && !targetClassName.equals(serviceClassName))
- {
- final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
- for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
- {
- if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
- {
- return portComponentRefMD.getPortQName();
- }
- }
- }
-
- return null;
- }
-
- private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
- throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class});
- if ((portQName != null) && (features == null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class});
- if ((portQName == null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {Class.class, WebServiceFeature[].class});
- if ((portQName != null) && (features != null))
- return serviceClass.getMethod("getPort", new Class[]
- {QName.class, Class.class, WebServiceFeature[].class});
-
- throw new IllegalStateException();
- }
-
- private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
- final Class<?> targetClass) throws NoSuchMethodException
- {
- if ((portQName == null) && (features == null))
- return new Object[]
- {targetClass};
- if ((portQName != null) && (features == null))
- return new Object[]
- {portQName, targetClass};
- if ((portQName == null) && (features != null))
- return new Object[]
- {targetClass, features};
- if ((portQName != null) && (features != null))
- return new Object[]
- {portQName, targetClass, features};
-
- throw new IllegalStateException();
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
-
- // configure @Addressing feature
- if (serviceRef.isAddressingEnabled())
- {
- final boolean required = serviceRef.isAddressingRequired();
- final String refResponses = serviceRef.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (serviceRef.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (serviceRef.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- return wsFeatures;
- }
-
- private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- // configure @Addressing feature
- if (portComponentRefMD.isAddressingEnabled())
- {
- final boolean required = portComponentRefMD.isAddressingRequired();
- final String refResponses = portComponentRefMD.getAddressingResponses();
- AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
- if ("ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.ANONYMOUS;
- if ("NON_ANONYMOUS".equals(refResponses))
- responses = AddressingFeature.Responses.NON_ANONYMOUS;
-
- features.add(new AddressingFeature(true, required, responses));
- }
-
- // configure @MTOM feature
- if (portComponentRefMD.isMtomEnabled())
- {
- features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
- }
-
- // configure @RespectBinding feature
- if (portComponentRefMD.isRespectBindingEnabled())
- {
- features.add(new RespectBindingFeature(true));
- }
-
- return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
- {});
- }
-
- private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
- NamingException
- {
- final UnifiedServiceRefMetaData sref;
- final RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
- final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
- try
- {
- ObjectInputStream ois = new ObjectInputStream(bais);
- sref = (UnifiedServiceRefMetaData) ois.readObject();
- ois.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
- }
-
- return sref;
- }
-
- private URL getCXFConfiguration(final UnifiedVirtualFile vfsRoot)
- {
- URL url = null;
- try
- {
- url = vfsRoot.findChild("WEB-INF/jbossws-cxf.xml").toURL();
- }
- catch (Exception e)
- {
- }
-
- if (url == null)
- {
- try
- {
- url = vfsRoot.findChild("META-INF/jbossws-cxf.xml").toURL();
- }
- catch (Exception e)
- {
- }
- }
- return url;
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
-
-/**
- * Binds a JAXWS Service object in the client's ENC
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 06-Dec-2007
- */
-public class ServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
-{
- public ServiceRefBinder newServiceRefBinder(Type type)
- {
- return (type == Type.JAXRPC ? new CXFServiceRefBinderJAXRPC() : new CXFServiceRefBinderJAXWS());
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefStubPropertyConfigurer.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.soap.MTOMFeature;
-
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
-
-/**
- * A CXF configurer that sets the serviceref data in the JaxWsProxyFactoryBean
- *
- * @author alessio.soldano(a)jboss.com
- * @since 21-Jul-2009
- */
-public class ServiceRefStubPropertyConfigurer implements Configurer
-{
- private UnifiedServiceRefMetaData serviceRefMD;
- private Configurer delegate;
-
- public ServiceRefStubPropertyConfigurer(UnifiedServiceRefMetaData serviceRefMD, Configurer delegate)
- {
- this.serviceRefMD = serviceRefMD;
- this.delegate = delegate;
- }
-
- public void configureBean(Object beanInstance)
- {
- if (delegate != null)
- {
- delegate.configureBean(beanInstance);
- }
- }
-
- public void configureBean(String name, Object beanInstance)
- {
- if (name != null && beanInstance instanceof JaxWsProxyFactoryBean)
- {
- QName portQName = null;
- try
- {
- String portName = name.substring(0, name.indexOf(".jaxws-client.proxyFactory"));
- portQName = QName.valueOf(portName);
- }
- catch (Exception e)
- {
- Logger.getLogger(this.getClass()).warn("Unable to retrieve port QName from '" + name + "', trying matching port using endpoint interface name only.");
- }
- configureJaxWsProxyFactoryBean(portQName, (JaxWsProxyFactoryBean)beanInstance);
- }
- if (delegate != null)
- {
- delegate.configureBean(name, beanInstance);
- }
- }
-
- private synchronized void configureJaxWsProxyFactoryBean(QName portQName, JaxWsProxyFactoryBean proxyFactory)
- {
- Class<?> clazz = proxyFactory.getServiceClass();
- UnifiedPortComponentRefMetaData upcmd = serviceRefMD.getPortComponentRef(clazz != null ? clazz.getName() : null, portQName);
- if (upcmd != null)
- {
- setProperties(proxyFactory, upcmd);
- setMTOM((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
- }
- }
-
- private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
- {
- if (upcmd.getEnableMTOM())
- {
- List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
- List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
- if (prevFeatures != null)
- {
- features.addAll(prevFeatures);
- }
- features.add(new MTOMFeature(true));
- serviceFactoryBean.setWsFeatures(features);
- }
- }
-
- private void setProperties(JaxWsProxyFactoryBean proxyFactory, UnifiedPortComponentRefMetaData upcmd)
- {
- Map<String, Object> properties = proxyFactory.getProperties();
- if (properties == null)
- {
- properties = new HashMap<String, Object>();
- proxyFactory.setProperties(properties);
- }
- for (UnifiedStubPropertyMetaData prop : upcmd.getStubProperties())
- {
- properties.put(prop.getPropName(), prop.getPropValue());
- }
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.*;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
-
-/**
- * A JNDI reference to a javax.xml.ws.Service
- *
- * It holds the information to reconstrut the javax.xml.ws.Service
- * when the client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 06-Dec-2007
- */
-public class ServiceReferenceable implements Referenceable
-{
- public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
- public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
- public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
-
- private String serviceImplClass;
- private String targetClassName;
- private UnifiedServiceRefMetaData serviceRef;
-
- public ServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
- {
- this.serviceImplClass = serviceImplClass;
- this.targetClassName = targetClassName;
- this.serviceRef = serviceRef;
- }
-
- /**
- * Retrieves the Reference of this object.
- *
- * @return The non-null Reference of this object.
- * @throws javax.naming.NamingException If a naming exception was encountered while retrieving the reference.
- */
- public Reference getReference() throws NamingException
- {
- Reference myRef = new Reference(ServiceReferenceable.class.getName(), ServiceObjectFactory.class.getName(), null);
-
- myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
- myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
- myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
-
- return myRef;
- }
-
- private byte[] marshall(Object obj) throws NamingException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
- try
- {
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- }
- catch (IOException e)
- {
- throw new NamingException("Cannot marshall object, cause: " + e.toString());
- }
- return baos.toByteArray();
- }
-
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("\n").append(getClass().getName());
- sb.append("\n serviceImplClass=" + serviceImplClass);
- sb.append("\n targetClassName=" + targetClassName);
- sb.append("\n serviceRef=" + this.serviceRef);
- return sb.toString();
- }
-}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderFactoryImpl.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
+
+/**
+ * Binds a JAXWS Service object in the client's ENC
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CXFServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
+{
+ private static final ServiceRefBinder JAXRPC_BINDER = new CXFServiceRefBinderJAXRPC();
+
+ private static final ServiceRefBinder JAXWS_BINDER = new CXFServiceRefBinderJAXWS();
+
+ public ServiceRefBinder newServiceRefBinder(final Type type)
+ {
+ return type == Type.JAXRPC ? JAXRPC_BINDER : JAXWS_BINDER;
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXRPC.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXRPC;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Binds a JAXRPC Service object to the client's ENC.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+final class CXFServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
+{
+ @Override
+ protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ throw new IllegalArgumentException("CXF does not support JAX-RPC");
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/CXFServiceRefBinderJAXWS.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXWS;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Binds a JAXWS Service object to the client's ENC.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+final class CXFServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
+{
+ @Override
+ protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceObjectFactory.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,487 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.stack.cxf.client.HandlerResolverImpl;
+import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
+
+/**
+ * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
+ * for a given WSDL when the webservice client does a JNDI lookup.
+ *
+ * @see ServiceReferenceable
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @author Richard.Opalka(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
+ */
+public class ServiceObjectFactory implements ObjectFactory
+{
+ protected final Logger log = Logger.getLogger(ServiceObjectFactory.class);
+
+ /**
+ * Creates an object using the location or reference information specified.
+ * <p/>
+ *
+ * @param obj The possibly null object containing location or reference
+ * information that can be used in creating an object.
+ * @param name The name of this object relative to <code>nameCtx</code>,
+ * or null if no name is specified.
+ * @param nameCtx The context relative to which the <code>name</code>
+ * parameter is specified, or null if <code>name</code> is
+ * relative to the default initial context.
+ * @param environment The possibly null environment that is used in
+ * creating the object.
+ * @return The object created; null if an object cannot be created.
+ * @throws Exception if this object factory encountered an exception
+ * while attempting to create an object, and no other object factories are
+ * to be tried.
+ * @see javax.naming.spi.NamingManager#getObjectInstance
+ * @see javax.naming.spi.NamingManager#getURLContext
+ */
+ @SuppressWarnings(value = "unchecked")
+ public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable environment)
+ throws Exception
+ {
+ try
+ {
+ // references
+ final Reference ref = (Reference) obj;
+ final UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ // class names
+ final String serviceImplClass = this.getServiceClassName(ref, serviceRef);
+ final String targetClassName = this.getTargetClassName(ref, serviceRef, serviceImplClass);
+ // class instances
+ final Class<?> serviceClass = this.getClass(serviceImplClass);
+ final Class<?> targetClass = this.getClass(targetClassName);
+ // clean thread local bus before constructing Service
+ BusFactory.setThreadDefaultBus(null);
+ try
+ {
+ // construct service
+ final Bus bus = this.createNewBus(serviceRef);
+ final Service serviceInstance = this.instantiateService(serviceRef, serviceClass);
+ if (serviceRef.getHandlerChain() != null)
+ {
+ serviceInstance.setHandlerResolver(new HandlerResolverImpl(bus, serviceRef.getHandlerChain(),
+ serviceInstance.getClass()));
+ }
+ // construct port
+ final boolean instantiatePort = targetClassName != null && !targetClassName.equals(serviceImplClass);
+ if (instantiatePort)
+ {
+ final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
+ final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
+
+ return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures);
+ }
+
+ return serviceInstance;
+ }
+ finally
+ {
+ BusFactory.setThreadDefaultBus(null);
+ }
+ }
+ catch (Exception ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ }
+
+ return null;
+ }
+
+ private Class<?> getClass(final String className) throws ClassNotFoundException
+ {
+ if (className != null)
+ {
+ return Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+
+ return null;
+ }
+
+ private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ final Bus bus;
+ final URL cxfConfig = this.getCXFConfiguration(serviceRefMD.getVfsRoot());
+ if (cxfConfig != null)
+ {
+ final SpringBusFactory busFactory = new JBossWSSpringBusFactory();
+ bus = busFactory.createBus(cxfConfig);
+ BusFactory.setThreadDefaultBus(bus);
+ }
+ else
+ {
+ Bus threadBus = BusFactory.getThreadDefaultBus(false);
+ bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
+ }
+
+ //Add extension to configure stub properties using the UnifiedServiceRefMetaData
+ Configurer configurer = bus.getExtension(Configurer.class);
+ bus.setExtension(new ServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
+
+ return bus;
+ }
+
+ private String getServiceClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ String serviceClassName = serviceRefMD.getServiceImplClass();
+ if (serviceClassName == null)
+ serviceClassName = (String) ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
+
+ return serviceClassName;
+ }
+
+ private String getTargetClassName(final Reference ref, final UnifiedServiceRefMetaData serviceRefMD,
+ final String serviceImplClass)
+ {
+ String targetClassName = serviceRefMD.getServiceRefType();
+ if (targetClassName == null)
+ targetClassName = (String) ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();
+
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ return targetClassName;
+ }
+
+ private Object instantiatePort(final Class<?> serviceClass, final Class<?> targetClass, final Service target,
+ final QName portQName, final WebServiceFeature[] features) throws NoSuchMethodException,
+ InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ Object retVal = null;
+
+ Object port = null;
+ if (serviceClass != Service.class)
+ {
+ for (Method method : serviceClass.getDeclaredMethods())
+ {
+ String methodName = method.getName();
+ Class<?> retType = method.getReturnType();
+ if (methodName.startsWith("get") && targetClass.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ retVal = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = getMethodFor(portQName, features, serviceClass);
+ Object[] args = getArgumentsFor(portQName, features, targetClass);
+ port = method.invoke(target, args);
+ retVal = port;
+ }
+
+ return retVal;
+ }
+
+ private Service instantiateService(final UnifiedServiceRefMetaData serviceRefMD, final Class<?> serviceClass)
+ throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
+ {
+ final WebServiceFeature[] features = getFeatures(serviceRefMD);
+ final URL wsdlURL = serviceRefMD.getWsdlLocation();
+ final QName serviceQName = serviceRefMD.getServiceQName();
+
+ Service target = null;
+ if (serviceClass == Service.class)
+ {
+ // Generic javax.xml.ws.Service
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ target = Service.create(wsdlURL, serviceQName, features);
+ }
+ else
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic javax.xml.ws.Service without wsdlLocation: "
+ + serviceRefMD);
+ }
+ }
+ else
+ {
+ // Generated javax.xml.ws.Service subclass
+ if (wsdlURL != null)
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class, WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName, features});
+ }
+ else
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {URL.class, QName.class});
+ target = (Service) ctor.newInstance(new Object[]
+ {wsdlURL, serviceQName});
+ }
+ }
+ else
+ {
+ if (features != null)
+ {
+ Constructor<?> ctor = serviceClass.getConstructor(new Class[]
+ {WebServiceFeature[].class});
+ target = (Service) ctor.newInstance(new Object[]
+ {features});
+ }
+ else
+ {
+ target = (Service) serviceClass.newInstance();
+ }
+ }
+ }
+
+ return target;
+ }
+
+ private WebServiceFeature[] getFeatures(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return getFeatures(portComponentRefMD);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private QName getPortQName(final String targetClassName, final String serviceClassName,
+ final UnifiedServiceRefMetaData serviceRefMD)
+ {
+ if (targetClassName != null && !targetClassName.equals(serviceClassName))
+ {
+ final Collection<UnifiedPortComponentRefMetaData> portComponentRefs = serviceRefMD.getPortComponentRefs();
+ for (final UnifiedPortComponentRefMetaData portComponentRefMD : portComponentRefs)
+ {
+ if (targetClassName.equals(portComponentRefMD.getServiceEndpointInterface()))
+ {
+ return portComponentRefMD.getPortQName();
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private Method getMethodFor(final QName portQName, final WebServiceFeature[] features, final Class<?> serviceClass)
+ throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class});
+ if ((portQName != null) && (features == null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class});
+ if ((portQName == null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {Class.class, WebServiceFeature[].class});
+ if ((portQName != null) && (features != null))
+ return serviceClass.getMethod("getPort", new Class[]
+ {QName.class, Class.class, WebServiceFeature[].class});
+
+ throw new IllegalStateException();
+ }
+
+ private Object[] getArgumentsFor(final QName portQName, final WebServiceFeature[] features,
+ final Class<?> targetClass) throws NoSuchMethodException
+ {
+ if ((portQName == null) && (features == null))
+ return new Object[]
+ {targetClass};
+ if ((portQName != null) && (features == null))
+ return new Object[]
+ {portQName, targetClass};
+ if ((portQName == null) && (features != null))
+ return new Object[]
+ {targetClass, features};
+ if ((portQName != null) && (features != null))
+ return new Object[]
+ {portQName, targetClass, features};
+
+ throw new IllegalStateException();
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedServiceRefMetaData serviceRef)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+
+ // configure @Addressing feature
+ if (serviceRef.isAddressingEnabled())
+ {
+ final boolean required = serviceRef.isAddressingRequired();
+ final String refResponses = serviceRef.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (serviceRef.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (serviceRef.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ return wsFeatures;
+ }
+
+ private WebServiceFeature[] getFeatures(final UnifiedPortComponentRefMetaData portComponentRefMD)
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ // configure @Addressing feature
+ if (portComponentRefMD.isAddressingEnabled())
+ {
+ final boolean required = portComponentRefMD.isAddressingRequired();
+ final String refResponses = portComponentRefMD.getAddressingResponses();
+ AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+ if ("ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.ANONYMOUS;
+ if ("NON_ANONYMOUS".equals(refResponses))
+ responses = AddressingFeature.Responses.NON_ANONYMOUS;
+
+ features.add(new AddressingFeature(true, required, responses));
+ }
+
+ // configure @MTOM feature
+ if (portComponentRefMD.isMtomEnabled())
+ {
+ features.add(new MTOMFeature(true, portComponentRefMD.getMtomThreshold()));
+ }
+
+ // configure @RespectBinding feature
+ if (portComponentRefMD.isRespectBindingEnabled())
+ {
+ features.add(new RespectBindingFeature(true));
+ }
+
+ return features.size() == 0 ? null : features.toArray(new WebServiceFeature[]
+ {});
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(final Reference ref) throws ClassNotFoundException,
+ NamingException
+ {
+ final UnifiedServiceRefMetaData sref;
+ final RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
+ final ByteArrayInputStream bais = new ByteArrayInputStream((byte[]) refAddr.getContent());
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ sref = (UnifiedServiceRefMetaData) ois.readObject();
+ ois.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot unmarshall service ref meta data, cause: " + e.toString());
+ }
+
+ return sref;
+ }
+
+ private URL getCXFConfiguration(final UnifiedVirtualFile vfsRoot)
+ {
+ URL url = null;
+ try
+ {
+ url = vfsRoot.findChild("WEB-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e)
+ {
+ }
+
+ if (url == null)
+ {
+ try
+ {
+ url = vfsRoot.findChild("META-INF/jbossws-cxf.xml").toURL();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ return url;
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceRefStubPropertyConfigurer.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.MTOMFeature;
+
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedStubPropertyMetaData;
+
+/**
+ * A CXF configurer that sets the serviceref data in the JaxWsProxyFactoryBean
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 21-Jul-2009
+ */
+public class ServiceRefStubPropertyConfigurer implements Configurer
+{
+ private UnifiedServiceRefMetaData serviceRefMD;
+ private Configurer delegate;
+
+ public ServiceRefStubPropertyConfigurer(UnifiedServiceRefMetaData serviceRefMD, Configurer delegate)
+ {
+ this.serviceRefMD = serviceRefMD;
+ this.delegate = delegate;
+ }
+
+ public void configureBean(Object beanInstance)
+ {
+ if (delegate != null)
+ {
+ delegate.configureBean(beanInstance);
+ }
+ }
+
+ public void configureBean(String name, Object beanInstance)
+ {
+ if (name != null && beanInstance instanceof JaxWsProxyFactoryBean)
+ {
+ QName portQName = null;
+ try
+ {
+ String portName = name.substring(0, name.indexOf(".jaxws-client.proxyFactory"));
+ portQName = QName.valueOf(portName);
+ }
+ catch (Exception e)
+ {
+ Logger.getLogger(this.getClass()).warn("Unable to retrieve port QName from '" + name + "', trying matching port using endpoint interface name only.");
+ }
+ configureJaxWsProxyFactoryBean(portQName, (JaxWsProxyFactoryBean)beanInstance);
+ }
+ if (delegate != null)
+ {
+ delegate.configureBean(name, beanInstance);
+ }
+ }
+
+ private synchronized void configureJaxWsProxyFactoryBean(QName portQName, JaxWsProxyFactoryBean proxyFactory)
+ {
+ Class<?> clazz = proxyFactory.getServiceClass();
+ UnifiedPortComponentRefMetaData upcmd = serviceRefMD.getPortComponentRef(clazz != null ? clazz.getName() : null, portQName);
+ if (upcmd != null)
+ {
+ setProperties(proxyFactory, upcmd);
+ setMTOM((JaxWsServiceFactoryBean)proxyFactory.getServiceFactory(), upcmd);
+ }
+ }
+
+ private void setMTOM(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd)
+ {
+ if (upcmd.getEnableMTOM())
+ {
+ List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
+ List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
+ if (prevFeatures != null)
+ {
+ features.addAll(prevFeatures);
+ }
+ features.add(new MTOMFeature(true));
+ serviceFactoryBean.setWsFeatures(features);
+ }
+ }
+
+ private void setProperties(JaxWsProxyFactoryBean proxyFactory, UnifiedPortComponentRefMetaData upcmd)
+ {
+ Map<String, Object> properties = proxyFactory.getProperties();
+ if (properties == null)
+ {
+ properties = new HashMap<String, Object>();
+ proxyFactory.setProperties(properties);
+ }
+ for (UnifiedStubPropertyMetaData prop : upcmd.getStubProperties())
+ {
+ properties.put(prop.getPropName(), prop.getPropValue());
+ }
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/serviceref/ServiceReferenceable.java 2010-10-15 11:19:31 UTC (rev 13135)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client.serviceref;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+import javax.naming.*;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+
+/**
+ * A JNDI reference to a javax.xml.ws.Service
+ *
+ * It holds the information to reconstrut the javax.xml.ws.Service
+ * when the client does a JNDI lookup.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 06-Dec-2007
+ */
+public class ServiceReferenceable implements Referenceable
+{
+ public static final String SERVICE_REF_META_DATA = "SERVICE_REF_META_DATA";
+ public static final String SERVICE_IMPL_CLASS = "SERVICE_CLASS_NAME";
+ public static final String TARGET_CLASS_NAME = "TARGET_CLASS_NAME";
+
+ private String serviceImplClass;
+ private String targetClassName;
+ private UnifiedServiceRefMetaData serviceRef;
+
+ public ServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
+ {
+ this.serviceImplClass = serviceImplClass;
+ this.targetClassName = targetClassName;
+ this.serviceRef = serviceRef;
+ }
+
+ /**
+ * Retrieves the Reference of this object.
+ *
+ * @return The non-null Reference of this object.
+ * @throws javax.naming.NamingException If a naming exception was encountered while retrieving the reference.
+ */
+ public Reference getReference() throws NamingException
+ {
+ Reference myRef = new Reference(ServiceReferenceable.class.getName(), ServiceObjectFactory.class.getName(), null);
+
+ myRef.add(new StringRefAddr(SERVICE_IMPL_CLASS, serviceImplClass));
+ myRef.add(new StringRefAddr(TARGET_CLASS_NAME, targetClassName));
+ myRef.add(new BinaryRefAddr(SERVICE_REF_META_DATA, marshall(serviceRef)));
+
+ return myRef;
+ }
+
+ private byte[] marshall(Object obj) throws NamingException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
+ try
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.close();
+ }
+ catch (IOException e)
+ {
+ throw new NamingException("Cannot marshall object, cause: " + e.toString());
+ }
+ return baos.toByteArray();
+ }
+
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("\n").append(getClass().getName());
+ sb.append("\n serviceImplClass=" + serviceImplClass);
+ sb.append("\n targetClassName=" + targetClassName);
+ sb.append("\n serviceRef=" + this.serviceRef);
+ return sb.toString();
+ }
+}
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
===================================================================
--- stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory 2010-10-15 10:37:52 UTC (rev 13134)
+++ stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-server.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory 2010-10-15 11:19:31 UTC (rev 13135)
@@ -1 +1 @@
-org.jboss.wsf.stack.cxf.client.ServiceRefBinderFactoryImpl
\ No newline at end of file
+org.jboss.wsf.stack.cxf.client.serviceref.CXFServiceRefBinderFactoryImpl
\ No newline at end of file
14 years, 2 months
JBossWS SVN: r13134 - in stack/native/trunk/modules: services/src/main/resources/META-INF/services and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 06:37:52 -0400 (Fri, 15 Oct 2010)
New Revision: 13134
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java
Removed:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java
Modified:
stack/native/trunk/modules/services/src/main/resources/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
Log:
refactoring - optimization
Added: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java (rev 0)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/NativeServiceRefBinderFactoryImpl.java 2010-10-15 10:37:52 UTC (rev 13134)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ws.core.client;
+
+import org.jboss.ws.core.jaxrpc.client.NativeServiceRefBinderJAXRPC;
+import org.jboss.ws.core.jaxws.client.NativeServiceRefBinderJAXWS;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
+
+/**
+ * Binds a JAXWS Service object in the client's ENC
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class NativeServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
+{
+ private static final ServiceRefBinder JAXRPC_BINDER = new NativeServiceRefBinderJAXRPC();
+
+ private static final ServiceRefBinder JAXWS_BINDER = new NativeServiceRefBinderJAXWS();
+
+ public ServiceRefBinder newServiceRefBinder(final Type type)
+ {
+ return type == Type.JAXRPC ? JAXRPC_BINDER : JAXWS_BINDER;
+ }
+}
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java 2010-10-15 10:12:05 UTC (rev 13133)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java 2010-10-15 10:37:52 UTC (rev 13134)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ws.core.client;
-
-import org.jboss.ws.core.jaxrpc.client.NativeServiceRefBinderJAXRPC;
-import org.jboss.ws.core.jaxws.client.NativeServiceRefBinderJAXWS;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler.Type;
-
-/**
- * Binds a JAXWS Service object in the client's ENC
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 17-Jan-2007
- */
-public class ServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
-{
- public ServiceRefBinder newServiceRefBinder(Type type)
- {
- return (type == Type.JAXRPC ? new NativeServiceRefBinderJAXRPC() : new NativeServiceRefBinderJAXWS());
- }
-}
Modified: stack/native/trunk/modules/services/src/main/resources/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
===================================================================
--- stack/native/trunk/modules/services/src/main/resources/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory 2010-10-15 10:12:05 UTC (rev 13133)
+++ stack/native/trunk/modules/services/src/main/resources/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory 2010-10-15 10:37:52 UTC (rev 13134)
@@ -1 +1 @@
-org.jboss.ws.core.client.ServiceRefBinderFactoryImpl
\ No newline at end of file
+org.jboss.ws.core.client.NativeServiceRefBinderFactoryImpl
\ No newline at end of file
14 years, 2 months
JBossWS SVN: r13133 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 06:12:05 -0400 (Fri, 15 Oct 2010)
New Revision: 13133
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java
Removed:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
Log:
refactoring
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXRPC.java 2010-10-15 10:12:05 UTC (rev 13133)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXRPC;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Binds a JAXRPC Service object to the client's ENC.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CXFServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
+{
+ @Override
+ protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ throw new IllegalArgumentException("CXF does not support JAX-RPC");
+ }
+}
Added: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java (rev 0)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/CXFServiceRefBinderJAXWS.java 2010-10-15 10:12:05 UTC (rev 13133)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.client;
+
+import javax.naming.Referenceable;
+
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXWS;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Binds a JAXWS Service object to the client's ENC.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public final class CXFServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
+{
+ @Override
+ protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRefUMDM)
+ {
+ return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
+ }
+}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java 2010-10-15 10:10:02 UTC (rev 13132)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java 2010-10-15 10:12:05 UTC (rev 13133)
@@ -35,6 +35,6 @@
{
public ServiceRefBinder newServiceRefBinder(Type type)
{
- return (type == Type.JAXRPC ? new ServiceRefBinderJAXRPC() : new ServiceRefBinderJAXWS());
+ return (type == Type.JAXRPC ? new CXFServiceRefBinderJAXRPC() : new CXFServiceRefBinderJAXWS());
}
}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java 2010-10-15 10:10:02 UTC (rev 13132)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java 2010-10-15 10:12:05 UTC (rev 13133)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
-
-/**
- * @author Thomas.Diesler(a)jboss.com
- * @since 06-Dec-2007
- */
-public class ServiceRefBinderJAXRPC implements ServiceRefBinder
-{
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
- {
- throw new IllegalArgumentException("Deployed stack does not support JAX-RPC service-ref deployments");
- }
-}
Deleted: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2010-10-15 10:10:02 UTC (rev 13132)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2010-10-15 10:12:05 UTC (rev 13133)
@@ -1,267 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.wsf.stack.cxf.client;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jws.HandlerChain;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.Referenceable;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBinding;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceClient;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-import javax.xml.ws.soap.Addressing;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOM;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.spi.WSFException;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
-
-/**
- * @author Thomas.Diesler(a)jboss.com
- * @since 06-Dec-2007
- */
-public class ServiceRefBinderJAXWS implements ServiceRefBinder
-{
- // logging support
- private static Logger log = Logger.getLogger(ServiceRefBinderJAXWS.class);
-
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
- throws NamingException
- {
- WebServiceRef wsref = null;
-
- if (null == loader)
- throw new IllegalArgumentException("There needs to be a classloader available");
-
- // Build the list of @WebServiceRef relevant annotations
- List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- Addressing addressingAnnotation = null;
- MTOM mtomAnnotation = null;
- RespectBinding respectBindingAnnotation = null;
-
- AnnotatedElement anElement = (AnnotatedElement)serviceRef.getAnnotatedElement();
- if (anElement != null)
- {
- for (Annotation an : anElement.getAnnotations())
- {
- if (an instanceof Addressing) {
- addressingAnnotation = (Addressing)an;
- continue;
- }
-
- if (an instanceof MTOM) {
- mtomAnnotation = (MTOM)an;
- continue;
- }
-
- if (an instanceof RespectBinding) {
- respectBindingAnnotation = (RespectBinding)an;
- continue;
- }
-
- if (an instanceof WebServiceRef) {
- wsrefList.add((WebServiceRef)an);
- continue;
- }
-
- if (an instanceof WebServiceRefs)
- {
- WebServiceRefs wsrefs = (WebServiceRefs)an;
- for (WebServiceRef aux : wsrefs.value())
- wsrefList.add(aux);
- }
- }
- }
-
- // Use the single @WebServiceRef
- if (wsrefList.size() == 1)
- {
- wsref = wsrefList.get(0);
- }
- else
- {
- for (WebServiceRef aux : wsrefList)
- {
- if (encName.endsWith("/" + aux.name()))
- {
- wsref = aux;
- break;
- }
- }
- }
-
- Class targetClass = null;
- if (anElement instanceof Field)
- {
- targetClass = ((Field)anElement).getType();
- }
- else if (anElement instanceof Method)
- {
- targetClass = ((Method)anElement).getParameterTypes()[0];
- }
- else
- {
- if (wsref != null && (wsref.type() != Object.class))
- targetClass = wsref.type();
- }
-
- String targetClassName = (targetClass != null ? targetClass.getName() : null);
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.debug("setupServiceRef [jndi=" + externalName + ",target=" + targetClassName + "]");
-
- String serviceImplClass = null;
-
- // #1 Use the explicit @WebServiceRef.value
- if (wsref != null && wsref.value() != Service.class)
- serviceImplClass = wsref.value().getName();
-
- // #2 Use the target ref type
- if (serviceImplClass == null && targetClass != null && Service.class.isAssignableFrom(targetClass))
- serviceImplClass = targetClass.getName();
-
- // #3 Use <service-interface>
- if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
- serviceImplClass = serviceRef.getServiceInterface();
-
- // #4 Use javax.xml.ws.Service
- if (serviceImplClass == null)
- serviceImplClass = Service.class.getName();
-
- // #1 Use the explicit @WebServiceRef.type
- if (wsref != null && wsref.type() != Object.class)
- targetClassName = wsref.type().getName();
-
- // #2 Use the target ref type
- if (targetClassName == null && targetClass != null && Service.class.isAssignableFrom(targetClass) == false)
- targetClassName = targetClass.getName();
-
- // Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && wsref != null && wsref.wsdlLocation().length() > 0)
- serviceRef.setWsdlOverride(wsref.wsdlLocation());
-
- // Set the handlerChain from @HandlerChain on the annotated element
- String handlerChain = serviceRef.getHandlerChain();
- if (anElement != null)
- {
- HandlerChain anHandlerChain = anElement.getAnnotation(HandlerChain.class);
- if (handlerChain == null && anHandlerChain != null && anHandlerChain.file().length() > 0)
- handlerChain = anHandlerChain.file();
- }
-
- // Resolve path to handler chain
- if (handlerChain != null)
- {
- try
- {
- new URL(handlerChain);
- }
- catch (MalformedURLException ex)
- {
- Class declaringClass = null;
- if (anElement instanceof Field)
- declaringClass = ((Field)anElement).getDeclaringClass();
- else if (anElement instanceof Method)
- declaringClass = ((Method)anElement).getDeclaringClass();
- else if (anElement instanceof Class)
- declaringClass = (Class)anElement;
-
- handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
- }
-
- serviceRef.setHandlerChain(handlerChain);
- }
-
- // Extract service QName for target service
- if (null == serviceRef.getServiceQName())
- {
- try
- {
- Class<?> serviceClass = loader.loadClass(serviceImplClass);
- if (serviceClass.getAnnotation(WebServiceClient.class) != null)
- {
- WebServiceClient clientDecl = (WebServiceClient)serviceClass.getAnnotation(WebServiceClient.class);
- serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
- //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
- if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
- {
- serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- WSFException.rethrow("Cannot extract service QName for target service", e);
- }
- }
-
- if (addressingAnnotation != null)
- {
- serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
- serviceRef.setAddressingRequired(addressingAnnotation.required());
- serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
- }
-
- if (mtomAnnotation != null) {
- serviceRef.setMtomEnabled(mtomAnnotation.enabled());
- serviceRef.setMtomThreshold(mtomAnnotation.threshold());
- }
-
- if (respectBindingAnnotation != null) {
- serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
- }
-
- // Do not use rebind, the binding should be unique
- // [JBWS-1499] - Revisit WebServiceRefHandler JNDI rebind
- Referenceable serviceReferenceable = buildServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
- Util.bind(encCtx, encName, serviceReferenceable);
-
- }
-
- /**
- * Create a Apache-CXF specific service referenceable.
- * Most of the setup is done in {@link org.jboss.wsf.framework.serviceref.ServiceRefBinderJAXWS}
- *
- * @param serviceImplClass
- * @param targetClassName
- * @param serviceRef
- * @return a Apache-CXF specific service referenceable.
- */
- protected Referenceable buildServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
- {
- return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
- }
-}
14 years, 2 months
JBossWS SVN: r13132 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core: jaxws/client and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 06:10:02 -0400 (Fri, 15 Oct 2010)
New Revision: 13132
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
Log:
refactoring
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-15 10:07:46 UTC (rev 13131)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-15 10:10:02 UTC (rev 13132)
@@ -21,39 +21,22 @@
*/
package org.jboss.ws.core.jaxrpc.client;
-import java.lang.reflect.AnnotatedElement;
+import javax.naming.Referenceable;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXRPC;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
- * deployment descriptor.
+ * Binds a JAXRPC Service object to the client's ENC.
*
* @author Thomas.Diesler(a)jboss.org
- * @since 04-Nov-2006
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public class NativeServiceRefBinderJAXRPC implements ServiceRefBinder
+public final class NativeServiceRefBinderJAXRPC extends AbstractServiceRefBinderJAXRPC
{
- // logging support
- private static Logger log = Logger.getLogger(NativeServiceRefBinderJAXRPC.class);
-
- /**
- * Binds a Service into the callers ENC for every service-ref element
- */
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
- throws NamingException
+ @Override
+ protected Referenceable createReferenceable(final UnifiedServiceRefMetaData serviceRefUMDM)
{
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- log.info("setupServiceRef [jndi=" + externalName + "]");
-
- // Do not use rebind, the binding should be unique
- ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
- Util.bind(encCtx, encName, ref);
+ return new ServiceReferenceable(serviceRefUMDM);
}
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 10:07:46 UTC (rev 13131)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 10:10:02 UTC (rev 13132)
@@ -21,240 +21,23 @@
*/
package org.jboss.ws.core.jaxws.client;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jws.HandlerChain;
-import javax.naming.Context;
-import javax.naming.NamingException;
import javax.naming.Referenceable;
-import javax.xml.namespace.QName;
-import javax.xml.ws.RespectBinding;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceClient;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-import javax.xml.ws.soap.Addressing;
-import javax.xml.ws.soap.AddressingFeature;
-import javax.xml.ws.soap.MTOM;
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.common.serviceref.AbstractServiceRefBinderJAXWS;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
/**
- * Binds a JAXWS Service object in the client's ENC
+ * Binds a JAXWS Service object to the client's ENC.
*
* @author Thomas.Diesler(a)jboss.org
- * @since 17-Jan-2007
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
*/
-public class NativeServiceRefBinderJAXWS implements ServiceRefBinder
+public final class NativeServiceRefBinderJAXWS extends AbstractServiceRefBinderJAXWS
{
- // logging support
- private static Logger log = Logger.getLogger(NativeServiceRefBinderJAXWS.class);
-
- public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ @Override
+ protected Referenceable createReferenceable(final String serviceImplClass, final String targetClassName,
+ final UnifiedServiceRefMetaData serviceRefUMDM)
{
- WebServiceRef wsref = null;
-
- if (null == loader)
- throw new IllegalArgumentException("There needs to be a classloader available");
-
- // Build the list of @WebServiceRef relevant annotations
- List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- Addressing addressingAnnotation = null;
- MTOM mtomAnnotation = null;
- RespectBinding respectBindingAnnotation = null;
-
- AnnotatedElement anElement = (AnnotatedElement)serviceRef.getAnnotatedElement();
- if (anElement != null)
- {
- for (Annotation an : anElement.getAnnotations())
- {
- if (an instanceof Addressing) {
- addressingAnnotation = (Addressing)an;
- continue;
- }
-
- if (an instanceof MTOM) {
- mtomAnnotation = (MTOM)an;
- continue;
- }
-
- if (an instanceof RespectBinding) {
- respectBindingAnnotation = (RespectBinding)an;
- continue;
- }
-
- if (an instanceof WebServiceRef) {
- wsrefList.add((WebServiceRef)an);
- continue;
- }
-
- if (an instanceof WebServiceRefs)
- {
- WebServiceRefs wsrefs = (WebServiceRefs)an;
- for (WebServiceRef aux : wsrefs.value())
- wsrefList.add(aux);
- }
- }
- }
-
- // Use the single @WebServiceRef
- if (wsrefList.size() == 1)
- {
- wsref = wsrefList.get(0);
- }
- else
- {
- for (WebServiceRef aux : wsrefList)
- {
- if (encName.endsWith("/" + aux.name()))
- {
- wsref = aux;
- break;
- }
- }
- }
-
- Class targetClass = null;
- if (anElement instanceof Field)
- {
- targetClass = ((Field)anElement).getType();
- }
- else if (anElement instanceof Method)
- {
- targetClass = ((Method)anElement).getParameterTypes()[0];
- }
- else
- {
- if (wsref != null && (wsref.type() != Object.class))
- targetClass = wsref.type();
- }
-
- String targetClassName = (targetClass != null ? targetClass.getName() : null);
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- if (log.isDebugEnabled())
- log.debug("setupServiceRef [jndi=" + externalName + ",target=" + targetClassName + "]");
-
- String serviceImplClass = null;
-
- // #1 Use the explicit @WebServiceRef.value
- if (wsref != null && wsref.value() != Service.class)
- serviceImplClass = wsref.value().getName();
-
- // #2 Use the target ref type
- if (serviceImplClass == null && targetClass != null && Service.class.isAssignableFrom(targetClass))
- serviceImplClass = targetClass.getName();
-
- // #3 Use <service-interface>
- if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
- serviceImplClass = serviceRef.getServiceInterface();
-
- // #4 Use javax.xml.ws.Service
- if (serviceImplClass == null)
- serviceImplClass = Service.class.getName();
-
- // #1 Use the explicit @WebServiceRef.type
- if (wsref != null && wsref.type() != Object.class)
- targetClassName = wsref.type().getName();
-
- // #2 Use the target ref type
- if (targetClassName == null && targetClass != null && Service.class.isAssignableFrom(targetClass) == false)
- targetClassName = targetClass.getName();
-
- // Set the wsdlLocation if there is no override already
- if (serviceRef.getWsdlOverride() == null && wsref != null && wsref.wsdlLocation().length() > 0)
- serviceRef.setWsdlOverride(wsref.wsdlLocation());
-
- // Set the handlerChain from @HandlerChain on the annotated element
- String handlerChain = serviceRef.getHandlerChain();
- if (anElement != null)
- {
- HandlerChain anHandlerChain = anElement.getAnnotation(HandlerChain.class);
- if (handlerChain == null && anHandlerChain != null && anHandlerChain.file().length() > 0)
- handlerChain = anHandlerChain.file();
- }
-
- // Resolve path to handler chain
- if (handlerChain != null)
- {
- try
- {
- new URL(handlerChain);
- }
- catch (MalformedURLException ex)
- {
- Class declaringClass = null;
- if (anElement instanceof Field)
- declaringClass = ((Field)anElement).getDeclaringClass();
- else if (anElement instanceof Method)
- declaringClass = ((Method)anElement).getDeclaringClass();
- else if (anElement instanceof Class)
- declaringClass = (Class)anElement;
-
- handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
- }
-
- serviceRef.setHandlerChain(handlerChain);
- }
-
- // Extract service QName for target service
- if (null == serviceRef.getServiceQName())
- {
- try
- {
- Class serviceClass = loader.loadClass(serviceImplClass);
- if (serviceClass.getAnnotation(WebServiceClient.class) != null)
- {
- WebServiceClient clientDecl = (WebServiceClient)serviceClass.getAnnotation(WebServiceClient.class);
- serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
- //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
- if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
- {
- serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
- }
- }
- }
- catch (ClassNotFoundException e)
- {
- WSFException.rethrow("Cannot extract service QName for target service", e);
- }
- }
-
- if (addressingAnnotation != null)
- {
- serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
- serviceRef.setAddressingRequired(addressingAnnotation.required());
- serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
- }
-
- if (mtomAnnotation != null) {
- serviceRef.setMtomEnabled(mtomAnnotation.enabled());
- serviceRef.setMtomThreshold(mtomAnnotation.threshold());
- }
-
- if (respectBindingAnnotation != null) {
- serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
- }
-
- // Do not use rebind, the binding should be unique
- // [JBWS-1499] - Revisit WebServiceRefHandler JNDI rebind
- Referenceable serviceReferenceable = buildServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
- Util.bind(encCtx, encName, serviceReferenceable);
-
+ return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRefUMDM);
}
-
- protected Referenceable buildServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
- {
- return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
- }
}
14 years, 2 months
JBossWS SVN: r13131 - in common/trunk: src/main/java/org/jboss/wsf/common and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 06:07:46 -0400 (Fri, 15 Oct 2010)
New Revision: 13131
Added:
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
Modified:
common/trunk/pom.xml
Log:
refactoring
Modified: common/trunk/pom.xml
===================================================================
--- common/trunk/pom.xml 2010-10-15 08:46:42 UTC (rev 13130)
+++ common/trunk/pom.xml 2010-10-15 10:07:46 UTC (rev 13131)
@@ -37,6 +37,7 @@
<junit.version>3.8.2</junit.version>
<wsdl4j.version>1.6.2</wsdl4j.version>
<jms.api.version>1.1</jms.api.version>
+ <jaxws.api.version>1.0.0.Beta1</jaxws.api.version>
</properties>
<!-- Dependencies -->
@@ -65,13 +66,12 @@
</dependency>
<!-- provided apis -->
+ <dependency>
+ <groupId>org.jboss.spec.javax.xml.ws</groupId>
+ <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+ <version>${jaxws.api.version}</version>
+ </dependency>
<dependency>
- <groupId>javax.xml.ws</groupId>
- <artifactId>jaxws-api</artifactId>
- <version>${jaxws.api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-ejb-api</artifactId>
<version>${jboss.ejb.api.version}</version>
@@ -120,6 +120,37 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <showDeprecation>false</showDeprecation>
+ <compilerArguments>
+ <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
+ </compilerArguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.spec.javax.xml.ws</groupId>
+ <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-8</version>
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXRPC.java 2010-10-15 10:07:46 UTC (rev 13131)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.serviceref;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Referenceable;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+
+/**
+ * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
+ * deployment descriptor.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public abstract class AbstractServiceRefBinderJAXRPC implements ServiceRefBinder
+{
+ // logging support
+ private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXRPC.class);
+
+ /**
+ * Binds a Service into the callers ENC for every service-ref element
+ */
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
+ UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ {
+ String externalName = encCtx.getNameInNamespace() + "/" + encName;
+ log.info("setupServiceRef [jndi=" + externalName + "]");
+
+ // Do not use rebind, the binding should be unique
+ Referenceable ref = this.createReferenceable(serviceRef);
+ Util.bind(encCtx, encName, ref);
+ }
+
+ protected abstract Referenceable createReferenceable(UnifiedServiceRefMetaData serviceRef);
+}
Added: common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/serviceref/AbstractServiceRefBinderJAXWS.java 2010-10-15 10:07:46 UTC (rev 13131)
@@ -0,0 +1,260 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.serviceref;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.Referenceable;
+import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBinding;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.MTOM;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+
+/**
+ * Binds a JAXWS Service object in the client's ENC.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public abstract class AbstractServiceRefBinderJAXWS implements ServiceRefBinder
+{
+ private static Logger log = Logger.getLogger(AbstractServiceRefBinderJAXWS.class);
+
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored,
+ UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ {
+ WebServiceRef wsref = null;
+
+ if (null == loader)
+ throw new IllegalArgumentException("There needs to be a classloader available");
+
+ // Build the list of @WebServiceRef relevant annotations
+ List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
+ Addressing addressingAnnotation = null;
+ MTOM mtomAnnotation = null;
+ RespectBinding respectBindingAnnotation = null;
+
+ AnnotatedElement anElement = (AnnotatedElement) serviceRef.getAnnotatedElement();
+ if (anElement != null)
+ {
+ for (Annotation an : anElement.getAnnotations())
+ {
+ if (an instanceof Addressing)
+ {
+ addressingAnnotation = (Addressing) an;
+ continue;
+ }
+
+ if (an instanceof MTOM)
+ {
+ mtomAnnotation = (MTOM) an;
+ continue;
+ }
+
+ if (an instanceof RespectBinding)
+ {
+ respectBindingAnnotation = (RespectBinding) an;
+ continue;
+ }
+
+ if (an instanceof WebServiceRef)
+ {
+ wsrefList.add((WebServiceRef) an);
+ continue;
+ }
+
+ if (an instanceof WebServiceRefs)
+ {
+ WebServiceRefs wsrefs = (WebServiceRefs) an;
+ for (WebServiceRef aux : wsrefs.value())
+ wsrefList.add(aux);
+ }
+ }
+ }
+
+ // Use the single @WebServiceRef
+ if (wsrefList.size() == 1)
+ {
+ wsref = wsrefList.get(0);
+ }
+ else
+ {
+ for (WebServiceRef aux : wsrefList)
+ {
+ if (encName.endsWith("/" + aux.name()))
+ {
+ wsref = aux;
+ break;
+ }
+ }
+ }
+
+ Class targetClass = null;
+ if (anElement instanceof Field)
+ {
+ targetClass = ((Field) anElement).getType();
+ }
+ else if (anElement instanceof Method)
+ {
+ targetClass = ((Method) anElement).getParameterTypes()[0];
+ }
+ else
+ {
+ if (wsref != null && (wsref.type() != Object.class))
+ targetClass = wsref.type();
+ }
+
+ String targetClassName = (targetClass != null ? targetClass.getName() : null);
+ String externalName = encCtx.getNameInNamespace() + "/" + encName;
+ if (log.isDebugEnabled())
+ log.debug("setupServiceRef [jndi=" + externalName + ",target=" + targetClassName + "]");
+
+ String serviceImplClass = null;
+
+ // #1 Use the explicit @WebServiceRef.value
+ if (wsref != null && wsref.value() != Service.class)
+ serviceImplClass = wsref.value().getName();
+
+ // #2 Use the target ref type
+ if (serviceImplClass == null && targetClass != null && Service.class.isAssignableFrom(targetClass))
+ serviceImplClass = targetClass.getName();
+
+ // #3 Use <service-interface>
+ if (serviceImplClass == null && serviceRef.getServiceInterface() != null)
+ serviceImplClass = serviceRef.getServiceInterface();
+
+ // #4 Use javax.xml.ws.Service
+ if (serviceImplClass == null)
+ serviceImplClass = Service.class.getName();
+
+ // #1 Use the explicit @WebServiceRef.type
+ if (wsref != null && wsref.type() != Object.class)
+ targetClassName = wsref.type().getName();
+
+ // #2 Use the target ref type
+ if (targetClassName == null && targetClass != null && Service.class.isAssignableFrom(targetClass) == false)
+ targetClassName = targetClass.getName();
+
+ // Set the wsdlLocation if there is no override already
+ if (serviceRef.getWsdlOverride() == null && wsref != null && wsref.wsdlLocation().length() > 0)
+ serviceRef.setWsdlOverride(wsref.wsdlLocation());
+
+ // Set the handlerChain from @HandlerChain on the annotated element
+ String handlerChain = serviceRef.getHandlerChain();
+ if (anElement != null)
+ {
+ HandlerChain anHandlerChain = anElement.getAnnotation(HandlerChain.class);
+ if (handlerChain == null && anHandlerChain != null && anHandlerChain.file().length() > 0)
+ handlerChain = anHandlerChain.file();
+ }
+
+ // Resolve path to handler chain
+ if (handlerChain != null)
+ {
+ try
+ {
+ new URL(handlerChain);
+ }
+ catch (MalformedURLException ex)
+ {
+ Class declaringClass = null;
+ if (anElement instanceof Field)
+ declaringClass = ((Field) anElement).getDeclaringClass();
+ else if (anElement instanceof Method)
+ declaringClass = ((Method) anElement).getDeclaringClass();
+ else if (anElement instanceof Class)
+ declaringClass = (Class) anElement;
+
+ handlerChain = declaringClass.getPackage().getName().replace('.', '/') + "/" + handlerChain;
+ }
+
+ serviceRef.setHandlerChain(handlerChain);
+ }
+
+ // Extract service QName for target service
+ if (null == serviceRef.getServiceQName())
+ {
+ try
+ {
+ Class serviceClass = loader.loadClass(serviceImplClass);
+ if (serviceClass.getAnnotation(WebServiceClient.class) != null)
+ {
+ WebServiceClient clientDecl = (WebServiceClient) serviceClass.getAnnotation(WebServiceClient.class);
+ serviceRef.setServiceQName(new QName(clientDecl.targetNamespace(), clientDecl.name()));
+ //use the @WebServiceClien(wsdlLocation=...) if the service ref wsdl location returned at this time would be null
+ if (clientDecl.wsdlLocation().length() > 0 && serviceRef.getWsdlLocation() == null)
+ {
+ serviceRef.setWsdlOverride(clientDecl.wsdlLocation());
+ }
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ WSFException.rethrow("Cannot extract service QName for target service", e);
+ }
+ }
+
+ if (addressingAnnotation != null)
+ {
+ serviceRef.setAddressingEnabled(addressingAnnotation.enabled());
+ serviceRef.setAddressingRequired(addressingAnnotation.required());
+ serviceRef.setAddressingResponses(addressingAnnotation.responses().toString());
+ }
+
+ if (mtomAnnotation != null)
+ {
+ serviceRef.setMtomEnabled(mtomAnnotation.enabled());
+ serviceRef.setMtomThreshold(mtomAnnotation.threshold());
+ }
+
+ if (respectBindingAnnotation != null)
+ {
+ serviceRef.setRespectBindingEnabled(respectBindingAnnotation.enabled());
+ }
+
+ Referenceable serviceReferenceable = this.createReferenceable(serviceImplClass, targetClassName, serviceRef);
+ Util.bind(encCtx, encName, serviceReferenceable);
+
+ }
+
+ protected abstract Referenceable createReferenceable(String serviceImplClass, String targetClassName,
+ UnifiedServiceRefMetaData serviceRef);
+}
14 years, 2 months
JBossWS SVN: r13130 - stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 04:46:42 -0400 (Fri, 15 Oct 2010)
New Revision: 13130
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
Log:
rollback - SPI have to be BC
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java 2010-10-15 08:46:00 UTC (rev 13129)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java 2010-10-15 08:46:42 UTC (rev 13130)
@@ -35,7 +35,7 @@
*/
public class ServiceRefBinderJAXRPC implements ServiceRefBinder
{
- public void setupServiceRef(Context encCtx, String encName, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
{
throw new IllegalArgumentException("Deployed stack does not support JAX-RPC service-ref deployments");
}
Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2010-10-15 08:46:00 UTC (rev 13129)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2010-10-15 08:46:42 UTC (rev 13130)
@@ -59,7 +59,7 @@
// logging support
private static Logger log = Logger.getLogger(ServiceRefBinderJAXWS.class);
- public void setupServiceRef(Context encCtx, String encName, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
throws NamingException
{
WebServiceRef wsref = null;
14 years, 2 months
JBossWS SVN: r13129 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core: jaxws/client and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2010-10-15 04:46:00 -0400 (Fri, 15 Oct 2010)
New Revision: 13129
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
Log:
rollback - SPI have to be BC
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-15 08:39:05 UTC (rev 13128)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java 2010-10-15 08:46:00 UTC (rev 13129)
@@ -46,7 +46,7 @@
/**
* Binds a Service into the callers ENC for every service-ref element
*/
- public void setupServiceRef(Context encCtx, String encName, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
throws NamingException
{
String externalName = encCtx.getNameInNamespace() + "/" + encName;
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 08:39:05 UTC (rev 13128)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java 2010-10-15 08:46:00 UTC (rev 13129)
@@ -61,7 +61,7 @@
// logging support
private static Logger log = Logger.getLogger(NativeServiceRefBinderJAXWS.class);
- public void setupServiceRef(Context encCtx, String encName, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement ignored, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
{
WebServiceRef wsref = null;
14 years, 2 months