[jbossws-commits] JBossWS SVN: r4053 - in trunk: integration/jboss40/src/main/resources and 16 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Aug 1 10:13:43 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-08-01 10:13:43 -0400 (Wed, 01 Aug 2007)
New Revision: 4053

Added:
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/serviceref/
   trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/serviceref/ServiceRefHandlerImpl.java
   trunk/integration/native/src/main/resources/jbossws-native.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
   trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinderFactory.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandlerFactory.java
   trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXRPC.java
   trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXWS.java
   trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderFactoryImpl.java
   trunk/integration/sunri/src/main/resources/jbossws-sunri.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
   trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java
   trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java
   trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
Removed:
   trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/CommonServiceRefBinder.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefBinder.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefHandlerFactory.java
   trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/DummyServiceRefBinderJAXRPC.java
   trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderJAXWS.java
   trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefBinderJAXRPC.java
   trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefBinderJAXWS.java
   trunk/jbossws-core/src/main/java/org/jboss/ws/integration/
Modified:
   trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/WebServiceClientDeployer.java
   trunk/integration/jboss40/src/main/resources/jbossws-jboss40-config.xml
   trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/serviceref/ServiceRefHandlerImpl.java
   trunk/integration/jboss42/src/main/resources/jbossws-jboss42-config.xml
   trunk/integration/native/src/main/resources/jbossws-native-config.xml
   trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
   trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java
   trunk/integration/sunri/src/main/resources/jbossws-sunri-config.xml
Log:
Add ServiceREfBinder to SPI

Modified: trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/WebServiceClientDeployer.java
===================================================================
--- trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/WebServiceClientDeployer.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/jboss40/src/main/java/org/jboss/wsf/container/jboss40/WebServiceClientDeployer.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -36,10 +36,13 @@
 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
 import org.jboss.wsf.framework.deployment.ResourceLoaderAdapter;
 import org.jboss.wsf.framework.deployment.URLLoaderAdapter;
