Author: thomas.diesler(a)jboss.com
Date: 2006-10-25 07:55:34 -0400 (Wed, 25 Oct 2006)
New Revision: 1308
Added:
trunk/src/main/java/org/jboss/ws/jaxws/injection/
trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceObjectFactory.java
trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceReferenceable.java
trunk/src/main/java/org/jboss/ws/jaxws/injection/WebServiceRefDeployer.java
Removed:
trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java
trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java
trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java
Modified:
trunk/.classpath
trunk/build.xml
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ApplicationClient.java
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/EJB3Client.java
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ServletClient.java
Log:
Move dependency of jboss-ejb3 from jbossws-core to jboss-jaxws
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2006-10-25 11:02:35 UTC (rev 1307)
+++ trunk/.classpath 2006-10-25 11:55:34 UTC (rev 1308)
@@ -28,6 +28,6 @@
<classpathentry kind="lib"
path="thirdparty/jboss-remoting.jar"/>
<classpathentry kind="lib" path="thirdparty/jaxb-xjc.jar"/>
<classpathentry kind="lib" path="thirdparty/jaxb-impl.jar"/>
- <classpathentry kind="lib"
path="thirdparty/jboss-common.jar"/>
+ <classpathentry
sourcepath="/home/tdiesler/svn/jboss/common/common-core/trunk/src/main/java"
kind="lib" path="thirdparty/jboss-common.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2006-10-25 11:02:35 UTC (rev 1307)
+++ trunk/build.xml 2006-10-25 11:55:34 UTC (rev 1308)
@@ -222,7 +222,7 @@
<fileset dir="${build.classes.dir}">
<include name="javax/jws/**"/>
<include name="javax/xml/ws/**"/>
- <include
name="org/jboss/ws/integration/jboss/WebServiceRefDeployer.class"/>
+ <include name="org/jboss/ws/jaxws/injection/**"/>
</fileset>
</jar>
Deleted: trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java 2006-10-25
11:02:35 UTC (rev 1307)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -1,65 +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.integration.jboss;
-
-// $Id$
-
-import javax.naming.Context;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceRef;
-
-import org.jboss.logging.Logger;
-import org.jboss.naming.Util;
-import org.jboss.ws.jaxws.ServiceReferenceable;
-
-/**
- * Binds a JAXWS Service object into JNDI
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 24-Oct-2006
- */
-public class WebServiceRefDeployer
-{
- // provide logging
- private static Logger log = Logger.getLogger(WebServiceRefDeployer.class);
-
- private WebServiceRefDeployer()
- {
- // Hide ctor
- }
-
- public static void setupWebServiceRef(Context ctx, String jndiName, Class targetType,
WebServiceRef ref) throws Exception
- {
- Class serviceType = ref.value();
- if (serviceType == Object.class)
- {
- if (targetType != null)
- serviceType = targetType;
- else
- serviceType = Service.class;
- }
-
- String targetTypeName = (targetType != null ? targetType.getName() : null);
- Util.bind(ctx, jndiName, new ServiceReferenceable(serviceType.getName(),
targetTypeName, ref.wsdlLocation()));
- log.debug("WebServiceRef bound [jndi=" + jndiName + ",type=" +
targetTypeName + "]");
- }
-}
Deleted: trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java 2006-10-25 11:02:35
UTC (rev 1307)
+++ trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java 2006-10-25 11:55:34
UTC (rev 1308)
@@ -1,181 +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.
- */
-// $Id$
-package org.jboss.ws.jaxws;
-
-// $Id$
-
-import java.io.File;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceException;
-
-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
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 24-Oct-2004
- */
-public class ServiceObjectFactory implements ObjectFactory
-{
- // provide logging
- private static 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;
-
- String serviceTypeName =
(String)ref.get(ServiceReferenceable.SERVICE_TYPE).getContent();
- String targetTypeName =
(String)ref.get(ServiceReferenceable.TARGET_TYPE).getContent();
- String wsdlLocation =
(String)ref.get(ServiceReferenceable.WSDL_LOCATION).getContent();
-
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- Class serviceType = ctxLoader.loadClass(serviceTypeName);
- Class targetType = ctxLoader.loadClass(targetTypeName);
-
- if (Service.class.isAssignableFrom(serviceType) == false)
- throw new IllegalArgumentException("WebServiceRef type '" +
serviceType + "' is not assignable to javax.xml.ws.Service");
-
- Object target;
-
- URL wsdlURL = getWsdlLocationURL(serviceType, wsdlLocation);
- if (wsdlURL != null)
- {
- Constructor ctor = serviceType.getConstructor(new Class[] { URL.class,
QName.class });
- target = (Service)ctor.newInstance(new Object[] { wsdlURL, null });
- }
- else
- {
- target = (Service)serviceType.newInstance();
- }
-
- if (serviceTypeName.equals(targetTypeName) == false)
- {
- Object port = null;
- for (Method method : serviceType.getMethods())
- {
- String methodName = method.getName();
- Class retType = method.getReturnType();
- if (methodName.startsWith("get") &&
targetType.isAssignableFrom(retType))
- {
- port = method.invoke(target, new Object[0]);
- target = port;
- break;
- }
- }
-
- if (port == null)
- throw new WebServiceException("Cannot find getter for port type:
" + targetTypeName);
- }
-
- return target;
- }
- catch (Exception ex)
- {
- log.error("Cannot create service", ex);
- throw ex;
- }
- }
-
- private URL getWsdlLocationURL(Class type, String wsdlLocation)
- {
- URL wsdlURL = null;
- if (wsdlLocation != null && wsdlLocation.length() > 0)
- {
- // Try the wsdlLocation as URL
- try
- {
- wsdlURL = new URL(wsdlLocation);
- }
- catch (MalformedURLException ex)
- {
- // ignore
- }
-
- // Try the filename as File
- if (wsdlURL == null)
- {
- try
- {
- File file = new File(wsdlLocation);
- if (file.exists())
- wsdlURL = file.toURL();
- }
- catch (MalformedURLException e)
- {
- // ignore
- }
- }
-
- // Try the filename as Resource
- if (wsdlURL == null)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- wsdlURL = loader.getResource(wsdlLocation);
- }
-
- // Try the filename relative to class
- if (wsdlURL == null)
- {
- String packagePath = type.getPackage().getName().replace('.',
'/');
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- wsdlURL = loader.getResource(packagePath + "/" + wsdlLocation);
- }
- }
- return wsdlURL;
- }
-}
Deleted: trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java 2006-10-25 11:02:35
UTC (rev 1307)
+++ trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java 2006-10-25 11:55:34
UTC (rev 1308)
@@ -1,74 +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.
- */
-// $Id$
-package org.jboss.ws.jaxws;
-
-// $Id$
-
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.StringRefAddr;
-
-/**
- * A JNDI reference to a javax.xml.ws.Service
- *
- * It holds the information to reconstrut the javax.xml.ws.Service
- * when the client does a JNDI lookup.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 24-Oct-2006
- */
-public class ServiceReferenceable implements Referenceable
-{
- public static final String WSDL_LOCATION = "WSDL_LOCATION";
- public static final String SERVICE_TYPE = "SERVICE_TYPE";
- public static final String TARGET_TYPE = "TARGET_TYPE";
-
- private String serviceType;
- private String targetType;
- private String wsdlLocation;
-
- public ServiceReferenceable(String serviceType, String targetType, String
wsdlLocation)
- {
- this.serviceType = serviceType;
- this.targetType = targetType;
- this.wsdlLocation = wsdlLocation;
- }
-
- /**
- * 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_TYPE, serviceType));
- myRef.add(new StringRefAddr(TARGET_TYPE, targetType));
- myRef.add(new StringRefAddr(WSDL_LOCATION, wsdlLocation));
-
- return myRef;
- }
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceObjectFactory.java (from
rev 1302, trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/ServiceObjectFactory.java 2006-10-25 06:35:39
UTC (rev 1302)
+++ trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceObjectFactory.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+// $Id$
+package org.jboss.ws.jaxws.injection;
+
+// $Id$
+
+import java.io.File;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+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
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 24-Oct-2004
+ */
+public class ServiceObjectFactory implements ObjectFactory
+{
+ // provide logging
+ private static 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;
+
+ String serviceTypeName =
(String)ref.get(ServiceReferenceable.SERVICE_TYPE).getContent();
+ String portTypeName =
(String)ref.get(ServiceReferenceable.PORT_TYPE).getContent();
+ String wsdlLocation =
(String)ref.get(ServiceReferenceable.WSDL_LOCATION).getContent();
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ Class serviceType = ctxLoader.loadClass(serviceTypeName);
+ Class portType = (portTypeName != null ? ctxLoader.loadClass(portTypeName) :
null);
+
+ if (Service.class.isAssignableFrom(serviceType) == false)
+ throw new IllegalArgumentException("WebServiceRef type '" +
serviceType + "' is not assignable to javax.xml.ws.Service");
+
+ Object target;
+
+ URL wsdlURL = getWsdlLocationURL(serviceType, wsdlLocation);
+ if (wsdlURL != null)
+ {
+ Constructor ctor = serviceType.getConstructor(new Class[] { URL.class,
QName.class });
+ target = (Service)ctor.newInstance(new Object[] { wsdlURL, null });
+ }
+ else
+ {
+ target = (Service)serviceType.newInstance();
+ }
+
+ if (portTypeName != null && portTypeName.equals(serviceTypeName) ==
false)
+ {
+ Object port = null;
+ for (Method method : serviceType.getMethods())
+ {
+ String methodName = method.getName();
+ Class retType = method.getReturnType();
+ if (methodName.startsWith("get") &&
portType.isAssignableFrom(retType))
+ {
+ port = method.invoke(target, new Object[0]);
+ target = port;
+ break;
+ }
+ }
+
+ if (port == null)
+ throw new WebServiceException("Cannot find getter for port type:
" + portTypeName);
+ }
+
+ return target;
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot create service", ex);
+ throw ex;
+ }
+ }
+
+ private URL getWsdlLocationURL(Class type, String wsdlLocation)
+ {
+ URL wsdlURL = null;
+ if (wsdlLocation != null && wsdlLocation.length() > 0)
+ {
+ // Try the wsdlLocation as URL
+ try
+ {
+ wsdlURL = new URL(wsdlLocation);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try the filename as File
+ if (wsdlURL == null)
+ {
+ try
+ {
+ File file = new File(wsdlLocation);
+ if (file.exists())
+ wsdlURL = file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ // Try the filename as Resource
+ if (wsdlURL == null)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ wsdlURL = loader.getResource(wsdlLocation);
+ }
+
+ // Try the filename relative to class
+ if (wsdlURL == null)
+ {
+ String packagePath = type.getPackage().getName().replace('.',
'/');
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ wsdlURL = loader.getResource(packagePath + "/" + wsdlLocation);
+ }
+ }
+ return wsdlURL;
+ }
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceObjectFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceReferenceable.java (from
rev 1302, trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java)
===================================================================
--- trunk/src/main/java/org/jboss/ws/jaxws/ServiceReferenceable.java 2006-10-25 06:35:39
UTC (rev 1302)
+++ trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceReferenceable.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+// $Id$
+package org.jboss.ws.jaxws.injection;
+
+// $Id$
+
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.StringRefAddr;
+
+
+/**
+ * A JNDI reference to a javax.xml.ws.Service
+ *
+ * It holds the information to reconstrut the javax.xml.ws.Service
+ * when the client does a JNDI lookup.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 24-Oct-2006
+ */
+public class ServiceReferenceable implements Referenceable
+{
+ public static final String WSDL_LOCATION = "WSDL_LOCATION";
+ public static final String SERVICE_TYPE = "SERVICE_TYPE";
+ public static final String PORT_TYPE = "PORT_TYPE";
+
+ private String serviceType;
+ private String portType;
+ private String wsdlLocation;
+
+ public ServiceReferenceable(String serviceType, String portType, String wsdlLocation)
+ {
+ this.serviceType = serviceType;
+ this.portType = portType;
+ this.wsdlLocation = wsdlLocation;
+ }
+
+ /**
+ * 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_TYPE, serviceType));
+ myRef.add(new StringRefAddr(PORT_TYPE, portType));
+ myRef.add(new StringRefAddr(WSDL_LOCATION, wsdlLocation));
+
+ return myRef;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/src/main/java/org/jboss/ws/jaxws/injection/ServiceReferenceable.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: trunk/src/main/java/org/jboss/ws/jaxws/injection/WebServiceRefDeployer.java (from
rev 1303, trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java)
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss/WebServiceRefDeployer.java 2006-10-25
10:23:24 UTC (rev 1303)
+++ trunk/src/main/java/org/jboss/ws/jaxws/injection/WebServiceRefDeployer.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -0,0 +1,113 @@
+/*
+ * 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.jaxws.injection;
+
+// $Id$
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceRef;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Binds a JAXWS Service object into JNDI
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 24-Oct-2006
+ */
+public class WebServiceRefDeployer
+{
+ // provide logging
+ private static Logger log = Logger.getLogger(WebServiceRefDeployer.class);
+
+ private WebServiceRefDeployer()
+ {
+ // Hide ctor
+ }
+
+ public static void setupWebServiceRef(Context ctx, String jndiName, Class refType,
WebServiceRef ref) throws Exception
+ {
+ String serviceTypeName = null;
+ String portTypeName = null;
+
+ // #1 Use the explicit @WebServiceRef.value
+ if (ref.value() != Object.class)
+ serviceTypeName = ref.value().getName();
+
+ // #2 Use the target ref type
+ if (serviceTypeName == null && refType != null &&
Service.class.isAssignableFrom(refType))
+ serviceTypeName = refType.getName();
+
+ // #3 Use javax.xml.ws.Service
+ if (serviceTypeName == null)
+ serviceTypeName = Service.class.getName();
+
+ // #1 Use the explicit @WebServiceRef.type
+ if (ref.type() != Object.class)
+ portTypeName = ref.type().getName();
+
+ // #2 Use the target ref type
+ if (portTypeName == null && refType != null &&
Service.class.isAssignableFrom(refType) == false)
+ portTypeName = refType.getName();
+
+ bind(ctx, jndiName, new ServiceReferenceable(serviceTypeName, portTypeName,
ref.wsdlLocation()));
+ log.debug("WebServiceRef bound [jndi=" + jndiName + ",service="
+ serviceTypeName + ",port=" + portTypeName + "]");
+ }
+
+ private static void bind(Context ctx, String name, Object value) throws
NamingException
+ {
+ Name n = ctx.getNameParser("").parse(name);
+ bind(ctx, n, value);
+ }
+
+ private static void bind(Context ctx, Name name, Object value) throws NamingException
+ {
+ int size = name.size();
+ String atom = name.get(size - 1);
+ Context parentCtx = createSubcontext(ctx, name.getPrefix(size - 1));
+ parentCtx.bind(atom, value);
+ }
+
+ private static Context createSubcontext(Context ctx, Name name) throws
NamingException
+ {
+ Context subctx = ctx;
+ for (int pos = 0; pos < name.size(); pos++)
+ {
+ String ctxName = name.get(pos);
+ try
+ {
+ subctx = (Context) ctx.lookup(ctxName);
+ }
+ catch (NameNotFoundException e)
+ {
+ subctx = ctx.createSubcontext(ctxName);
+ }
+ // The current subctx will be the ctx for the next name component
+ ctx = subctx;
+ }
+ return subctx;
+ }
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/jaxws/injection/WebServiceRefDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ApplicationClient.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ApplicationClient.java 2006-10-25
11:02:35 UTC (rev 1307)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ApplicationClient.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -56,14 +56,15 @@
try
{
InitialContext iniCtx = new InitialContext();
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service1")).getTestEndpointPort());
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service2")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service1")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service2")).getTestEndpointPort());
ports.add((TestEndpoint)service3.getPort(TestEndpoint.class));
- //ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/port1"));
+ ports.add((TestEndpoint)iniCtx.lookup("java:comp.ejb3/env/port1"));
ports.add(port2);
}
catch (Exception ex)
{
+ log.error("Cannot add port", ex);
throw new WebServiceException(ex);
}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/EJB3Client.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/EJB3Client.java 2006-10-25
11:02:35 UTC (rev 1307)
+++ trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/EJB3Client.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -61,14 +61,15 @@
try
{
InitialContext iniCtx = new InitialContext();
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service1")).getTestEndpointPort());
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service2")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service1")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp.ejb3/env/service2")).getTestEndpointPort());
ports.add((TestEndpoint)service3.getPort(TestEndpoint.class));
- //ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/port1"));
+ ports.add((TestEndpoint)iniCtx.lookup("java:comp.ejb3/env/port1"));
ports.add(port2);
}
catch (Exception ex)
{
+ log.error("Cannot add port", ex);
throw new WebServiceException(ex);
}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ServletClient.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ServletClient.java 2006-10-25
11:02:35 UTC (rev 1307)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/webserviceref/ServletClient.java 2006-10-25
11:55:34 UTC (rev 1308)
@@ -60,14 +60,15 @@
try
{
InitialContext iniCtx = new InitialContext();
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service1")).getTestEndpointPort());
-
//ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service2")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service1")).getTestEndpointPort());
+
ports.add(((TestEndpointService)iniCtx.lookup("java:comp/env/service2")).getTestEndpointPort());
ports.add((TestEndpoint)service3.getPort(TestEndpoint.class));
- //ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/port1"));
+ ports.add((TestEndpoint)iniCtx.lookup("java:comp/env/port1"));
ports.add(port2);
}
catch (Exception ex)
{
+ log.error("Cannot add port", ex);
throw new WebServiceException(ex);
}