Author: thomas.diesler(a)jboss.com
Date: 2007-12-06 11:37:59 -0500 (Thu, 06 Dec 2007)
New Revision: 5213
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java
stack/cxf/trunk/src/main/resources/jbossws-cxf.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
Modified:
stack/cxf/trunk/ant-import/build-thirdparty.xml
stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt
Log:
[JBWS-1756] Fix @WebServiceRef with CXF
Modified: stack/cxf/trunk/ant-import/build-thirdparty.xml
===================================================================
--- stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-12-06 16:28:41 UTC (rev 5212)
+++ stack/cxf/trunk/ant-import/build-thirdparty.xml 2007-12-06 16:37:59 UTC (rev 5213)
@@ -81,6 +81,7 @@
<pathelement location="${thirdparty.dir}/jbossws-spi.jar"/>
<pathelement location="${thirdparty.dir}/cxf-${cxf.version}.jar"/>
+ <pathelement
location="${thirdparty.dir}/geronimo-ws-metadata_${cxf.geronimo.ws.metadata}.jar"/>
<pathelement
location="${thirdparty.dir}/jaxws-api-${cxf.jaxws.api}.jar"/>
<pathelement
location="${thirdparty.dir}/spring-beans-${cxf.spring}.jar"/>
<pathelement
location="${thirdparty.dir}/spring-context-${cxf.spring}.jar"/>
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
---
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
(rev 0)
+++
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2007-12-06
16:37:59 UTC (rev 5213)
@@ -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.wsf.stack.cxf.client;
+
+// $Id: $
+
+import org.jboss.wsf.spi.WSFException;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedServiceRefMetaData;
+
+import javax.naming.*;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+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.Hashtable;
+import org.jboss.logging.Logger;
+
+/**
+ * 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
+ * @since 06-Dec-2007
+ */
+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
+ */
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable
environment) throws Exception
+ {
+ try
+ {
+ Reference ref = (Reference)obj;
+
+ // Get the target class name
+ String targetClassName =
(String)ref.get(ServiceReferenceable.TARGET_CLASS_NAME).getContent();
+
+ // Unmarshall the UnifiedServiceRef
+ UnifiedServiceRefMetaData serviceRef = unmarshallServiceRef(ref);
+ String serviceRefName = serviceRef.getServiceRefName();
+ QName serviceQName = serviceRef.getServiceQName();
+
+ String serviceImplClass = serviceRef.getServiceImplClass();
+ if (serviceImplClass == null)
+ serviceImplClass =
(String)ref.get(ServiceReferenceable.SERVICE_IMPL_CLASS).getContent();
+
+ // If the target defaults to javax.xml.ws.Service, use the service as the
target
+ if (Service.class.getName().equals(targetClassName))
+ targetClassName = serviceImplClass;
+
+ log.debug("getObjectInstance [name=" + serviceRefName +
",service=" + serviceImplClass + ",target=" + targetClassName +
"]");
+
+ // Load the service class
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ Class serviceClass = ctxLoader.loadClass(serviceImplClass);
+ Class targetClass = (targetClassName != null ?
ctxLoader.loadClass(targetClassName) : null);
+
+ if (Service.class.isAssignableFrom(serviceClass) == false)
+ throw new IllegalArgumentException("WebServiceRef type '" +
serviceClass + "' is not assignable to javax.xml.ws.Service");
+
+ // Receives either a javax.xml.ws.Service or a dynamic proxy
+ Object target;
+
+ // Get the URL to the wsdl
+ URL wsdlURL = serviceRef.getWsdlLocation();
+
+ // Generic javax.xml.ws.Service
+ if (serviceClass == Service.class)
+ {
+ if (wsdlURL != null)
+ {
+ target = Service.create(wsdlURL, serviceQName);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot create generic
javax.xml.ws.Service without wsdlLocation: " + serviceRefName);
+ }
+ }
+ // Generated javax.xml.ws.Service subclass
+ else
+ {
+ if (wsdlURL != null)
+ {
+ Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class,
QName.class });
+ target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
+ }
+ else
+ {
+ target = (Service)serviceClass.newInstance();
+ }
+ }
+
+ // Configure the service
+ configureService((Service)target, serviceRef);
+
+ if (targetClassName != null && targetClassName.equals(serviceImplClass)
== false)
+ {
+ try
+ {
+ 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]);
+ target = port;
+ break;
+ }
+ }
+ }
+
+ if (port == null)
+ {
+ Method method = serviceClass.getMethod("getPort", new Class[]
{ Class.class });
+ port = method.invoke(target, new Object[] { targetClass });
+ target = port;
+ }
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw ex.getTargetException();
+ }
+ }
+
+ return target;
+ }
+ catch (Throwable ex)
+ {
+ WSFException.rethrow("Cannot create service", ex);
+ return null;
+ }
+ }
+
+
+ private void configureService(Service service, UnifiedServiceRefMetaData serviceRef)
+ {
+ log.warn("Service configuration not available in Sun-RI");
+ }
+
+ private UnifiedServiceRefMetaData unmarshallServiceRef(Reference ref) throws
ClassNotFoundException, NamingException
+ {
+ UnifiedServiceRefMetaData sref;
+ RefAddr refAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
+ 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());
+ }
+
+ // Verify it. There is some know coinstraints
+ if(null == sref.getServiceQName())
+ throw new IllegalArgumentException("ServiceQName may not be null. " +
+ "Specify a service QName in the <service-ref> declaration, or
thorugh the @WebServiceClient annotation.");
+
+ return sref;
+ }
+}
+
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
===================================================================
---
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java
(rev 0)
+++
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderFactoryImpl.java 2007-12-06
16:37:59 UTC (rev 5213)
@@ -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.cxf.client;
+
+// $Id: ServiceRefBinderJAXWS.java 4049 2007-08-01 11:26:30Z thomas.diesler(a)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(a)jboss.com
+ * @since 06-Dec-2007
+ */
+public class ServiceRefBinderFactoryImpl implements ServiceRefBinderFactory
+{
+ public ServiceRefBinder newServiceRefBinder(Type type)
+ {
+ return (type == Type.JAXRPC ? new ServiceRefBinderJAXRPC() : new
ServiceRefBinderJAXWS());
+ }
+}
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
===================================================================
---
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java
(rev 0)
+++
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXRPC.java 2007-12-06
16:37:59 UTC (rev 5213)
@@ -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.stack.cxf.client;
+
+// $Id: $
+
+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
anElement, UnifiedServiceRefMetaData serviceRef, ClassLoader loader) throws
NamingException
+ {
+ throw new IllegalArgumentException("Deployed stack does not support JAX-RPC
service-ref deployments");
+ }
+}
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
===================================================================
---
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
(rev 0)
+++
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2007-12-06
16:37:59 UTC (rev 5213)
@@ -0,0 +1,223 @@
+/*
+ * 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.cxf.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;
+
+/**
+ * @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
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 ServiceReferenceable(serviceImplClass, targetClassName, serviceRef);
+ }
+}
Added:
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java
===================================================================
---
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java
(rev 0)
+++
stack/cxf/trunk/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceReferenceable.java 2007-12-06
16:37:59 UTC (rev 5213)
@@ -0,0 +1,91 @@
+/*
+ * 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.cxf.client;
+
+// $Id: $
+
+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();
+ }
+}
Added:
stack/cxf/trunk/src/main/resources/jbossws-cxf.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
===================================================================
---
stack/cxf/trunk/src/main/resources/jbossws-cxf.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory
(rev 0)
+++
stack/cxf/trunk/src/main/resources/jbossws-cxf.jar/META-INF/services/org.jboss.wsf.spi.serviceref.ServiceRefBinderFactory 2007-12-06
16:37:59 UTC (rev 5213)
@@ -0,0 +1 @@
+org.jboss.wsf.stack.cxf.client.ServiceRefBinderFactoryImpl
\ No newline at end of file
Modified: stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt
===================================================================
--- stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt 2007-12-06 16:28:41 UTC
(rev 5212)
+++ stack/cxf/trunk/src/test/resources/test-excludes-jboss500.txt 2007-12-06 16:37:59 UTC
(rev 5213)
@@ -14,11 +14,6 @@
# [JBWS-1683] Fix JAXR samples for CXF
org/jboss/test/ws/jaxws/samples/jaxr/**
-# [JBWS-1756] Fix @WebServiceRef with CXF
-org/jboss/test/ws/jaxws/samples/retail/**
-org/jboss/test/ws/jaxws/samples/serviceref/**
-org/jboss/test/ws/jaxws/samples/webserviceref/**
-
# [JBWS-1774] Provide a tools implementation for CXF (WSContractProvider and
WSContractConsumer)
org/jboss/test/ws/jaxws/smoke/tools/**
@@ -35,7 +30,7 @@
# [CXF-1253] CXF does not respect @HandlerChain on client SEI
org/jboss/test/ws/jaxws/samples/logicalhandler/**
-# [CXF-1261] Handler does not see XOP message properly
+# Won't Fix: [CXF-1261] Handler does not see XOP message properly
org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*