-import org.jboss.wsf.framework.serviceref.ServiceRefHandlerFactory;
+import org.jboss.wsf.framework.serviceref.DefaultServiceRefHandlerFactory;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
 import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
 
 /**
  * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
@@ -72,7 +75,9 @@
             URLLoaderAdapter urlLoaderAdapter = new URLLoaderAdapter(getDeploymentURL(di));
             usr.setVfsRoot(urlLoaderAdapter);
 
-            ServiceRefHandler serviceRefHandler = ServiceRefHandlerFactory.getServiceRefHandler();
+            SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+            ServiceRefHandler serviceRefHandler = spiProvider.getSPI(ServiceRefHandlerFactory.class).getServiceRefHandler();
+            
             serviceRefHandler.bindServiceRef(envCtx, serviceRefName, urlLoaderAdapter, di.ucl, usr);
 
             log.debug("Webservice binding: java:comp/env/" + serviceRefName);

Modified: trunk/integration/jboss40/src/main/resources/jbossws-jboss40-config.xml
===================================================================
--- trunk/integration/jboss40/src/main/resources/jbossws-jboss40-config.xml	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/jboss40/src/main/resources/jbossws-jboss40-config.xml	2007-08-01 14:13:43 UTC (rev 4053)
@@ -13,10 +13,7 @@
   </bean>
 
   <!-- Bind Service objects in client environment context  -->
-  <bean name="ServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl">
-     <property name="jaxrpcBinder"><inject bean="WSServiceRefBinderJAXRPC"/></property>
-     <property name="jaxwsBinder"><inject bean="WSServiceRefBinderJAXWS"/></property>
-  </bean>
+  <bean name="ServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl"/>
 
   <!-- 
     ********************************************************************************************************************* 

Modified: trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/serviceref/ServiceRefHandlerImpl.java
===================================================================
--- trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/serviceref/ServiceRefHandlerImpl.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/jboss42/src/main/java/org/jboss/wsf/container/jboss42/serviceref/ServiceRefHandlerImpl.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -37,9 +37,9 @@
 import org.jboss.ws.integration.ServiceRefMetaData;
 import org.jboss.ws.integration.URLLoaderAdapter;
 import org.jboss.ws.integration.UnifiedVirtualFile;
-import org.jboss.wsf.framework.serviceref.ServiceRefBinder;
 import org.jboss.wsf.spi.WSFException;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
 import org.jboss.xb.binding.UnmarshallingContext;
 import org.xml.sax.Attributes;
 

Modified: trunk/integration/jboss42/src/main/resources/jbossws-jboss42-config.xml
===================================================================
--- trunk/integration/jboss42/src/main/resources/jbossws-jboss42-config.xml	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/jboss42/src/main/resources/jbossws-jboss42-config.xml	2007-08-01 14:13:43 UTC (rev 4053)
@@ -15,16 +15,10 @@
   </bean>
 
   <!-- Bind Service objects in client environment context  -->
-  <bean name="WSServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl">
-     <property name="jaxrpcBinder"><inject bean="WSServiceRefBinderJAXRPC"/></property>
-     <property name="jaxwsBinder"><inject bean="WSServiceRefBinderJAXWS"/></property>
-  </bean>
+  <bean name="WSServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl"/>
 
   <!-- JBoss_4_2_0_GA uses this hardcoded bean name -->
-  <bean name="ServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl">
-     <property name="jaxrpcBinder"><inject bean="WSServiceRefBinderJAXRPC"/></property>
-     <property name="jaxwsBinder"><inject bean="WSServiceRefBinderJAXWS"/></property>
-  </bean>
+  <bean name="ServiceRefHandler" class="org.jboss.wsf.container.jboss42.serviceref.ServiceRefHandlerImpl"/>
 
   <!-- 
     ********************************************************************************************************************* 

Added: trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/serviceref/ServiceRefHandlerImpl.java
===================================================================
--- trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/serviceref/ServiceRefHandlerImpl.java	                        (rev 0)
+++ trunk/integration/jboss50/src/main/java/org/jboss/wsf/container/jboss50/serviceref/ServiceRefHandlerImpl.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,187 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.container.jboss50.serviceref;
+
+// $Id: ServiceRefHandlerImpl.java 4043 2007-07-31 17:11:42Z thomas.diesler at jboss.com $
+
+import java.io.File;
+import java.lang.reflect.AnnotatedElement;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.framework.deployment.URLLoaderAdapter;
+import org.jboss.wsf.framework.serviceref.ServiceRefObjectFactory;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinder;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefElement;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * Bind service refs in the client's ENC
+ * for every service-ref element in the deployment descriptor.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @author Heiko.Braun at jboss.com
+ *
+ * @since 04-Nov-2006
+ */
+public class ServiceRefHandlerImpl implements ServiceRefHandler
+{
+   // logging support
+   private static Logger log = Logger.getLogger(ServiceRefHandlerImpl.class);
+
+   private ServiceRefObjectFactory objectFactory = new ServiceRefObjectFactory();
+
+   private ServiceRefBinder getJaxrpcBinder()
+   {
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      return spiProvider.getSPI(ServiceRefBinderFactory.class).newServiceRefBinder(Type.JAXRPC);
+   }
+
+   private ServiceRefBinder getJaxwsBinder()
+   {
+      SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+      return spiProvider.getSPI(ServiceRefBinderFactory.class).newServiceRefBinder(Type.JAXWS);
+   }
+
+   public ServiceRefMetaData newServiceRefMetaData()
+   {
+      return new UnifiedServiceRefMetaData();
+   }
+
+   public void bindServiceRef(Context encCtx, String encName, UnifiedVirtualFile vfsRoot, ClassLoader loader, ServiceRefMetaData sref) throws NamingException
+   {
+      if (sref.isProcessed())
+      {
+         log.debug("Attempt to rebind the service-ref: " + sref.getServiceRefName());
+         return;
+      }
+
+      // In case of an .war deployment the associated root file doesn't point to
+      // the expanded war file structure and thus breaks service-ref usage for servlet clients.
+      // This needs to be fixed in org.jboss.web.AbstractWebDeployer (JBOSS_AS/server module)
+      if (vfsRoot instanceof URLLoaderAdapter)
+      {
+         URLLoaderAdapter ula = (URLLoaderAdapter)vfsRoot;
+         URL rootURL = ula.toURL();
+         if ("file".equals(rootURL.getProtocol()) && rootURL.getFile().endsWith(".war"))
+         {
+            String fileName = rootURL.getFile();
+
+            if (!new File(fileName).exists()) // might be an exploded directory
+            {
+               // There is a filename convention for exploded directories
+               fileName = fileName.substring(0, fileName.indexOf(".war")) + "-exp.war";
+
+               File expandedDirectory = new File(fileName);
+               if (!expandedDirectory.exists())
+                  throw new WSFException("Failed to bind service-ref, the deployment root expandedDirectory doesn't exist: " + fileName);
+
+               // update the rootFile
+               try
+               {
+                  vfsRoot = new URLLoaderAdapter(expandedDirectory.toURL());
+               }
+               catch (MalformedURLException e)
+               {
+               }
+            }
+
+         }
+      }
+
+      UnifiedServiceRefMetaData serviceRef = (UnifiedServiceRefMetaData)sref;
+      serviceRef.setVfsRoot(vfsRoot);
+      try
+      {
+         if (getServiceRefType(serviceRef, loader) == Type.JAXRPC)
+         {
+            getJaxrpcBinder().setupServiceRef(encCtx, encName, null, serviceRef, loader);
+         }
+         else
+         {
+            AnnotatedElement anElement = (AnnotatedElement)sref.getAnnotatedElement();
+            getJaxwsBinder().setupServiceRef(encCtx, encName, anElement, serviceRef, loader);
+         }
+      }
+      finally
+      {
+         sref.setProcessed(true);
+      }
+   }
+
+   public Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs)
+   {
+      return objectFactory.newChild(ref, navigator, namespaceURI, localName, attrs);
+   }
+
+   public void setValue(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, String value)
+   {
+      objectFactory.setValue(ref, navigator, namespaceURI, localName, value);
+   }
+
+   private Type getServiceRefType(UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+   {
+      // The service-ref-type is JAXWS specific
+      String serviceRefType = serviceRef.getServiceRefType();
+      if (serviceRefType != null || serviceRef.getAnnotatedElement() != null)
+         return Type.JAXWS;
+
+      // The mapping-file is JAXRPC specific
+      if (serviceRef.getMappingFile() != null)
+         return Type.JAXRPC;
+
+      String siName = serviceRef.getServiceInterface();
+      if (siName == null)
+         throw new IllegalStateException("<service-interface> cannot be null");
+
+      if (siName.equals("javax.xml.rpc.Service"))
+         return Type.JAXRPC;
+
+      try
+      {
+         Class siClass = loader.loadClass(siName);
+         if (javax.xml.ws.Service.class.isAssignableFrom(siClass))
+            return Type.JAXWS;
+         else if (javax.xml.rpc.Service.class.isAssignableFrom(siClass))
+            return Type.JAXRPC;
+         else
+            throw new IllegalStateException("Illegal service interface: " + siName);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new IllegalStateException("Cannot load <service-interface>: " + siName);
+      }
+   }
+}

