Author: thomas.diesler(a)jboss.com
Date: 2007-02-05 08:45:04 -0500 (Mon, 05 Feb 2007)
New Revision: 2280
Added:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/URLLoaderAdapter.java
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandler.java
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandlerMBean.java
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedServiceRefObjectFactory.java
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
Removed:
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/UnifiedServiceRefObjectFactory.java
Modified:
branches/jbossws-1.2.0/build/etc/default.mf
branches/jbossws-1.2.0/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ResourceLoaderAdapter.java
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java
branches/jbossws-1.2.0/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt
Log:
[JBWS-1438] - Implement @WebServiceRef injection for JBossAS-4.2
Modified: branches/jbossws-1.2.0/build/etc/default.mf
===================================================================
--- branches/jbossws-1.2.0/build/etc/default.mf 2007-02-05 12:19:56 UTC (rev 2279)
+++ branches/jbossws-1.2.0/build/etc/default.mf 2007-02-05 13:45:04 UTC (rev 2280)
@@ -5,6 +5,6 @@
Specification-Vendor: @specification.vendor@
Implementation-Title: @implementation.title@
Implementation-URL: @implementation.url@
-Implementation-Version: @implementation.version@ (date=(a)build.id@)
+Implementation-Version: @implementation.version@ (build=(a)build.id@)
Implementation-Vendor: @implementation.vendor@
Implementation-Vendor-Id: @implementation.vendor.id@
Added:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/URLLoaderAdapter.java
===================================================================
---
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/URLLoaderAdapter.java
(rev 0)
+++
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/URLLoaderAdapter.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -0,0 +1,125 @@
+/*
+ * 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.jboss42;
+
+// $Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.jboss.ws.core.UnifiedVirtualFile;
+
+/**
+ * The default file adapter loads resources through an associated classloader.
+ * If no classload is set, the the thread context classloader will be used.
+ *
+ * @author Heiko.Braun(a)jboss.org
+ * @since 25.01.2007
+ */
+public class URLLoaderAdapter implements UnifiedVirtualFile
+{
+ private URL rootURL;
+ private URL resourceURL;
+ private transient URLClassLoader loader;
+
+ public URLLoaderAdapter(URL rootURL)
+ {
+ this.rootURL = rootURL;
+ }
+
+ private URLLoaderAdapter(URL rootURL, URLClassLoader loader, URL resourceURL)
+ {
+ this.rootURL = rootURL;
+ this.resourceURL = resourceURL;
+ this.loader = loader;
+ }
+
+ public UnifiedVirtualFile findChild(String resourcePath) throws IOException
+ {
+ URL resourceURL = null;
+ if (resourcePath != null)
+ {
+ // Try the child as URL
+ try
+ {
+ resourceURL = new URL(resourcePath);
+ }
+ catch (MalformedURLException ex)
+ {
+ // ignore
+ }
+
+ // Try the filename as File
+ if (resourceURL == null)
+ {
+ try
+ {
+ File file = new File(resourcePath);
+ if (file.exists())
+ resourceURL = file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ // Try the filename as Resource
+ if (resourceURL == null)
+ {
+ try
+ {
+ resourceURL = getResourceLoader().getResource(resourcePath);
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ }
+
+ if (resourceURL == null)
+ throw new IOException("Cannot get URL for: " + resourcePath);
+
+ return new URLLoaderAdapter(rootURL, loader, resourceURL);
+ }
+
+ public URL toURL()
+ {
+ if (null == this.resourceURL)
+ throw new IllegalStateException("UnifiedVirtualFile not
initialized");
+ return resourceURL;
+ }
+
+ private URLClassLoader getResourceLoader()
+ {
+ if (loader == null)
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ loader = new URLClassLoader(new URL[]{rootURL}, ctxLoader);
+ }
+ return loader;
+ }
+}
Property changes on:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/URLLoaderAdapter.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandler.java
===================================================================
---
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandler.java
(rev 0)
+++
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandler.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -0,0 +1,63 @@
+/*
+ * 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.jboss42;
+
+// $Id$
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.transform.Source;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.ws.core.jaxws.UnifiedWebServiceRefHandler;
+
+/**
+ * Binds a JAXWS @WebServiceRef object in the client's ENC
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 17-Jan-2007
+ */
+public class WebServiceRefHandler extends UnifiedWebServiceRefHandler implements
WebServiceRefHandlerMBean
+{
+ public void setupWebServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, URL rootURL, Source metadata) throws NamingException
+ {
+ setupWebServiceRef(encCtx, encName, anElement, new URLLoaderAdapter(rootURL),
metadata);
+ }
+
+ public void create() throws Exception
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ if (server != null)
+ server.registerMBean(this, OBJECT_NAME);
+ }
+
+ public void destroy() throws Exception
+ {
+ MBeanServer server = MBeanServerLocator.locateJBoss();
+ if (server != null)
+ server.unregisterMBean(OBJECT_NAME);
+ }
+}
Property changes on:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandlerMBean.java
===================================================================
---
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandlerMBean.java
(rev 0)
+++
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandlerMBean.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -0,0 +1,46 @@
+/*
+* 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.jboss42;
+
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.transform.Source;
+
+import org.jboss.ws.core.utils.ObjectNameFactory;
+
+/**
+ * MBean interface.
+ */
+public interface WebServiceRefHandlerMBean
+{
+ // default object name
+ public static final ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=WebServiceRefHandler");
+
+ /** Binds a JAXWS WebServiceRef into the callers ENC
+ */
+ void setupWebServiceRef(Context encCtx, String encName, AnnotatedElement enElement,
URL rootURL, Source metadata) throws NamingException;
+}
Property changes on:
branches/jbossws-1.2.0/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/WebServiceRefHandlerMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/jbossws-1.2.0/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
---
branches/jbossws-1.2.0/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/integration-jboss42/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2007-02-05
13:45:04 UTC (rev 2280)
@@ -36,6 +36,9 @@
<property
name="serviceEndpointServlet">org.jboss.ws.integration.jboss42.JBossServiceEndpointServlet</property>
</bean>
+ <!-- Bind JAXWS Service objects in client environment context -->
+ <bean name="WebServiceRefHandler"
class="org.jboss.ws.integration.jboss42.WebServiceRefHandler"/>
+
<!-- A subscription manager for WS-Eventing -->
<bean name="SubscriptionManager"
class="org.jboss.ws.extensions.eventing.mgmt.SubscriptionManager"/>
Deleted:
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/UnifiedServiceRefObjectFactory.java
===================================================================
---
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/UnifiedServiceRefObjectFactory.java 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/UnifiedServiceRefObjectFactory.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -1,187 +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.jboss50;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
-
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.jaxws.client.NameValuePair;
-import org.jboss.ws.core.jaxws.client.PortInfo;
-import org.jboss.ws.core.jaxws.client.UnifiedServiceRef;
-import org.jboss.xb.binding.ObjectModelFactory;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
-import org.jboss.xb.binding.UnmarshallingContext;
-import org.xml.sax.Attributes;
-
-/**
- * An ObjectModelFactory for UnifiedServiceRef
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 17-Jan-2007
- */
-public class UnifiedServiceRefObjectFactory implements ObjectModelFactory
-{
- // Hide constructor
- private UnifiedServiceRefObjectFactory()
- {
- }
-
- public static UnifiedServiceRefObjectFactory newInstance()
- {
- return new UnifiedServiceRefObjectFactory();
- }
-
- public UnifiedServiceRef parse(Source source)
- {
- // setup the XML binding Unmarshaller
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- StreamResult result = new StreamResult(baos);
- TransformerFactory tf = TransformerFactory.newInstance();
- tf.newTransformer().transform(source, result);
-
- InputStream is = new ByteArrayInputStream(baos.toByteArray());
-
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
- return (UnifiedServiceRef)unmarshaller.unmarshal(is, this, null);
- }
- catch (Exception ex)
- {
- WSException.rethrow(ex);
- return null;
- }
- }
-
- /**
- * This method is called on the factory by the object model builder when the parsing
starts.
- */
- public Object newRoot(Object root, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
- {
- return new UnifiedServiceRef();
- }
-
- public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String
name)
- {
- return root;
- }
-
- public void setValue(UnifiedServiceRef ref, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
- {
- if (localName.equals("service-ref-name"))
- {
- ref.setServiceRefName(value);
- }
- else if (localName.equals("service-class-name"))
- {
- ref.setServiceClassName(value);
- }
- else if (localName.equals("service-qname"))
- {
- ref.setServiceQName(QName.valueOf(value));
- }
- else if (localName.equals("config-name"))
- {
- ref.setConfigName(value);
- }
- else if (localName.equals("config-file"))
- {
- ref.setConfigFile(value);
- }
- else if (localName.equals("handler-chain"))
- {
- ref.setHandlerChain(value);
- }
- else if (localName.equals("wsdl-override"))
- {
- ref.setWsdlLocation(value);
- }
- }
-
- public Object newChild(UnifiedServiceRef parent, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
-
- if (localName.equals("port-info"))
- child = new PortInfo(parent);
-
- return child;
- }
-
- public void addChild(UnifiedServiceRef parent, PortInfo portInfo, UnmarshallingContext
navigator, String namespaceURI, String localName)
- {
- parent.getPortInfos().add(portInfo);
- }
-
- public void setValue(PortInfo portInfo, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
- {
- if (localName.equals("service-endpoint-interface"))
- {
- portInfo.setServiceEndpointInterface(value);
- }
- else if (localName.equals("port-qname"))
- {
- portInfo.setPortQName(QName.valueOf(value));
- }
- else if (localName.equals("config-name"))
- {
- portInfo.setConfigName(value);
- }
- else if (localName.equals("config-file"))
- {
- portInfo.setConfigFile(value);
- }
- }
-
- public Object newChild(PortInfo portInfo, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
- {
- Object child = null;
- if (localName.equals("stub-property"))
- child = new NameValuePair();
- return child;
- }
-
- public void addChild(PortInfo parent, NameValuePair stubProp, UnmarshallingContext
navigator, String namespaceURI, String localName)
- {
- parent.getStubProperties().add(stubProp);
- }
-
- public void setValue(NameValuePair nvPair, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
- {
- if (localName.equals("name"))
- {
- nvPair.setName(value);
- }
- else if (localName.equals("value"))
- {
- nvPair.setValue(value);
- }
- }
-}
Modified:
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
===================================================================
---
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -23,171 +23,30 @@
// $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.management.MBeanServer;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.xml.transform.Source;
-import javax.xml.ws.Service;
-import javax.xml.ws.WebServiceRef;
-import javax.xml.ws.WebServiceRefs;
-import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.util.naming.Util;
import org.jboss.virtual.VirtualFile;
-import org.jboss.ws.WSException;
-import org.jboss.ws.core.jaxws.client.ServiceReferenceable;
-import org.jboss.ws.core.jaxws.client.UnifiedServiceRef;
+import org.jboss.ws.core.jaxws.UnifiedWebServiceRefHandler;
/**
- * Binds a JAXWS Service object in the client's ENC
+ * Binds a JAXWS @WebServiceRef object in the client's ENC
*
* @author Thomas.Diesler(a)jboss.org
* @since 17-Jan-2007
*/
-public class WebServiceRefHandler implements WebServiceRefHandlerMBean
+public class WebServiceRefHandler extends UnifiedWebServiceRefHandler implements
WebServiceRefHandlerMBean
{
- // logging support
- private static Logger log = Logger.getLogger(WebServiceRefHandler.class);
-
public void setupWebServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, VirtualFile vfsRoot, Source metadata) throws NamingException
{
- WebServiceRef wsref = null;
-
- // Build the list of @WebServiceRef relevant annotations
- List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
- 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;
- }
- }
- }
-
- if (wsref == null)
- throw new IllegalArgumentException("@WebServiceRef must be present on:
" + anElement);
-
- Class targetClass = null;
- if (anElement instanceof Field)
- targetClass = ((Field)anElement).getType();
- else if (anElement instanceof Method)
- targetClass = ((Method)anElement).getParameterTypes()[0];
-
- String externalName = encCtx.getNameInNamespace() + "/" + encName;
- String targetClassName = (targetClass != null ? targetClass.getName() : null);
- log.debug("setupWebServiceRef [jndi=" + externalName +
",target=" + targetClassName + "]");
-
- String serviceClassName = null;
-
- // #1 Use the explicit @WebServiceRef.value
- if (wsref.value() != Object.class)
- serviceClassName = wsref.value().getName();
-
- // #2 Use the target ref type
- if (serviceClassName == null && targetClass != null &&
Service.class.isAssignableFrom(targetClass))
- serviceClassName = targetClass.getName();
-
- // #3 Use javax.xml.ws.Service
- if (serviceClassName == null)
- serviceClassName = Service.class.getName();
-
- // #1 Use the explicit @WebServiceRef.type
- if (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();
-
- try
- {
- UnifiedServiceRefObjectFactory factory =
UnifiedServiceRefObjectFactory.newInstance();
- UnifiedServiceRef usRef = factory.parse(metadata);
- usRef.setRootFile(new VirtualFileAdaptor(vfsRoot));
-
- // Set the wsdlLocation if there is no override already
- if (usRef.getWsdlLocation() == null && wsref.wsdlLocation().length()
> 0)
- usRef.setWsdlLocation(wsref.wsdlLocation());
-
- // Set the handlerChain from @HandlerChain on the annotated element
- String handlerChain = usRef.getHandlerChain();
- 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;
- VirtualFile vfHandlerChain = vfsRoot.findChild(handlerChain);
- if (vfHandlerChain == null)
- throw new IllegalStateException("Cannot find handler chain: "
+ handlerChain);
- }
- usRef.setHandlerChain(handlerChain);
- }
-
- // Do not use rebind, the binding should be unique
- // [JBWS-1499] - Revisit WebServiceRefHandler JNDI rebind
- Util.rebind(encCtx, encName, new ServiceReferenceable(serviceClassName,
targetClassName, usRef));
-
- log.debug("<service-ref> bound to: java:comp/env/" + encName);
- }
- catch (RuntimeException rte)
- {
- throw rte;
- }
- catch (Exception ex)
- {
- throw new WSException("Cannot bind web service ref: " + encName, ex);
- }
+ setupWebServiceRef(encCtx, encName, anElement, new VirtualFileAdaptor(vfsRoot),
metadata);
}
-
+
public void create() throws Exception
{
MBeanServer server = MBeanServerLocator.locateJBoss();
Copied:
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedServiceRefObjectFactory.java
(from rev 2273,
branches/jbossws-1.2.0/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/UnifiedServiceRefObjectFactory.java)
===================================================================
---
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedServiceRefObjectFactory.java
(rev 0)
+++
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedServiceRefObjectFactory.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -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.ws.core.jaxws;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.jaxws.client.NameValuePair;
+import org.jboss.ws.core.jaxws.client.PortInfo;
+import org.jboss.ws.core.jaxws.client.UnifiedServiceRef;
+import org.jboss.xb.binding.ObjectModelFactory;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.UnmarshallingContext;
+import org.xml.sax.Attributes;
+
+/**
+ * An ObjectModelFactory for UnifiedServiceRef
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 17-Jan-2007
+ */
+public class UnifiedServiceRefObjectFactory implements ObjectModelFactory
+{
+ // Hide constructor
+ private UnifiedServiceRefObjectFactory()
+ {
+ }
+
+ public static UnifiedServiceRefObjectFactory newInstance()
+ {
+ return new UnifiedServiceRefObjectFactory();
+ }
+
+ public UnifiedServiceRef parse(Source source)
+ {
+ // setup the XML binding Unmarshaller
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ StreamResult result = new StreamResult(baos);
+ TransformerFactory tf = TransformerFactory.newInstance();
+ tf.newTransformer().transform(source, result);
+
+ InputStream is = new ByteArrayInputStream(baos.toByteArray());
+
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ return (UnifiedServiceRef)unmarshaller.unmarshal(is, this, null);
+ }
+ catch (Exception ex)
+ {
+ WSException.rethrow(ex);
+ return null;
+ }
+ }
+
+ /**
+ * This method is called on the factory by the object model builder when the parsing
starts.
+ */
+ public Object newRoot(Object root, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
+ {
+ return new UnifiedServiceRef();
+ }
+
+ public Object completeRoot(Object root, UnmarshallingContext ctx, String uri, String
name)
+ {
+ return root;
+ }
+
+ public void setValue(UnifiedServiceRef ref, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
+ {
+ if (localName.equals("service-ref-name"))
+ {
+ ref.setServiceRefName(value);
+ }
+ else if (localName.equals("service-class-name"))
+ {
+ ref.setServiceClassName(value);
+ }
+ else if (localName.equals("service-qname"))
+ {
+ ref.setServiceQName(QName.valueOf(value));
+ }
+ else if (localName.equals("config-name"))
+ {
+ ref.setConfigName(value);
+ }
+ else if (localName.equals("config-file"))
+ {
+ ref.setConfigFile(value);
+ }
+ else if (localName.equals("handler-chain"))
+ {
+ ref.setHandlerChain(value);
+ }
+ else if (localName.equals("wsdl-override"))
+ {
+ ref.setWsdlLocation(value);
+ }
+ }
+
+ public Object newChild(UnifiedServiceRef parent, UnmarshallingContext navigator,
String namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+
+ if (localName.equals("port-info"))
+ child = new PortInfo(parent);
+
+ return child;
+ }
+
+ public void addChild(UnifiedServiceRef parent, PortInfo portInfo, UnmarshallingContext
navigator, String namespaceURI, String localName)
+ {
+ parent.getPortInfos().add(portInfo);
+ }
+
+ public void setValue(PortInfo portInfo, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
+ {
+ if (localName.equals("service-endpoint-interface"))
+ {
+ portInfo.setServiceEndpointInterface(value);
+ }
+ else if (localName.equals("port-qname"))
+ {
+ portInfo.setPortQName(QName.valueOf(value));
+ }
+ else if (localName.equals("config-name"))
+ {
+ portInfo.setConfigName(value);
+ }
+ else if (localName.equals("config-file"))
+ {
+ portInfo.setConfigFile(value);
+ }
+ }
+
+ public Object newChild(PortInfo portInfo, UnmarshallingContext navigator, String
namespaceURI, String localName, Attributes attrs)
+ {
+ Object child = null;
+ if (localName.equals("stub-property"))
+ child = new NameValuePair();
+ return child;
+ }
+
+ public void addChild(PortInfo parent, NameValuePair stubProp, UnmarshallingContext
navigator, String namespaceURI, String localName)
+ {
+ parent.getStubProperties().add(stubProp);
+ }
+
+ public void setValue(NameValuePair nvPair, UnmarshallingContext navigator, String
namespaceURI, String localName, String value)
+ {
+ if (localName.equals("name"))
+ {
+ nvPair.setName(value);
+ }
+ else if (localName.equals("value"))
+ {
+ nvPair.setValue(value);
+ }
+ }
+}
Added:
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
===================================================================
---
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
(rev 0)
+++
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -0,0 +1,188 @@
+/*
+ * 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;
+
+// $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.xml.transform.Source;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceRef;
+import javax.xml.ws.WebServiceRefs;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.UnifiedVirtualFile;
+import org.jboss.ws.core.jaxws.client.ServiceReferenceable;
+import org.jboss.ws.core.jaxws.client.UnifiedServiceRef;
+
+/**
+ * Binds a JAXWS Service object in the client's ENC
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 17-Jan-2007
+ */
+public class UnifiedWebServiceRefHandler
+{
+ // logging support
+ private static Logger log = Logger.getLogger(UnifiedWebServiceRefHandler.class);
+
+ protected void setupWebServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, UnifiedVirtualFile vfsRoot, Source metadata) throws NamingException
+ {
+ WebServiceRef wsref = null;
+
+ // Build the list of @WebServiceRef relevant annotations
+ List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
+ 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;
+ }
+ }
+ }
+
+ if (wsref == null)
+ throw new IllegalArgumentException("@WebServiceRef must be present on:
" + anElement);
+
+ Class targetClass = null;
+ if (anElement instanceof Field)
+ targetClass = ((Field)anElement).getType();
+ else if (anElement instanceof Method)
+ targetClass = ((Method)anElement).getParameterTypes()[0];
+
+ String externalName = encCtx.getNameInNamespace() + "/" + encName;
+ String targetClassName = (targetClass != null ? targetClass.getName() : null);
+ log.debug("setupWebServiceRef [jndi=" + externalName +
",target=" + targetClassName + "]");
+
+ String serviceClassName = null;
+
+ // #1 Use the explicit @WebServiceRef.value
+ if (wsref.value() != Object.class)
+ serviceClassName = wsref.value().getName();
+
+ // #2 Use the target ref type
+ if (serviceClassName == null && targetClass != null &&
Service.class.isAssignableFrom(targetClass))
+ serviceClassName = targetClass.getName();
+
+ // #3 Use javax.xml.ws.Service
+ if (serviceClassName == null)
+ serviceClassName = Service.class.getName();
+
+ // #1 Use the explicit @WebServiceRef.type
+ if (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();
+
+ try
+ {
+ UnifiedServiceRefObjectFactory factory =
UnifiedServiceRefObjectFactory.newInstance();
+ UnifiedServiceRef usRef = factory.parse(metadata);
+ usRef.setRootFile(vfsRoot);
+
+ // Set the wsdlLocation if there is no override already
+ if (usRef.getWsdlLocation() == null && wsref.wsdlLocation().length()
> 0)
+ usRef.setWsdlLocation(wsref.wsdlLocation());
+
+ // Set the handlerChain from @HandlerChain on the annotated element
+ String handlerChain = usRef.getHandlerChain();
+ 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;
+ UnifiedVirtualFile vfHandlerChain = vfsRoot.findChild(handlerChain);
+ if (vfHandlerChain == null)
+ throw new IllegalStateException("Cannot find handler chain: "
+ handlerChain);
+ }
+ usRef.setHandlerChain(handlerChain);
+ }
+
+ // Do not use rebind, the binding should be unique
+ // [JBWS-1499] - Revisit WebServiceRefHandler JNDI rebind
+ Util.rebind(encCtx, encName, new ServiceReferenceable(serviceClassName,
targetClassName, usRef));
+
+ log.debug("<service-ref> bound to: java:comp/env/" + encName);
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new WSException("Cannot bind web service ref: " + encName, ex);
+ }
+ }
+}
Property changes on:
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ResourceLoaderAdapter.java
===================================================================
---
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ResourceLoaderAdapter.java 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/jbossws-core/src/main/java/org/jboss/ws/metadata/umdm/ResourceLoaderAdapter.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -39,7 +39,7 @@
*/
public class ResourceLoaderAdapter implements UnifiedVirtualFile
{
- private URL location;
+ private URL resourceURL;
private ClassLoader loader;
public ResourceLoaderAdapter()
@@ -52,9 +52,9 @@
this.loader = loader;
}
- private ResourceLoaderAdapter(ClassLoader loader, URL location)
+ private ResourceLoaderAdapter(ClassLoader loader, URL resourceURL)
{
- this.location = location;
+ this.resourceURL = resourceURL;
this.loader = loader;
}
@@ -110,13 +110,8 @@
public URL toURL()
{
- if (null == this.location)
+ if (null == this.resourceURL)
throw new IllegalStateException("UnifiedVirtualFile not
initialized");
- return location;
+ return resourceURL;
}
-
- public ClassLoader getResourceLoader()
- {
- return loader;
- }
}
Modified:
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java
===================================================================
---
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefEJB3TestCase.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -72,12 +72,6 @@
public void testEJB3Client() throws Exception
{
- if (isTargetJBoss50() == false)
- {
- System.out.println("FIXME: [JBWS-1438] Implement @WebServiceRef injection
for JBossAS-4.2");
- return;
- }
-
deploy("jaxws-samples-webserviceref-ejb3-client.jar");
try
{
Modified:
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java
===================================================================
---
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/samples/webserviceref/WebServiceRefServletTestCase.java 2007-02-05
13:45:04 UTC (rev 2280)
@@ -73,12 +73,6 @@
public void testServletClient() throws Exception
{
- if (isTargetJBoss50() == false)
- {
- System.out.println("FIXME: [JBWS-1438] Implement @WebServiceRef injection
for JBossAS-4.2");
- return;
- }
-
deploy("jaxws-samples-webserviceref-servlet-client.war");
try
{
Modified:
branches/jbossws-1.2.0/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt
===================================================================
---
branches/jbossws-1.2.0/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt 2007-02-05
12:19:56 UTC (rev 2279)
+++
branches/jbossws-1.2.0/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt 2007-02-05
13:45:04 UTC (rev 2280)
@@ -5,6 +5,5 @@
# EJB3/Injection excludes
org/jboss/test/ws/jaxws/endpoint/**
-org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase*
-org/jboss/test/ws/jaxws/samples/retail/**
+org/jboss/test/ws/jaxws/samples/handlerchain/HandlerChainClientTestCase.*
org/jboss/test/ws/jaxws/samples/webserviceref/**