Author: thomas.diesler(a)jboss.com
Date: 2006-11-03 20:36:16 -0500 (Fri, 03 Nov 2006)
New Revision: 1364
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceRefMetaDataAdaptor.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java
Modified:
trunk/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
Log:
resurect service-ref in app client
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceRefMetaDataAdaptor.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceRefMetaDataAdaptor.java 2006-11-03
20:23:13 UTC (rev 1363)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceRefMetaDataAdaptor.java 2006-11-04
01:36:16 UTC (rev 1364)
@@ -0,0 +1,98 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+
+import org.jboss.webservice.metadata.serviceref.HandlerMetaData;
+import org.jboss.webservice.metadata.serviceref.InitParamMetaData;
+import org.jboss.webservice.metadata.serviceref.PortComponentRefMetaData;
+import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.ws.metadata.HandlerMetaData.HandlerInitParam;
+import org.jboss.ws.metadata.j2ee.UnifiedHandlerMetaData;
+import org.jboss.ws.metadata.j2ee.UnifiedPortComponentRefMetaData;
+import org.jboss.ws.metadata.j2ee.UnifiedServiceRefMetaData;
+
+/**
+ * Build container independent service ref meta data
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 05-May-2006
+ */
+public class ServiceRefMetaDataAdaptor
+{
+ public static UnifiedServiceRefMetaData
buildUnifiedServiceRefMetaData(ServiceRefMetaData srmd)
+ {
+ UnifiedServiceRefMetaData usrmd = new UnifiedServiceRefMetaData();
+ usrmd.setServiceRefName(srmd.getServiceRefName());
+ usrmd.setServiceInterface(srmd.getServiceInterface());
+ usrmd.setWsdlFile(srmd.getWsdlFile());
+ usrmd.setJaxrpcMappingFile(srmd.getJaxrpcMappingFile());
+ usrmd.setServiceQName(srmd.getServiceQName());
+
+ LinkedHashMap<String, UnifiedPortComponentRefMetaData> pcrefs = new
LinkedHashMap<String, UnifiedPortComponentRefMetaData>();
+ for (PortComponentRefMetaData pcmd : srmd.getPortComponentRefs())
+ {
+ UnifiedPortComponentRefMetaData upcmd = new UnifiedPortComponentRefMetaData();
+ upcmd.setServiceEndpointInterface(pcmd.getServiceEndpointInterface());
+ upcmd.setPortComponentLink(pcmd.getPortComponentLink());
+ upcmd.setCallProperties(pcmd.getCallProperties());
+ pcrefs.put(pcmd.getServiceEndpointInterface(), upcmd);
+ }
+ usrmd.setPortComponentRefs(pcrefs);
+
+ ArrayList<UnifiedHandlerMetaData> handlers = new
ArrayList<UnifiedHandlerMetaData>();
+ for (HandlerMetaData hmd : srmd.getHandlers())
+ {
+ UnifiedHandlerMetaData uhmd = new UnifiedHandlerMetaData(null);
+ uhmd.setHandlerName(hmd.getHandlerName());
+ uhmd.setHandlerClass(hmd.getHandlerClass());
+ Arrays.asList(hmd.getSoapHeaders());
+
+ for(String portname : hmd.getPortNames())
+ {
+ uhmd.addPortName(portname);
+ }
+ for (InitParamMetaData ipmd : hmd.getInitParams())
+ {
+ HandlerInitParam ip = new HandlerInitParam();
+ ip.setParamName(ipmd.getParamName());
+ ip.setParamValue(ipmd.getParamValue());
+ uhmd.addInitParam(ip);
+ }
+ handlers.add(uhmd);
+ }
+ usrmd.setHandlers(handlers);
+
+ usrmd.setConfigName(srmd.getConfigName());
+ usrmd.setConfigFile(srmd.getConfigFile());
+ usrmd.setWsdlOverride(srmd.getWsdlOverride());
+ usrmd.setCallProperties(srmd.getCallProperties());
+ usrmd.setResourceCL(srmd.getResourceCL());
+
+ return usrmd;
+ }
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceRefMetaDataAdaptor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2006-11-03
20:23:13 UTC (rev 1363)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java 2006-11-04
01:36:16 UTC (rev 1364)
@@ -0,0 +1,158 @@
+/*
+ * 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.net.URL;
+import java.util.Iterator;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.wsdl.Definition;
+import javax.wsdl.WSDLException;
+import javax.xml.rpc.JAXRPCException;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.mx.util.MBeanServerLocator;
+import org.jboss.naming.Util;
+import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
+import org.jboss.ws.WSException;
+import org.jboss.ws.deployment.JSR109ClientDeployment;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.jaxrpc.ServiceReferenceable;
+import org.jboss.ws.metadata.j2ee.UnifiedServiceRefMetaData;
+import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMapping;
+import org.jboss.ws.metadata.jaxrpcmapping.JavaWsdlMappingFactory;
+import org.jboss.ws.metadata.wsdl.WSDL11DefinitionFactory;
+
+/**
+ * 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 WebServiceRefHandler implements WebServiceRefHandlerMBean
+{
+ // logging support
+ private static Logger log = Logger.getLogger(WebServiceRefHandler.class);
+
+ /**
+ * This binds a jaxrpc Service into the callers ENC for every service-ref element
+ *
+ * @param envCtx ENC to bind the javax.rpc.xml.Service object to
+ * @param serviceRefs An iterator of the service-ref elements in the client deployment
descriptor
+ * @param unit The client's deployment info
+ * @throws org.jboss.deployment.DeploymentException if it goes wrong
+ */
+ public void setupServiceRefEnvironment(Context envCtx, Iterator serviceRefs,
DeploymentUnit unit) throws DeploymentException
+ {
+ try
+ {
+ while (serviceRefs.hasNext())
+ {
+ ServiceRefMetaData serviceRef = (ServiceRefMetaData)serviceRefs.next();
+ String serviceRefName = serviceRef.getServiceRefName();
+
+ UnifiedServiceRefMetaData wsServiceRef =
ServiceRefMetaDataAdaptor.buildUnifiedServiceRefMetaData(serviceRef);
+
+ JavaWsdlMapping javaWsdlMapping = getJavaWsdlMapping(wsServiceRef);
+ wsServiceRef.setJavaWsdlMapping(javaWsdlMapping);
+
+ Definition wsdlDefinition = getWsdlDefinition(wsServiceRef);
+ wsServiceRef.setWsdlDefinition(wsdlDefinition);
+
+ // build the container independent deployment info
+ UnifiedDeploymentInfo udi = new
JSR109ClientDeployment(UnifiedDeploymentInfo.DeploymentType.JSR109_Client);
+ DeploymentInfoAdaptor.buildDeploymentInfo(udi, unit);
+
+ ServiceReferenceable ref = new ServiceReferenceable(wsServiceRef, udi);
+ Util.bind(envCtx, serviceRefName, ref);
+
+ log.debug("<service-ref> bound to: java:comp/env/" +
serviceRefName);
+ }
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException("Cannot bind webservice to
client environment", ex);
+ }
+ }
+
+ private JavaWsdlMapping getJavaWsdlMapping(UnifiedServiceRefMetaData serviceRef)
+ {
+ JavaWsdlMapping javaWsdlMapping = null;
+ URL mappingURL = serviceRef.getJavaWsdlMappingURL();
+ if (mappingURL != null)
+ {
+ try
+ {
+ // setup the XML binding Unmarshaller
+ JavaWsdlMappingFactory mappingFactory =
JavaWsdlMappingFactory.newInstance();
+ javaWsdlMapping = mappingFactory.parse(mappingURL);
+ }
+ catch (Exception e)
+ {
+ throw new JAXRPCException("Cannot unmarshal jaxrpc-mapping-file: "
+ mappingURL, e);
+ }
+ }
+ return javaWsdlMapping;
+ }
+
+ private Definition getWsdlDefinition(UnifiedServiceRefMetaData serviceRef)
+ {
+ Definition wsdlDefinition = null;
+ {
+ URL wsdlOverride = serviceRef.getWsdlOverride();
+ URL wsdlURL = serviceRef.getWsdlURL();
+ if (wsdlOverride == null && wsdlURL != null)
+ {
+ try
+ {
+ WSDL11DefinitionFactory factory = WSDL11DefinitionFactory.newInstance();
+ wsdlDefinition = factory.parse(wsdlURL);
+ }
+ catch (WSDLException e)
+ {
+ throw new WSException("Cannot unmarshall wsdl, cause: " +
e.toString());
+ }
+ }
+ }
+ return wsdlDefinition;
+ }
+
+ 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:
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java 2006-11-03
20:23:13 UTC (rev 1363)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java 2006-11-04
01:36:16 UTC (rev 1364)
@@ -0,0 +1,36 @@
+/*
+* 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 javax.management.ObjectName;
+
+import org.jboss.webservice.WebServiceRefHandler;
+import org.jboss.ws.utils.ObjectNameFactory;
+
+/**
+ * MBean interface.
+ */
+public interface WebServiceRefHandlerMBean extends WebServiceRefHandler
+{
+ // default object name
+ public static final ObjectName OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=WebServiceRefHandler");
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebServiceRefHandlerMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
--- trunk/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2006-11-03 20:23:13
UTC (rev 1363)
+++ trunk/src/main/resources/jbossws.beans/META-INF/jboss-beans.xml 2006-11-04 01:36:16
UTC (rev 1364)
@@ -35,6 +35,9 @@
<property
name="serviceEndpointServlet">org.jboss.ws.integration.jboss.ServiceEndpointServlet</property>
</bean>
+ <!-- Bind JAXRPC Service objects in application client environment context -->
+ <bean name="WebServiceRefHandler"
class="org.jboss.ws.integration.jboss50.WebServiceRefHandler"/>
+
<!-- A subscription manager for WS-Eventing -->
<bean name="SubscriptionManager"
class="org.jboss.ws.eventing.mgmt.SubscriptionManager"/>