Modified: trunk/integration/native/src/main/resources/jbossws-native-config.xml
===================================================================
--- trunk/integration/native/src/main/resources/jbossws-native-config.xml	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/native/src/main/resources/jbossws-native-config.xml	2007-08-01 14:13:43 UTC (rev 4053)
@@ -34,10 +34,6 @@
     <property name="bindAddress">${jboss.bind.address}</property>
   </bean>
   
-  <!-- Bind Service objects in client environment context  -->
-  <bean name="WSServiceRefBinderJAXRPC" class="org.jboss.ws.core.jaxrpc.client.ServiceRefBinderJAXRPC"/>
-  <bean name="WSServiceRefBinderJAXWS" class="org.jboss.ws.core.jaxws.client.ServiceRefBinderJAXWS"/>
-  
   <!-- 
     The stack specific deployment aspects
   --> 

Added: trunk/integration/native/src/main/resources/jbossws-native.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
===================================================================
--- trunk/integration/native/src/main/resources/jbossws-native.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory	                        (rev 0)
+++ trunk/integration/native/src/main/resources/jbossws-native.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1 @@
+org.jboss.ws.core.client.ServiceRefBinderFactoryImpl
\ No newline at end of file

Modified: trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/framework/DefaultSPIProviderResolver.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -29,6 +29,7 @@
 import org.jboss.wsf.framework.http.DefaultHttpContextFactory;
 import org.jboss.wsf.framework.http.DefaultHttpServerFactory;
 import org.jboss.wsf.framework.invocation.DefaultResourceInjectorFactory;
