Author: thomas.diesler(a)jboss.com
Date: 2007-03-06 18:07:01 -0500 (Tue, 06 Mar 2007)
New Revision: 2538
Added:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
Removed:
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
Modified:
branches/tdiesler/trunk/build/build.xml
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/ServiceRefHandler.java
branches/tdiesler/trunk/integration-jboss50/src/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactory.java
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceReferenceable.java
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/metadata/j2ee/serviceref/ServiceRefMetaData.java
Log:
partial
Modified: branches/tdiesler/trunk/build/build.xml
===================================================================
--- branches/tdiesler/trunk/build/build.xml 2007-03-06 21:33:39 UTC (rev 2537)
+++ branches/tdiesler/trunk/build/build.xml 2007-03-06 23:07:01 UTC (rev 2538)
@@ -48,7 +48,7 @@
<ant antfile="${integration.jboss42.dir}/build.xml"
target="clean" inheritall="false"/>
<ant antfile="${integration.jboss50.dir}/build.xml"
target="clean" inheritall="false"/>
<ant antfile="${integration.tomcat.dir}/build.xml"
target="clean" inheritall="false"/>
- <ant antfile="${tests.dir}/build.xml" target="clean"
inheritall="false"/>
+ <!--ant antfile="${tests.dir}/build.xml" target="clean"
inheritall="false"/-->
</target>
<target name="main" description="Executes the default target
(most)." depends="most">
Modified:
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/ServiceRefHandler.java
===================================================================
---
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/ServiceRefHandler.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/ServiceRefHandler.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -23,25 +23,23 @@
// $Id$
+import java.io.IOException;
import java.lang.reflect.AnnotatedElement;
-import java.net.URL;
import javax.management.MBeanServer;
import javax.naming.Context;
import javax.naming.NamingException;
-import javax.wsdl.Definition;
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.jaxrpc.client.ServiceReferenceable;
+import org.jboss.ws.core.jaxrpc.client.ServiceRefHandlerJAXRPC;
+import org.jboss.ws.core.jaxws.client.ServiceRefHandlerJAXWS;
+import org.jboss.ws.core.utils.DOMUtils;
+import org.jboss.ws.core.utils.DOMWriter;
import org.jboss.ws.metadata.j2ee.serviceref.ServiceRefMetaData;
import org.jboss.ws.metadata.j2ee.serviceref.ServiceRefObjectFactory;
-import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
-import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMappingFactory;
-import org.jboss.ws.tools.wsdl.WSDL11DefinitionFactory;
+import org.w3c.dom.Element;
/**
* Binds a JAXRPC Service object in the client's ENC for every service-ref element in
the
@@ -62,74 +60,34 @@
{
try
{
- ServiceRefObjectFactory factory = ServiceRefObjectFactory.newInstance();
- ServiceRefMetaData serviceRef = factory.parse(xmlFragment);
- serviceRef.setVfsRoot(new VirtualFileAdaptor(vfsRoot));
-
- String serviceRefName = serviceRef.getServiceRefName();
-
- JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
- serviceRef.setJavaWsdlMapping(javaWsdlMapping);
-
- Definition wsdlDefinition = getWsdlDefinition(serviceRef);
- serviceRef.setWsdlDefinition(wsdlDefinition);
-
- ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
-
- // Do not use rebind, the binding should be unique
- Util.bind(encCtx, encName, ref);
-
- log.debug("<service-ref> bound to: java:comp/env/" +
serviceRefName);
+ Element root = DOMUtils.parse(xmlFragment);
+ if (log.isDebugEnabled())
+ log.info(DOMWriter.printNode(root, true));
}
- catch (RuntimeException rte)
+ catch (IOException e)
{
- throw rte;
+ log.error("Invalid service-ref: " + xmlFragment);
}
- catch (Exception ex)
+
+ ServiceRefObjectFactory factory = ServiceRefObjectFactory.newInstance();
+ ServiceRefMetaData serviceRef = factory.parse(xmlFragment);
+ serviceRef.setVfsRoot(new VirtualFileAdaptor(vfsRoot));
+
+ if (isServiceRefJaxRpc(serviceRef))
{
- throw new WSException("Cannot bind webservice to client environment",
ex);
+ ServiceRefHandlerJAXRPC handler = new ServiceRefHandlerJAXRPC();
+ handler.setupServiceRef(encCtx, encName, serviceRef);
}
- }
-
- private JavaWsdlMapping getJavaWsdlMapping(ServiceRefMetaData serviceRef)
- {
- JavaWsdlMapping javaWsdlMapping = null;
- if (serviceRef.getMappingFile() != null)
+ else
{
- String mappingFile = serviceRef.getMappingFile();
- try
- {
- JavaWsdlMappingFactory mappingFactory =
JavaWsdlMappingFactory.newInstance();
- URL mappingURL = serviceRef.getVfsRoot().findChild(mappingFile).toURL();
- javaWsdlMapping = mappingFactory.parse(mappingURL);
- }
- catch (Exception e)
- {
- throw new WSException("Cannot unmarshal jaxrpc-mapping-file: " +
mappingFile, e);
- }
+ ServiceRefHandlerJAXWS handler = new ServiceRefHandlerJAXWS();
+ handler.setupServiceRef(encCtx, encName, anElement, serviceRef);
}
- return javaWsdlMapping;
}
- private Definition getWsdlDefinition(ServiceRefMetaData serviceRef)
+ private boolean isServiceRefJaxRpc(ServiceRefMetaData serviceRef)
{
- Definition wsdlDefinition = null;
- {
- URL wsdlLocation = serviceRef.getWsdlLocation();
- if (wsdlLocation != null)
- {
- try
- {
- WSDL11DefinitionFactory factory = WSDL11DefinitionFactory.newInstance();
- wsdlDefinition = factory.parse(wsdlLocation);
- }
- catch (Exception e)
- {
- throw new WSException("Cannot unmarshall wsdl-file: " +
wsdlLocation, e);
- }
- }
- }
- return wsdlDefinition;
+ return false;
}
public void create() throws Exception
Deleted:
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
===================================================================
---
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -1,62 +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;
-
-// $Id$
-
-import java.lang.reflect.AnnotatedElement;
-
-import javax.management.MBeanServer;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.mx.util.MBeanServerLocator;
-import org.jboss.virtual.VirtualFile;
-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 setupServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, VirtualFile vfsRoot, String xmlFragment) throws NamingException
- {
- setupServiceRef(encCtx, encName, anElement, new VirtualFileAdaptor(vfsRoot),
xmlFragment);
- }
-
- 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);
- }
-}
Deleted:
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java
===================================================================
---
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/integration-jboss50/src/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -1,45 +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.lang.reflect.AnnotatedElement;
-
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.virtual.VirtualFile;
-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=ServiceRefHandler");
-
- /** Binds a JAXWS WebServiceRef into the callers ENC
- */
- void setupServiceRef(Context encCtx, String encName, AnnotatedElement enElement,
VirtualFile vfsRoot, String xmlFragment) throws NamingException;
-}
Modified:
branches/tdiesler/trunk/integration-jboss50/src/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml
===================================================================
---
branches/tdiesler/trunk/integration-jboss50/src/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/integration-jboss50/src/resources/jbossws.deployer/META-INF/jbossws-deployer-beans.xml 2007-03-06
23:07:01 UTC (rev 2538)
@@ -48,7 +48,7 @@
</bean>
<!-- Bind Service objects in client environment context -->
- <bean name="ServiceRefHandler"
class="org.jboss.ws.integration.jboss50.WebServiceRefHandler"/>
+ <bean name="ServiceRefHandler"
class="org.jboss.ws.integration.jboss50.ServiceRefHandler"/>
<!-- A subscription manager for WS-Eventing -->
<bean name="SubscriptionManager"
class="org.jboss.ws.extensions.eventing.mgmt.SubscriptionManager"/>
Modified:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactory.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactory.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceObjectFactory.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -45,6 +45,7 @@
import javax.naming.RefAddr;
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
+import javax.wsdl.Definition;
import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.Service;
@@ -59,9 +60,11 @@
import org.jboss.ws.metadata.j2ee.serviceref.PortComponentRefMetaData;
import org.jboss.ws.metadata.j2ee.serviceref.ServiceRefMetaData;
import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
+import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMappingFactory;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.ServiceMetaData;
import org.jboss.ws.metadata.wsse.WSSecurityConfiguration;
+import org.jboss.ws.tools.wsdl.WSDL11DefinitionFactory;
/**
* This ServiceObjectFactory reconstructs a javax.xml.rpc.Service
@@ -104,13 +107,13 @@
Reference ref = (Reference)obj;
// Unmarshall the ServiceRefMetaData
- ServiceRefMetaData serviceRefMetaData = null;
+ ServiceRefMetaData serviceRef = null;
RefAddr metaRefAddr = ref.get(ServiceReferenceable.SERVICE_REF_META_DATA);
ByteArrayInputStream bais = new
ByteArrayInputStream((byte[])metaRefAddr.getContent());
try
{
ObjectInputStream ois = new ObjectInputStream(bais);
- serviceRefMetaData = (ServiceRefMetaData)ois.readObject();
+ serviceRef = (ServiceRefMetaData)ois.readObject();
ois.close();
}
catch (IOException ex)
@@ -139,15 +142,15 @@
}
ServiceImpl jaxrpcService = null;
- URL wsdlLocation = serviceRefMetaData.getWsdlLocation();
+ URL wsdlLocation = serviceRef.getWsdlLocation();
if (wsdlLocation != null)
{
if(log.isDebugEnabled()) log.debug("Create jaxrpc service from
wsdl");
// Create the actual service object
- QName serviceName = serviceRefMetaData.getServiceQName();
- JavaWsdlMapping javaWsdlMapping =
(JavaWsdlMapping)serviceRefMetaData.getJavaWsdlMapping();
- jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping,
securityConfig, serviceRefMetaData);
+ QName serviceName = serviceRef.getServiceQName();
+ JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(serviceRef);
+ jaxrpcService = new ServiceImpl(serviceName, wsdlLocation, javaWsdlMapping,
securityConfig, serviceRef);
}
else
{
@@ -158,11 +161,11 @@
ServiceMetaData serviceMetaData = jaxrpcService.getServiceMetaData();
// Set any service level properties
- if (serviceRefMetaData.getCallProperties().size() > 0)
+ if (serviceRef.getCallProperties().size() > 0)
{
Properties callProps = new Properties();
serviceMetaData.setProperties(callProps);
- for (CallPropertyMetaData prop : serviceRefMetaData.getCallProperties())
+ for (CallPropertyMetaData prop : serviceRef.getCallProperties())
callProps.setProperty(prop.getPropName(), prop.getPropValue());
}
@@ -220,12 +223,12 @@
// load the service interface class
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
- Class siClass = contextCL.loadClass(serviceRefMetaData.getServiceInterface());
+ Class siClass = contextCL.loadClass(serviceRef.getServiceInterface());
if (Service.class.isAssignableFrom(siClass) == false)
throw new JAXRPCException("The service interface does not implement
javax.xml.rpc.Service: " + siClass.getName());
// load all service endpoint interface classes
- for (PortComponentRefMetaData pcr : serviceRefMetaData.getPortComponentRefs())
+ for (PortComponentRefMetaData pcr : serviceRef.getPortComponentRefs())
{
Class seiClass = contextCL.loadClass(pcr.getServiceEndpointInterface());
if (Remote.class.isAssignableFrom(seiClass) == false)
@@ -256,4 +259,45 @@
jaxrpcService.setupHandlerChain(epMetaData);
}
}
+
+ private JavaWsdlMapping getJavaWsdlMapping(ServiceRefMetaData serviceRef)
+ {
+ JavaWsdlMapping javaWsdlMapping = null;
+ if (serviceRef.getMappingFile() != null)
+ {
+ String mappingFile = serviceRef.getMappingFile();
+ try
+ {
+ JavaWsdlMappingFactory mappingFactory =
JavaWsdlMappingFactory.newInstance();
+ URL mappingURL = serviceRef.getVfsRoot().findChild(mappingFile).toURL();
+ javaWsdlMapping = mappingFactory.parse(mappingURL);
+ }
+ catch (Exception e)
+ {
+ throw new WSException("Cannot unmarshal jaxrpc-mapping-file: " +
mappingFile, e);
+ }
+ }
+ return javaWsdlMapping;
+ }
+
+ private Definition getWsdlDefinition(ServiceRefMetaData serviceRef)
+ {
+ Definition wsdlDefinition = null;
+ {
+ URL wsdlLocation = serviceRef.getWsdlLocation();
+ if (wsdlLocation != null)
+ {
+ try
+ {
+ WSDL11DefinitionFactory factory = WSDL11DefinitionFactory.newInstance();
+ wsdlDefinition = factory.parse(wsdlLocation);
+ }
+ catch (Exception e)
+ {
+ throw new WSException("Cannot unmarshall wsdl-file: " +
wsdlLocation, e);
+ }
+ }
+ }
+ return wsdlDefinition;
+ }
}
Added:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
(rev 0)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.jaxrpc.client;
+
+// $Id$
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+import org.jboss.ws.metadata.j2ee.serviceref.ServiceRefMetaData;
+
+/**
+ * Binds a JAXRPC Service object in the client's ENC for every service-ref element in
the
+ * deployment descriptor.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 04-Nov-2006
+ */
+public class ServiceRefHandlerJAXRPC
+{
+ // logging support
+ private static Logger log = Logger.getLogger(ServiceRefHandlerJAXRPC.class);
+
+ /**
+ * Binds a Service into the callers ENC for every service-ref element
+ */
+ public void setupServiceRef(Context encCtx, String encName, ServiceRefMetaData
serviceRef) throws NamingException
+ {
+ String serviceRefName = serviceRef.getServiceRefName();
+ ServiceReferenceable ref = new ServiceReferenceable(serviceRef);
+
+ // Do not use rebind, the binding should be unique
+ Util.bind(encCtx, encName, ref);
+
+ log.debug("<service-ref> bound to: java:comp/env/" +
serviceRefName);
+ }
+}
Property changes on:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceRefHandlerJAXRPC.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceReferenceable.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceReferenceable.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxrpc/client/ServiceReferenceable.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -123,8 +123,6 @@
*/
private byte[] marshallServiceRef() throws NamingException
{
- refMetaData.getJavaWsdlMapping();
-
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
try
{
Deleted:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/UnifiedWebServiceRefHandler.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -1,200 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ws.core.jaxws;
-
-// $Id$
-
-import java.io.IOException;
-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.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.metadata.j2ee.serviceref.ServiceRefMetaData;
-import org.jboss.ws.metadata.j2ee.serviceref.ServiceRefObjectFactory;
-
-/**
- * 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 setupServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, UnifiedVirtualFile vfsRoot, String xmlFragment) 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
- {
- ServiceRefObjectFactory factory = ServiceRefObjectFactory.newInstance();
- ServiceRefMetaData usRef = factory.parse(xmlFragment);
- usRef.setVfsRoot(vfsRoot);
-
- // Set the wsdlLocation if there is no override already
- if (usRef.getWsdlLocation() == null && wsref.wsdlLocation().length()
> 0)
- usRef.setWsdlLocation(new URL(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;
- }
-
- 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);
- }
- }
-
- private boolean findHandlerChain(UnifiedVirtualFile vfsRoot, String handlerChain)
- {
- try
- {
- vfsRoot.findChild(handlerChain);
- return true;
- }
- catch (IOException io)
- {
- return false;
- }
- }
-}
Added:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
(rev 0)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.core.jaxws.client;
+
+// $Id$
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jws.HandlerChain;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.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.metadata.j2ee.serviceref.ServiceRefMetaData;
+
+/**
+ * Binds a JAXWS Service object in the client's ENC
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 17-Jan-2007
+ */
+public class ServiceRefHandlerJAXWS
+{
+ // logging support
+ private static Logger log = Logger.getLogger(ServiceRefHandlerJAXWS.class);
+
+ public void setupServiceRef(Context encCtx, String encName, AnnotatedElement
anElement, ServiceRefMetaData serviceRef) 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();
+
+ // Set the wsdlLocation if there is no override already
+ if (serviceRef.getWsdlOverride() == null && wsref.wsdlLocation().length()
> 0)
+ serviceRef.setWsdlFile(wsref.wsdlLocation());
+
+ // Set the handlerChain from @HandlerChain on the annotated element
+ String handlerChain = serviceRef.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;
+ }
+
+ serviceRef.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, serviceRef));
+
+ log.debug("<service-ref> bound to: java:comp/env/" + encName);
+ }
+}
Property changes on:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/core/jaxws/client/ServiceRefHandlerJAXWS.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/metadata/j2ee/serviceref/ServiceRefMetaData.java
===================================================================
---
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/metadata/j2ee/serviceref/ServiceRefMetaData.java 2007-03-06
21:33:39 UTC (rev 2537)
+++
branches/tdiesler/trunk/jbossws-core/src/java/org/jboss/ws/metadata/j2ee/serviceref/ServiceRefMetaData.java 2007-03-06
23:07:01 UTC (rev 2538)
@@ -32,14 +32,11 @@
import java.util.List;
import java.util.Map;
-import javax.wsdl.Definition;
import javax.xml.namespace.QName;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.UnifiedVirtualFile;
-import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
-import org.jboss.ws.tools.wsdl.WSDL11DefinitionFactory;
/**
* The metdata data from service-ref element in web.xml, ejb-jar.xml, and
@@ -52,6 +49,8 @@
// provide logging
private static Logger log = Logger.getLogger(ServiceRefMetaData.class);
+ private UnifiedVirtualFile vfsRoot;
+
// The required <service-ref-name> element
private String serviceRefName;
// The required <service-interface> element
@@ -77,18 +76,10 @@
// The optional JBossWS config-file
private String configFile;
// The optional URL of the actual WSDL to use, <wsdl-override>
- private URL wsdlOverride;
+ private String wsdlOverride;
// Arbitrary proxy properties given by <call-property>
private List<CallPropertyMetaData> callProperties = new
ArrayList<CallPropertyMetaData>();
- private UnifiedVirtualFile vfsRoot;
- // derived from jaxrpc-mapping-file
- private JavaWsdlMapping javaWsdlMapping;
- // derived from wsdl-override, wsdl-file
- private URL wsdlLocation;
- // derived from wsdl-override, wsdl-file
- private Definition wsdlDefinition;
-
public UnifiedVirtualFile getVfsRoot()
{
return vfsRoot;
@@ -119,31 +110,21 @@
this.mappingFile = mappingFile;
}
- public JavaWsdlMapping getJavaWsdlMapping()
- {
- return javaWsdlMapping;
- }
-
- public void setJavaWsdlMapping(JavaWsdlMapping javaWsdlMapping)
- {
- this.javaWsdlMapping = javaWsdlMapping;
- }
-
public URL getMappingLocation()
{
- URL mappingLocation = null;
+ URL mappingURL = null;
if (mappingFile != null)
{
try
{
- mappingLocation = vfsRoot.findChild(mappingFile).toURL();
+ mappingURL = vfsRoot.findChild(mappingFile).toURL();
}
catch (Exception e)
{
throw new WSException("Cannot find jaxrcp-mapping-file: " +
mappingFile, e);
}
}
- return mappingLocation;
+ return mappingURL;
}
public Collection<PortComponentRefMetaData> getPortComponentRefs()
@@ -214,10 +195,26 @@
public URL getWsdlLocation()
{
- if (wsdlLocation != null)
- return wsdlLocation;
-
- wsdlLocation = wsdlOverride;
+ URL wsdlLocation = null;
+ if (wsdlOverride != null)
+ {
+ try
+ {
+ wsdlLocation = new URL(wsdlOverride);
+ }
+ catch (MalformedURLException e1)
+ {
+ try
+ {
+ wsdlLocation = vfsRoot.findChild(wsdlOverride).toURL();
+ }
+ catch (Exception e)
+ {
+ throw new WSException("Cannot find wsdl-override: " +
wsdlOverride, e);
+ }
+ }
+ }
+
if (wsdlLocation == null && wsdlFile != null)
{
try
@@ -229,24 +226,10 @@
throw new WSException("Cannot find wsdl-file: " + wsdlFile, e);
}
}
+
return wsdlLocation;
}
- public void setWsdlLocation(URL wsdlLocation)
- {
- this.wsdlLocation = wsdlLocation;
- }
-
- public Definition getWsdlDefinition()
- {
- return wsdlDefinition;
- }
-
- public void setWsdlDefinition(Definition wsdlDefinition)
- {
- this.wsdlDefinition = wsdlDefinition;
- }
-
public String getConfigFile()
{
return configFile;
@@ -267,21 +250,14 @@
this.configName = configName;
}
- public URL getWsdlOverride()
+ public String getWsdlOverride()
{
return wsdlOverride;
}
public void setWsdlOverride(String wsdlOverride)
{
- try
- {
- this.wsdlOverride = new URL(wsdlOverride);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Invalid wsdl-override: " +
wsdlOverride);
- }
+ this.wsdlOverride = wsdlOverride;
}
public List<CallPropertyMetaData> getCallProperties()