+import org.jboss.wsf.framework.serviceref.DefaultServiceRefHandlerFactory;
 import org.jboss.wsf.spi.SPIProvider;
 import org.jboss.wsf.spi.SPIProviderResolver;
 import org.jboss.wsf.spi.WSFException;
@@ -44,6 +45,8 @@
 import org.jboss.wsf.spi.invocation.WebServiceContextFactory;
 import org.jboss.wsf.spi.management.EndpointRegistryFactory;
 import org.jboss.wsf.spi.management.ServerConfigFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
 
 /**
  * @author Heiko.Braun at jboss.com
@@ -98,6 +101,10 @@
          {
             returnType = (T)loadService(spiType, DefaultResourceInjectorFactory.class.getName());
          }
+         else if (ServiceRefHandlerFactory.class.equals(spiType))
+         {
+            returnType = (T)loadService(spiType, DefaultServiceRefHandlerFactory.class.getName());
+         }
 
          // SPI provided by either container or stack integration
 
@@ -121,6 +128,10 @@
          {
             returnType = (T)loadService(spiType, null);
          }
+         else if (ServiceRefBinderFactory.class.equals(spiType))
+         {
+            returnType = (T)loadService(spiType, null);
+         }
          else if (WebServiceContextFactory.class.equals(spiType))
          {
             returnType = (T)loadService(spiType, null);

Deleted: trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/CommonServiceRefBinder.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/CommonServiceRefBinder.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/CommonServiceRefBinder.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.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.Service;
-import javax.xml.ws.WebServiceClient;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-
-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;
-
-/**
- * A generic ServiceRefBinder that knows how to deal with JAX-WS services.
- * Subclasses need to provide a stack specific {@link Referenceable} that can be bound into JNDI.
- * <p/>
- * This works in conjunction with a ServiceObjectFactory that knows how to assemble
- * the Service after JNDI lookup on the client side.
- *
- * @see javax.naming.spi.ObjectFactory
- *
- * @author Heiko.Braun at jboss.com
- *         Created: Jul 12, 2007
- */
-public abstract class CommonServiceRefBinder implements ServiceRefBinder
-{
-   // logging support
-   private static Logger log = Logger.getLogger(CommonServiceRefBinder.class);
-
-   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, 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>();
-
-      if (anElement != null)
-      {
-         for (Annotation an : anElement.getAnnotations())
-         {
-            if (an instanceof WebServiceRef)
-               wsrefList.add((WebServiceRef)an);
-
-            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() != Object.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()));
-            }
-         }
-         catch (ClassNotFoundException e)
-         {
-            WSFException.rethrow("Cannot extract service QName for target service", e);
-         }
-      }
-
-      // 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);
-
-   }
-
-   /**
-    * Subclasses should provide a stack specific ServiceReferenceable.
-    *
-    * @param serviceImplClass
-    * @param targetClassName
-    * @param serviceRef
-    * @return  a Referenceable that can be used by a stack specific {@link javax.naming.spi.ObjectFactory} on the client side
-    * to create a web service stub
-    * */
-   protected abstract Referenceable buildServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef);
-}

Added: trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java	                        (rev 0)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/DefaultServiceRefHandlerFactory.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.framework.serviceref;
+
+//$Id: ServiceRefHandlerFactory.java 4049 2007-08-01 11:26:30Z thomas.diesler at jboss.com $
+
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.wsf.common.ServiceLoader;
+import org.jboss.wsf.common.KernelLocator;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
+import org.jboss.wsf.spi.serviceref.ServiceRefHandlerFactory;
+
+/**
+ * A factory for the ServiceRefHandler 
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 05-May-2004
+ */
+public class DefaultServiceRefHandlerFactory implements ServiceRefHandlerFactory
+{
+   public ServiceRefHandler getServiceRefHandler()
+   {
+      ServiceRefHandler handler;
+      if (KernelLocator.getKernel() != null)
+      {
+         handler = getServerSideServiceRefHandler();
+      }
+      else
+      {
+         handler = getClientSideServiceRefHandler();
+      }
+      return handler;
+   }
+
+   private ServiceRefHandler getServerSideServiceRefHandler()
+   {
+      Kernel kernel = KernelLocator.getKernel();
+      KernelRegistry registry = kernel.getRegistry();
+      KernelRegistryEntry entry = registry.getEntry(ServiceRefHandler.BEAN_NAME);
+      ServiceRefHandler handler = (ServiceRefHandler)entry.getTarget();
+      return handler;
+   }
+
+   private ServiceRefHandler getClientSideServiceRefHandler()
+   {
+      String propName = ServiceRefHandler.class.getName();
+      String defaultImpl = "org.jboss.ws.integration.ServiceRefHandlerImpl";
+      ServiceRefHandler handler = (ServiceRefHandler) ServiceLoader.loadService(propName, defaultImpl);
+      return handler;
+   }
+}

Deleted: trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefBinder.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefBinder.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefBinder.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.serviceref;
-
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import java.lang.reflect.AnnotatedElement;
-
-/**
- * Creates a ServiceReferenceable and binds it to JNDI.
- *
- * @author Heiko.Braun at jboss.com
- *         Created: Jul 11, 2007
- */
-public interface ServiceRefBinder
-{
-   public final static String JAXRPC_BINDER = "WSServiceRefBinderJAXRPC";
-
-   public final static String JAXWS_BINDER = "WSServiceRefBinderJAXWS";
-
-   void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader)
-     throws NamingException;
-}

Deleted: trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefHandlerFactory.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefHandlerFactory.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefHandlerFactory.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.framework.serviceref;
-
-//$Id$
-
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.registry.KernelRegistry;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.wsf.common.ServiceLoader;
-import org.jboss.wsf.common.KernelLocator;
-import org.jboss.wsf.spi.serviceref.ServiceRefHandler;
-
-/**
- * A factory for the ServiceRefHandler 
- * 
- * @author Thomas.Diesler at jboss.org
- * @since 05-May-2004
- */
-public abstract class ServiceRefHandlerFactory
-{
-   public static ServiceRefHandler getServiceRefHandler()
-   {
-      ServiceRefHandler handler;
-      if (KernelLocator.getKernel() != null)
-      {
-         handler = getServerSideServiceRefHandler();
-      }
-      else
-      {
-         handler = getClientSideServiceRefHandler();
-      }
-      return handler;
-   }
-
-   private static ServiceRefHandler getServerSideServiceRefHandler()
-   {
-      Kernel kernel = KernelLocator.getKernel();
-      KernelRegistry registry = kernel.getRegistry();
-      KernelRegistryEntry entry = registry.getEntry(ServiceRefHandler.BEAN_NAME);
-      ServiceRefHandler handler = (ServiceRefHandler)entry.getTarget();
-
-      // Try legacy JBossAS-4.2 name
-      if (handler == null)
-      {
-         entry = registry.getEntry("ServiceRefHandler");
-         handler = (ServiceRefHandler)entry.getTarget();
-      }
-      return handler;
-   }
-
-   private static ServiceRefHandler getClientSideServiceRefHandler()
-   {
-      String propName = ServiceRefHandler.class.getName();
-      String defaultImpl = "org.jboss.ws.integration.ServiceRefHandlerImpl";
-      ServiceRefHandler handler = (ServiceRefHandler) ServiceLoader.loadService(propName, defaultImpl);
-      return handler;
-   }
-}

Copied: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java (from rev 4050, trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefBinder.java)
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java	                        (rev 0)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinder.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.serviceref;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+/**
+ * Creates a ServiceReferenceable and binds it to JNDI.
+ *
+ * @author Heiko.Braun at jboss.com
+ *         Created: Jul 11, 2007
+ */
+public interface ServiceRefBinder
+{
+   final static String BEAN_NAME_JAXRPC = "WSServiceRefBinderJAXRPC";
+
+   final static String BEAN_NAME_JAXWS = "WSServiceRefBinderJAXWS";
+
+   void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException;
+}

Added: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinderFactory.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinderFactory.java	                        (rev 0)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefBinderFactory.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.serviceref;
+
+/**
+ * @author Thomas.Diesler at jboss.com
+ * @since 01-Aug-2007
+ */
+public interface ServiceRefBinderFactory
+{
+   ServiceRefBinder newServiceRefBinder(ServiceRefHandler.Type type);
+}

Modified: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandler.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -40,6 +40,8 @@
 {
    final String BEAN_NAME = "WSServiceRefHandler";
    
+   enum Type {JAXRPC, JAXWS};
+
    ServiceRefMetaData newServiceRefMetaData();
 
    Object newChild(ServiceRefElement ref, UnmarshallingContext navigator, String namespaceURI, String localName, Attributes attrs);

Copied: trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandlerFactory.java (from rev 4049, trunk/integration/spi/src/main/java/org/jboss/wsf/framework/serviceref/ServiceRefHandlerFactory.java)
===================================================================
--- trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandlerFactory.java	                        (rev 0)
+++ trunk/integration/spi/src/main/java/org/jboss/wsf/spi/serviceref/ServiceRefHandlerFactory.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.serviceref;
+
+//$Id$
+
+
+public interface ServiceRefHandlerFactory
+{
+   ServiceRefHandler getServiceRefHandler();
+}
\ No newline at end of file

Deleted: trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/DummyServiceRefBinderJAXRPC.java
===================================================================
--- trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/DummyServiceRefBinderJAXRPC.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/DummyServiceRefBinderJAXRPC.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.sunri.client;
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.wsf.framework.serviceref.ServiceRefBinder;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-/**
- * @author Heiko.Braun at jboss.com
- *         Created: Jul 12, 2007
- */
-public class DummyServiceRefBinderJAXRPC implements ServiceRefBinder
-{
-   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
-   {
-      throw new IllegalArgumentException("The Sun-RI stack doesnt support JAX-RPC service-ref deployments");
-   }
-}

Added: trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXRPC.java
===================================================================
--- trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXRPC.java	                        (rev 0)
+++ trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXRPC.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.sunri.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 Heiko.Braun at jboss.com
+ *         Created: Jul 12, 2007
+ */
+public class MetroServiceRefBinderJAXRPC implements ServiceRefBinder
+{
+   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws NamingException
+   {
+      throw new IllegalArgumentException("Deployed stack doesnt support JAX-RPC service-ref deployments");
+   }
+}

Copied: trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXWS.java (from rev 4050, trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderJAXWS.java)
===================================================================
--- trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXWS.java	                        (rev 0)
+++ trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/MetroServiceRefBinderJAXWS.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,221 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.sunri.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.Service;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+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 Heiko.Braun at jboss.com
+ *         Created: Jul 12, 2007
+ */
+public class MetroServiceRefBinderJAXWS implements ServiceRefBinder
+{
+   // logging support
+   private static Logger log = Logger.getLogger(MetroServiceRefBinderJAXWS.class);
+
+   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, 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>();
+
+      if (anElement != null)
+      {
+         for (Annotation an : anElement.getAnnotations())
+         {
+            if (an instanceof WebServiceRef)
+               wsrefList.add((WebServiceRef)an);
+
+            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() != Object.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()));
+            }
+         }
+         catch (ClassNotFoundException e)
+         {
+            WSFException.rethrow("Cannot extract service QName for target service", e);
+         }
+      }
+
+      // 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 Sun-RI 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 Sun-RI specific service referenceable.
+    */
+   protected Referenceable buildServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
+   {
+      return new SunRIServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
+   }
+}

Added: trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderFactoryImpl.java
===================================================================
--- trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderFactoryImpl.java	                        (rev 0)
+++ trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderFactoryImpl.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.sunri.client;
+
+// $Id: ServiceRefBinderJAXWS.java 4049 2007-08-01 11:26:30Z thomas.diesler at jboss.com $
+
+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 at jboss.org
+ * @since 17-Jan-2007
+ */
+public class ServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
+{
+   public ServiceRefBinder newServiceRefBinder(Type type)
+   {
+      return (type == Type.JAXRPC ? new MetroServiceRefBinderJAXRPC() : new MetroServiceRefBinderJAXWS());
+   }
+}

Deleted: trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderJAXWS.java
===================================================================
--- trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderJAXWS.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/sunri/src/main/java/org/jboss/wsf/stack/sunri/client/ServiceRefBinderJAXWS.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.sunri.client;
-
-import org.jboss.wsf.framework.serviceref.CommonServiceRefBinder;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.Referenceable;
-
-/**
- * @author Heiko.Braun at jboss.com
- *         Created: Jul 12, 2007
- */
-public class ServiceRefBinderJAXWS extends CommonServiceRefBinder
-{
-   /**
-    * Create a Sun-RI specific service referenceable.
-    * Most of the setup is done in {@link org.jboss.wsf.framework.serviceref.CommonServiceRefBinder}
-    *
-    * @param serviceImplClass
-    * @param targetClassName
-    * @param serviceRef
-    * @return a Sun-RI specific service referenceable.
-    */
-   protected Referenceable buildServiceReferenceable(
-     String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
-   {
-      return new SunRIServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
-   }
-}

Modified: trunk/integration/sunri/src/main/resources/jbossws-sunri-config.xml
===================================================================
--- trunk/integration/sunri/src/main/resources/jbossws-sunri-config.xml	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/integration/sunri/src/main/resources/jbossws-sunri-config.xml	2007-08-01 14:13:43 UTC (rev 4053)
@@ -29,20 +29,6 @@
     <property name="mbeanServer"><inject bean="WSMBeanServerLocator" property="mbeanServer"/></property>
   </bean>
   
-  <!-- Bind Service objects in client environment context  -->
-  <bean name="WSServiceRefHandler" class="org.jboss.ws.integration.ServiceRefHandlerImpl">
-     <property name="jaxrpcBinder"><inject bean="WSServiceRefBinderJAXRPC"/></property>
-     <property name="jaxwsBinder"><inject bean="WSServiceRefBinderJAXWS"/></property>
-  </bean>
-  
-  <!-- JBoss_4_2_0_GA uses this hardcoded bean name -->
-  <bean name="ServiceRefHandler" class="org.jboss.ws.integration.ServiceRefHandlerImpl">
-     <property name="jaxrpcBinder"><inject bean="WSServiceRefBinderJAXRPC"/></property>
-     <property name="jaxwsBinder"><inject bean="WSServiceRefBinderJAXWS"/></property>
-  </bean>
-  <bean name="WSServiceRefBinderJAXRPC" class="org.jboss.wsf.stack.sunri.client.DummyServiceRefBinderJAXRPC"/>
-  <bean name="WSServiceRefBinderJAXWS" class="org.jboss.wsf.stack.sunri.client.ServiceRefBinderJAXWS"/>
-
   <!-- Logging redirector -->
   <bean name="JDKLogRedirector" class="org.jboss.wsf.stack.sunri.log.JDKLogRedirector">
     <property name="namespaces">

Added: trunk/integration/sunri/src/main/resources/jbossws-sunri.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
===================================================================
--- trunk/integration/sunri/src/main/resources/jbossws-sunri.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory	                        (rev 0)
+++ trunk/integration/sunri/src/main/resources/jbossws-sunri.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.sunri.client.ServiceRefBinderFactoryImpl
\ No newline at end of file

Added: trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java	                        (rev 0)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/client/ServiceRefBinderFactoryImpl.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+// $Id: ServiceRefBinderJAXWS.java 4049 2007-08-01 11:26:30Z thomas.diesler at jboss.com $
+
+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 at jboss.org
+ * @since 17-Jan-2007
+ */
+public class ServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
+{
+   public ServiceRefBinder newServiceRefBinder(Type type)
+   {
+      return (type == Type.JAXRPC ? new NativeServiceRefBinderJAXRPC() : new NativeServiceRefBinderJAXWS());
+   }
+}

Copied: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java (from rev 4050, trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefBinderJAXRPC.java)
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java	                        (rev 0)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/NativeServiceRefBinderJAXRPC.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.jaxrpc.client;
+
+// $Id$
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+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 Thomas.Diesler at jboss.org
+ * @since 04-Nov-2006
+ */
+public class NativeServiceRefBinderJAXRPC implements ServiceRefBinder
+{
+   // 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 anElement, 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
+      ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
+      Util.bind(encCtx, encName, ref);
+   }
+}

Deleted: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefBinderJAXRPC.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefBinderJAXRPC.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxrpc/client/ServiceRefBinderJAXRPC.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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.jaxrpc.client;
-
-// $Id$
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-import org.jboss.util.naming.Util;
-import org.jboss.wsf.framework.serviceref.ServiceRefBinder;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import java.lang.reflect.AnnotatedElement;
-
-/**
- * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
- * deployment descriptor.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 04-Nov-2006
- */
-public class ServiceRefBinderJAXRPC implements ServiceRefBinder
-{
-   // logging support
-   private static Logger log = Logger.getLogger(ServiceRefBinderJAXRPC.class);
-   
-   /**
-    * Binds a Service into the callers ENC for every service-ref element
-    */
-   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, 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
-      ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
-      Util.bind(encCtx, encName, ref);
-   }
-}

Copied: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java (from rev 4050, trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefBinderJAXWS.java)
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java	                        (rev 0)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -0,0 +1,215 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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;
+
+// $Id$
+
+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.Service;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+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 Thomas.Diesler at jboss.org
+ * @since 17-Jan-2007
+ */
+public class NativeServiceRefBinderJAXWS implements ServiceRefBinder
+{
+   // logging support
+   private static Logger log = Logger.getLogger(NativeServiceRefBinderJAXWS.class);
+   
+   public void setupServiceRef(Context encCtx, String encName, AnnotatedElement anElement, 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>();
+
+      if (anElement != null)
+      {
+         for (Annotation an : anElement.getAnnotations())
+         {
+            if (an instanceof WebServiceRef)
+               wsrefList.add((WebServiceRef)an);
+
+            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() != Object.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()));
+            }
+         }
+         catch (ClassNotFoundException e)
+         {
+            WSFException.rethrow("Cannot extract service QName for target service", e);
+         }
+      }
+
+      // 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);
+
+   }
+
+   protected Referenceable buildServiceReferenceable(String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
+   {
+      return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
+   }
+}

Deleted: trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefBinderJAXWS.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefBinderJAXWS.java	2007-08-01 13:27:00 UTC (rev 4052)
+++ trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceRefBinderJAXWS.java	2007-08-01 14:13:43 UTC (rev 4053)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt 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;
-
-// $Id$
-
-import org.jboss.wsf.framework.serviceref.CommonServiceRefBinder;
-import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
-
-import javax.naming.Referenceable;
-
-/**
- * Binds a JAXWS Service object in the client's ENC
- *
- * @author Thomas.Diesler at jboss.org
- * @since 17-Jan-2007
- */
-public class ServiceRefBinderJAXWS extends CommonServiceRefBinder
-{
-   protected Referenceable buildServiceReferenceable(
-     String serviceImplClass, String targetClassName, UnifiedServiceRefMetaData serviceRef)
-   {
-      return new ServiceReferenceable(serviceImplClass, targetClassName, serviceRef);      
-   }
-}




More information about the jbossws-commits mailing list