Author: thomas.diesler(a)jboss.com
Date: 2006-11-03 10:02:46 -0500 (Fri, 03 Nov 2006)
New Revision: 1359
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXRPCDeployerJSE.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointLifecycleDeployer.java
Modified:
trunk/src/main/java/org/jboss/ws/deployment/JSR109Deployment.java
trunk/src/main/java/org/jboss/ws/deployment/UnifiedDeploymentInfo.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractDeployer.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractEJBDeployer.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/DeploymentInfoAdaptor.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerEJB3.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerJSE.java
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebAppClassLoaderFactory.java
trunk/src/main/resources/jbossws.deployer/META-INF/deployer-beans.xml
Log:
JSR109 JSE, more to come
Modified: trunk/src/main/java/org/jboss/ws/deployment/JSR109Deployment.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/JSR109Deployment.java 2006-11-03 13:23:31
UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/deployment/JSR109Deployment.java 2006-11-03 15:02:46
UTC (rev 1359)
@@ -21,7 +21,6 @@
*/
package org.jboss.ws.deployment;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -42,22 +41,29 @@
public class JSR109Deployment extends UnifiedDeploymentInfo
{
private WebservicesMetaData jsr109MetaData;
-
- public JSR109Deployment(DeploymentType type, URL webservicesURL) throws Exception
+
+ public JSR109Deployment(DeploymentType type, URL webservicesURL)
{
super(type);
-
- // Unmarshall webservices.xml
- InputStream is = webservicesURL.openStream();
+
try
{
- Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
- ObjectModelFactory factory = new WebservicesFactory(webservicesURL);
- jsr109MetaData = (WebservicesMetaData)unmarshaller.unmarshal(is, factory,
null);
+ // Unmarshall webservices.xml
+ InputStream is = webservicesURL.openStream();
+ try
+ {
+ Unmarshaller unmarshaller =
UnmarshallerFactory.newInstance().newUnmarshaller();
+ ObjectModelFactory factory = new WebservicesFactory(webservicesURL);
+ jsr109MetaData = (WebservicesMetaData)unmarshaller.unmarshal(is, factory,
null);
+ }
+ finally
+ {
+ is.close();
+ }
}
- finally
+ catch (Exception ex)
{
- is.close();
+ throw new RuntimeException(ex);
}
}
Modified: trunk/src/main/java/org/jboss/ws/deployment/UnifiedDeploymentInfo.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/deployment/UnifiedDeploymentInfo.java 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/deployment/UnifiedDeploymentInfo.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -24,12 +24,9 @@
// $Id$
import java.net.URL;
-import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;
-import javax.management.ObjectName;
-
/**
* The container independent deployment info.
*
@@ -50,28 +47,22 @@
/** The type of this deployment */
public DeploymentType type;
-
/** Sub deployments have a parent */
public UnifiedDeploymentInfo parent;
-
/** The suffix of the deployment url */
public String shortName;
-
/** The URL identifing this deployment **/
public URL url;
-
+ /** The URL to the expanded webapp **/
+ public URL expandedWebApp;
/** We can hold "typed" metadata */
public Object metaData;
-
/** A CL for preloading annotations */
public ClassLoader annotationsCl;
-
/** Local Cl is a CL that is used for metadata loading */
public ClassLoader localCl;
-
/** Unified CL is a global scope class loader **/
public ClassLoader ucl;
-
/** An arbitrary map of state associated with the deployment */
public Map<String, Object> context = new HashMap<String, Object>();
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractDeployer.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractDeployer.java 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractDeployer.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -26,12 +26,12 @@
import org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
-import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.registry.KernelRegistry;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
import org.jboss.ws.deployment.AbstractServiceEndpointPublisher;
import org.jboss.ws.deployment.ServiceEndpointDeployer;
import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo.DeploymentType;
import org.jboss.ws.server.KernelLocator;
/**
@@ -42,18 +42,6 @@
*/
public abstract class AbstractDeployer extends AbstractSimpleDeployer
{
- private Kernel kernel;
-
- public Kernel getKernel()
- {
- return kernel;
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
/** Depending on the type of deployment, this method should return true
* if the deployment contains web service endpoints.
*/
@@ -78,20 +66,9 @@
protected void deployWebService(DeploymentUnit unit) throws DeploymentException
{
UnifiedDeploymentInfo udi = createUnifiedDeploymentInfo(unit);
- String attachmentKey = getClass().getName() + ":" + unit.getName();
- unit.addAttachment(attachmentKey, udi, UnifiedDeploymentInfo.class);
+ unit.addAttachment(UnifiedDeploymentInfo.class, udi);
- try
- {
- createServiceEndpoint(udi, unit);
-
- startServiceEndpoint(udi, unit);
- }
- catch (Exception ex)
- {
- log.error("Cannot deploy web service: " + unit.getName(), ex);
- throw new DeploymentException(ex);
- }
+ createServiceEndpoint(udi, unit);
}
/** Undeploy the web service endpoints if there are any
@@ -108,44 +85,17 @@
*/
protected void undeployWebService(DeploymentUnit unit, UnifiedDeploymentInfo udi)
{
- try
- {
- stopServiceEndpoint(udi, unit);
-
- destroyServiceEndpoint(udi, unit);
- }
- catch (RuntimeException rte)
- {
- log.error("Cannot undeploy web service: " + udi.getCanonicalName(),
rte);
- throw rte;
- }
- catch (Exception ex)
- {
- log.error("Cannot undeploy web service: " + udi.getCanonicalName(),
ex);
- throw new RuntimeException(ex);
- }
+ destroyServiceEndpoint(udi, unit);
}
- protected void createServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
+ protected void createServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws DeploymentException
{
log.debug("createServiceEndpoint: " + udi.getCanonicalName());
getServiceEndpointDeployer().create(udi);
}
- protected void startServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
+ protected void destroyServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
{
- log.debug("startServiceEndpoint: " + udi.getCanonicalName());
- getServiceEndpointDeployer().start(udi);
- }
-
- protected void stopServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
- {
- log.debug("stopServiceEndpoint: " + udi.getCanonicalName());
- getServiceEndpointDeployer().stop(udi);
- }
-
- protected void destroyServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
- {
log.debug("destroyServiceEndpoint: " + udi.getCanonicalName());
getServiceEndpointDeployer().destroy(udi);
}
@@ -164,9 +114,12 @@
return (ServiceEndpointPublisher)entry.getTarget();
}
+ protected abstract DeploymentType getDeploymentType();
+
protected UnifiedDeploymentInfo getUnifiedDeploymentInfo(DeploymentUnit unit)
{
- String attachmentKey = getClass().getName() + ":" + unit.getName();
- return (UnifiedDeploymentInfo)unit.getAttachment(attachmentKey,
UnifiedDeploymentInfo.class);
+ UnifiedDeploymentInfo udi = unit.getAttachment(UnifiedDeploymentInfo.class);
+ return (udi != null && udi.type == getDeploymentType() ? udi : null);
+
}
}
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractEJBDeployer.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractEJBDeployer.java 2006-11-03
13:23:31 UTC (rev 1358)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractEJBDeployer.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -25,6 +25,7 @@
import java.net.URL;
+import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.ws.deployment.UnifiedDeploymentInfo;
import org.jboss.ws.metadata.UnifiedMetaData;
@@ -38,24 +39,38 @@
public abstract class AbstractEJBDeployer extends AbstractDeployer
{
@Override
- protected void createServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
+ protected void createServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws DeploymentException
{
// Create the service endpoint
super.createServiceEndpoint(udi, unit);
// Generate the webapp and publish to tomcat
- UnifiedMetaData wsMetaData = getServiceEndpointDeployer().getUnifiedMetaData(udi);
- URL warURL = new ServiceEndpointGeneratorEJB3().generatWebDeployment(wsMetaData,
unit);
- unit.addAttachment(ServiceEndpointWebApp.class, new
ServiceEndpointWebApp(warURL));
- getServiceEndpointPublisher().publishServiceEndpoint(warURL);
+ try
+ {
+ UnifiedMetaData wsMetaData =
getServiceEndpointDeployer().getUnifiedMetaData(udi);
+ URL warURL = new ServiceEndpointGeneratorEJB3().generatWebDeployment(wsMetaData,
unit);
+ unit.addAttachment(ServiceEndpointWebApp.class, new
ServiceEndpointWebApp(warURL));
+ getServiceEndpointPublisher().publishServiceEndpoint(warURL);
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+ }
}
@Override
- protected void destroyServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
throws Exception
+ protected void destroyServiceEndpoint(UnifiedDeploymentInfo udi, DeploymentUnit unit)
{
// Destroy the webapp
URL warURL = unit.getAttachment(ServiceEndpointWebApp.class).getWarURL();
- getServiceEndpointPublisher().destroyServiceEndpoint(warURL);
+ try
+ {
+ getServiceEndpointPublisher().destroyServiceEndpoint(warURL);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot destroy service endpoint: " + warURL, ex);
+ }
// Destroy the service endpoint
super.destroyServiceEndpoint(udi, unit);
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java 2006-11-03
13:23:31 UTC (rev 1358)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/AbstractJSEDeployer.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -21,6 +21,31 @@
*/
package org.jboss.ws.integration.jboss50;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import javax.jws.WebService;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.metadata.NameValuePair;
+import org.jboss.metadata.WebMetaData;
+import org.jboss.metadata.web.Servlet;
+import org.jboss.util.file.Files;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.server.ServerConfig;
+import org.jboss.ws.server.ServerConfigFactory;
+import org.jboss.ws.utils.IOUtils;
+
//$Id$
@@ -32,4 +57,180 @@
*/
public abstract class AbstractJSEDeployer extends AbstractDeployer
{
+ // The URL the expanded webapp in the deployment unit
+ public static final String JBOSSWS_EXPANDED_WAR_URL =
"jbossws.expanded.war.url";
+ // The servlet init param in web.xml that is the service endpoint class
+ public static final String INIT_PARAM_SERVICE_ENDPOINT_IMPL =
"ServiceEndpointImpl";
+
+ /** Install an annotation class loader, if there is none already
+ */
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ Set<? extends WebMetaData> allMetaData =
unit.getAllMetaData(WebMetaData.class);
+ if (allMetaData.size() > 0)
+ {
+ boolean removeLoader = false;
+ try
+ {
+ unit.getClassLoader();
+ }
+ catch (Exception ex)
+ {
+ unit.getDeploymentContext().createClassLoader(new
WebAppClassLoaderFactory());
+ removeLoader = true;
+ }
+ try
+ {
+ super.deploy(unit);
+ }
+ finally
+ {
+ if (removeLoader == true)
+ unit.getDeploymentContext().removeClassLoader();
+ }
+ }
+ }
+
+ /** Create the unified deployment info and create and start th eservice endpoints
+ * through the ServiceEndpointDeployer
+ */
+ @Override
+ protected void deployWebService(DeploymentUnit unit) throws DeploymentException
+ {
+ // modify the WebMetaData
+ modifyWebMetaData(unit);
+
+ // Call the super implementation
+ super.deployWebService(unit);
+
+ // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
+ URL expWebAppURL = expandWebDeployment(unit);
+ if (expWebAppURL != null)
+ {
+ getServiceEndpointPublisher().rewriteWebXML(expWebAppURL);
+ unit.addAttachment(JBOSSWS_EXPANDED_WAR_URL, expWebAppURL);
+ }
+ }
+
+ @Override
+ protected void undeployWebService(DeploymentUnit unit, UnifiedDeploymentInfo udi)
+ {
+ // Call the super implementation
+ super.undeployWebService(unit, udi);
+
+ // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
+ URL warURL = (URL)unit.getAttachment(JBOSSWS_EXPANDED_WAR_URL);
+ if (warURL != null)
+ {
+ Files.delete(new File(warURL.getFile()));
+ }
+ }
+
+ private void modifyWebMetaData(DeploymentUnit unit) throws DeploymentException
+ {
+ try
+ {
+ Set<? extends WebMetaData> allMetaData =
unit.getAllMetaData(WebMetaData.class);
+ if (allMetaData.size() > 0)
+ {
+ WebMetaData webMetaData = allMetaData.iterator().next();
+ ClassLoader anLoader = unit.getClassLoader();
+ String serviceEndpointServlet =
getServiceEndpointPublisher().getServiceEndpointServlet();
+
+ Iterator it = webMetaData.getServlets().iterator();
+ while (it.hasNext())
+ {
+ Servlet servlet = (Servlet)it.next();
+ String className = servlet.getServletClass();
+ Class<?> servletClass = anLoader.loadClass(className);
+ if (servletClass.isAnnotationPresent(WebService.class))
+ {
+ // Nothing to do if we have an <init-param>
+ if (isAlreadyModified(servlet) == false)
+ {
+ servlet.setServletClass(serviceEndpointServlet);
+ NameValuePair initParam = new
NameValuePair(INIT_PARAM_SERVICE_ENDPOINT_IMPL, className);
+ servlet.addInitParam(initParam);
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+ }
+ }
+
+ private boolean isAlreadyModified(Servlet servlet)
+ {
+ Iterator itParams = servlet.getInitParams().iterator();
+ while (itParams.hasNext())
+ {
+ NameValuePair pair = (NameValuePair)itParams.next();
+ if (INIT_PARAM_SERVICE_ENDPOINT_IMPL.equals(pair.getName()))
+ return true;
+ }
+ return false;
+ }
+
+ private URL expandWebDeployment(DeploymentUnit unit) throws DeploymentException
+ {
+ URL expWebAppURL = null;
+ try
+ {
+ VirtualFile virtualWarFile = unit.getDeploymentContext().getRoot();
+ // FIXME: JBAS-3811 - VirtualFile.getPathName() returns empty string for jar
files
+ // String warPathName = virtualWarFile.getPathName();
+
+ String warPathName = virtualWarFile.toURL().toExternalForm();
+ if (warPathName.startsWith("jar:") &&
warPathName.endsWith("!/"))
+ warPathName = warPathName.substring(4,
warPathName.lastIndexOf("!/"));
+ if (warPathName.startsWith("file:"))
+ warPathName = new URL(warPathName).getFile();
+
+ String warShortName = virtualWarFile.getName();
+ File warFile = new File(warPathName);
+ if (warFile.exists() == false)
+ throw new IllegalStateException("WAR file does not exist: " +
warPathName);
+
+ if (warFile.isDirectory() == false)
+ {
+ ServerConfigFactory factory = ServerConfigFactory.getInstance();
+ ServerConfig config = factory.getServerConfig();
+ File tmpdir = new File(config.getServerTempDir().getCanonicalPath() +
"/deploy");
+
+ File tmpWar = File.createTempFile(warShortName, ".war", tmpdir);
+ tmpWar.delete();
+
+ log.debug("Expand war to: " + tmpWar);
+
+ ZipFile zipFile = new ZipFile(warFile);
+ Enumeration en = zipFile.entries();
+ while (en.hasMoreElements())
+ {
+ ZipEntry entry = (ZipEntry)en.nextElement();
+ String entryName = entry.getName();
+ if (entry.isDirectory() == false)
+ {
+ File entryFile = new File(tmpWar.getAbsolutePath() + "/" +
entryName);
+ entryFile.getParentFile().mkdirs();
+ OutputStream fos = new FileOutputStream(entryFile);
+ InputStream fis = zipFile.getInputStream(entry);
+ IOUtils.copyStream(fos, fis);
+ fos.close();
+ fis.close();
+ }
+ }
+
+ expWebAppURL = tmpWar.toURL();
+ }
+ }
+ catch (Exception ex)
+ {
+ DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
+ }
+ return expWebAppURL;
+ }
}
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/DeploymentInfoAdaptor.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/DeploymentInfoAdaptor.java 2006-11-03
13:23:31 UTC (rev 1358)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/DeploymentInfoAdaptor.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -66,10 +66,7 @@
private static String getShortName(DeploymentUnit unit)
{
- String shortName = unit.getName();
- if (shortName.endsWith("!/"))
- shortName = shortName.substring(0, shortName.lastIndexOf("!"));
- shortName = shortName.substring(shortName.lastIndexOf("/") + 1);
+ String shortName = unit.getDeploymentContext().getRoot().getName();
return shortName;
}
Added: trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXRPCDeployerJSE.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXRPCDeployerJSE.java 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXRPCDeployerJSE.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -0,0 +1,94 @@
+/*
+ * 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 org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.ws.deployment.JSR109Deployment;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo.DeploymentType;
+
+/**
+ * A deployer JAXRPC JSE Endpoints
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 31-Oct-2005
+ */
+public class JAXRPCDeployerJSE extends AbstractJSEDeployer
+{
+ // The default relative order after the JBossWebAppParsingDeployer
+ public int getRelativeOrder()
+ {
+ return PARSER_DEPLOYER + 3;
+ }
+
+ @Override
+ protected DeploymentType getDeploymentType()
+ {
+ return DeploymentType.JSR109_JSE;
+ }
+
+ @Override
+ public boolean isWebService(DeploymentUnit unit)
+ {
+ boolean isWebServiceDeployment = false;
+
+ if (getWebServicesURL(unit) != null)
+ isWebServiceDeployment = true;
+
+ return isWebServiceDeployment;
+ }
+
+ @Override
+ protected UnifiedDeploymentInfo createUnifiedDeploymentInfo(DeploymentUnit unit)
+ {
+ URL webservicesUrl = getWebServicesURL(unit);
+ UnifiedDeploymentInfo udi = new JSR109Deployment(getDeploymentType(),
webservicesUrl);
+ DeploymentInfoAdaptor.buildDeploymentInfo(udi, unit);
+ return udi;
+ }
+
+ private URL getWebServicesURL(DeploymentUnit unit)
+ {
+ VirtualFile vfile = unit.getMetaDataFile("webservices.xml");
+ if (vfile != null)
+ {
+ try
+ {
+ String urlStr = vfile.toURL().toExternalForm();
+ if (urlStr.startsWith("jar:") &&
urlStr.endsWith("!/"))
+ urlStr = urlStr.substring(4, urlStr.length() - 2);
+
+ return new URL(urlStr);
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ }
+ return null;
+ }
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXRPCDeployerJSE.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerEJB3.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerEJB3.java 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerEJB3.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -33,6 +33,7 @@
import org.jboss.ejb3.stateless.StatelessContainer;
import org.jboss.ws.deployment.JSR181Deployment;
import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo.DeploymentType;
/**
* A deployer JAXWS EJB3 Endpoints
@@ -43,9 +44,15 @@
public class JAXWSDeployerEJB3 extends AbstractEJBDeployer
{
@Override
+ protected DeploymentType getDeploymentType()
+ {
+ return DeploymentType.JSR181_EJB3;
+ }
+
+ @Override
protected UnifiedDeploymentInfo createUnifiedDeploymentInfo(DeploymentUnit unit)
{
- UnifiedDeploymentInfo udi = new
JSR181Deployment(UnifiedDeploymentInfo.DeploymentType.JSR181_EJB3);
+ UnifiedDeploymentInfo udi = new JSR181Deployment(getDeploymentType());
DeploymentInfoAdaptor.buildDeploymentInfo(udi, unit);
return udi;
}
Property changes on:
trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerEJB3.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerJSE.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerJSE.java 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/java/org/jboss/ws/integration/jboss50/JAXWSDeployerJSE.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -23,31 +23,17 @@
//$Id$
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
import javax.jws.WebService;
-import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentUnit;
-import org.jboss.metadata.NameValuePair;
import org.jboss.metadata.WebMetaData;
import org.jboss.metadata.web.Servlet;
-import org.jboss.util.file.Files;
-import org.jboss.virtual.VirtualFile;
import org.jboss.ws.deployment.JSR181Deployment;
import org.jboss.ws.deployment.UnifiedDeploymentInfo;
-import org.jboss.ws.server.ServerConfig;
-import org.jboss.ws.server.ServerConfigFactory;
-import org.jboss.ws.utils.IOUtils;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo.DeploymentType;
/**
* A deployer JAXWS JSE Endpoints
@@ -57,9 +43,6 @@
*/
public class JAXWSDeployerJSE extends AbstractJSEDeployer
{
- // The servlet init param in web.xml that is the service endpoint class
- public static final String INIT_PARAM_SERVICE_ENDPOINT_IMPL =
"ServiceEndpointImpl";
-
// The default relative order after the JBossWebAppParsingDeployer
public int getRelativeOrder()
{
@@ -67,6 +50,12 @@
}
@Override
+ protected DeploymentType getDeploymentType()
+ {
+ return DeploymentType.JSR181_JSE;
+ }
+
+ @Override
public boolean isWebService(DeploymentUnit unit)
{
boolean isWebServiceDeployment = false;
@@ -101,183 +90,11 @@
return isWebServiceDeployment;
}
- /** Install an annotation class loader, if there is none already
- */
@Override
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- Set<? extends WebMetaData> allMetaData =
unit.getAllMetaData(WebMetaData.class);
- if (allMetaData.size() > 0)
- {
- boolean removeLoader = false;
- try
- {
- unit.getClassLoader();
- }
- catch (Exception ex)
- {
- unit.getDeploymentContext().createClassLoader(new
WebAppClassLoaderFactory());
- removeLoader = true;
- }
- try
- {
- super.deploy(unit);
- }
- finally
- {
- if (removeLoader == true)
- unit.getDeploymentContext().removeClassLoader();
- }
- }
- }
-
- /** Create the unified deployment info and create and start th eservice endpoints
- * through the ServiceEndpointDeployer
- */
- @Override
- protected void deployWebService(DeploymentUnit unit) throws DeploymentException
- {
- // Call the super implementation
- super.deployWebService(unit);
-
- // modify the WebMetaData
- modifyWebMetaData(unit);
-
- // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
- URL expWebAppURL = expandWebDeployment(unit);
- if (expWebAppURL != null)
- {
- getServiceEndpointPublisher().rewriteWebXML(expWebAppURL);
- unit.addAttachment("jbossws.expanded.war.url", expWebAppURL);
- }
- }
-
- @Override
- protected void undeployWebService(DeploymentUnit unit, UnifiedDeploymentInfo udi)
- {
- // Call the super implementation
- super.undeployWebService(unit, udi);
-
- // FIXME: JBAS-3812 - TomcatDeployment should use modified WebMetaData
- URL warURL = (URL)unit.getAttachment("jbossws.expanded.war.url");
- if (warURL != null)
- {
- Files.delete(new File(warURL.getFile()));
- }
- }
-
- @Override
protected UnifiedDeploymentInfo createUnifiedDeploymentInfo(DeploymentUnit unit)
{
- UnifiedDeploymentInfo udi = new
JSR181Deployment(UnifiedDeploymentInfo.DeploymentType.JSR181_JSE);
+ UnifiedDeploymentInfo udi = new JSR181Deployment(getDeploymentType());
DeploymentInfoAdaptor.buildDeploymentInfo(udi, unit);
return udi;
}
-
- private void modifyWebMetaData(DeploymentUnit unit) throws DeploymentException
- {
- try
- {
- Set<? extends WebMetaData> allMetaData =
unit.getAllMetaData(WebMetaData.class);
- if (allMetaData.size() > 0)
- {
- WebMetaData webMetaData = allMetaData.iterator().next();
- ClassLoader anLoader = unit.getClassLoader();
- String serviceEndpointServlet =
getServiceEndpointPublisher().getServiceEndpointServlet();
-
- Iterator it = webMetaData.getServlets().iterator();
- while (it.hasNext())
- {
- Servlet servlet = (Servlet)it.next();
- String className = servlet.getServletClass();
- Class<?> servletClass = anLoader.loadClass(className);
- if (servletClass.isAnnotationPresent(WebService.class))
- {
- // Nothing to do if we have an <init-param>
- if (isAlreadyModified(servlet) == false)
- {
- servlet.setServletClass(serviceEndpointServlet);
- NameValuePair initParam = new
NameValuePair(INIT_PARAM_SERVICE_ENDPOINT_IMPL, className);
- servlet.addInitParam(initParam);
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
- }
- }
-
- private boolean isAlreadyModified(Servlet servlet)
- {
- Iterator itParams = servlet.getInitParams().iterator();
- while (itParams.hasNext())
- {
- NameValuePair pair = (NameValuePair)itParams.next();
- if (INIT_PARAM_SERVICE_ENDPOINT_IMPL.equals(pair.getName()))
- return true;
- }
- return false;
- }
-
- private URL expandWebDeployment(DeploymentUnit unit) throws DeploymentException
- {
- URL expWebAppURL = null;
- try
- {
- VirtualFile virtualWarFile = unit.getDeploymentContext().getRoot();
- // FIXME: JBAS-3811 - VirtualFile.getPathName() returns empty string for jar
files
- // String warPathName = virtualWarFile.getPathName();
-
- String warPathName = virtualWarFile.toURL().toExternalForm();
- if (warPathName.startsWith("jar:") &&
warPathName.endsWith("!/"))
- warPathName = warPathName.substring(4,
warPathName.lastIndexOf("!/"));
- if (warPathName.startsWith("file:"))
- warPathName = new URL(warPathName).getFile();
-
- String warShortName = virtualWarFile.getName();
- File warFile = new File(warPathName);
- if (warFile.exists() == false)
- throw new IllegalStateException("WAR file does not exist: " +
warPathName);
-
- if (warFile.isDirectory() == false)
- {
- ServerConfigFactory factory = ServerConfigFactory.getInstance();
- ServerConfig config = factory.getServerConfig();
- File tmpdir = new File(config.getServerTempDir().getCanonicalPath() +
"/deploy");
-
- File tmpWar = File.createTempFile(warShortName, ".war", tmpdir);
- tmpWar.delete();
-
- log.debug("Expand war to: " + tmpWar);
-
- ZipFile zipFile = new ZipFile(warFile);
- Enumeration en = zipFile.entries();
- while (en.hasMoreElements())
- {
- ZipEntry entry = (ZipEntry)en.nextElement();
- String entryName = entry.getName();
- if (entry.isDirectory() == false)
- {
- File entryFile = new File(tmpWar.getAbsolutePath() + "/" +
entryName);
- entryFile.getParentFile().mkdirs();
- OutputStream fos = new FileOutputStream(entryFile);
- InputStream fis = zipFile.getInputStream(entry);
- IOUtils.copyStream(fos, fis);
- fos.close();
- fis.close();
- }
- }
-
- expWebAppURL = tmpWar.toURL();
- }
- }
- catch (Exception ex)
- {
- DeploymentException.rethrowAsDeploymentException(ex.getMessage(), ex);
- }
- return expWebAppURL;
- }
}
Added:
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointLifecycleDeployer.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointLifecycleDeployer.java 2006-11-03
13:23:31 UTC (rev 1358)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointLifecycleDeployer.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -0,0 +1,81 @@
+/*
+ * 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 org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.ws.deployment.ServiceEndpointDeployer;
+import org.jboss.ws.deployment.UnifiedDeploymentInfo;
+import org.jboss.ws.metadata.UnifiedMetaData;
+import org.jboss.ws.server.KernelLocator;
+
+/**
+ * A deployer that starts and stops web service deployments
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 31-Oct-2006
+ */
+public class ServiceEndpointLifecycleDeployer extends AbstractSimpleDeployer
+{
+ /** Start the service endpoint
+ */
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ UnifiedDeploymentInfo udi = unit.getAttachment(UnifiedDeploymentInfo.class);
+ if (udi != null)
+ {
+ // Always use the context class loader to initialize the endpoint
+ UnifiedMetaData wsMetaData =
getServiceEndpointDeployer().getUnifiedMetaData(udi);
+ ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
+ wsMetaData.setClassLoader(ctxClassLoader);
+
+ log.debug("startServiceEndpoint: " + udi.getCanonicalName());
+ getServiceEndpointDeployer().start(udi);
+ }
+ }
+
+ /** Stop the service endpoint
+ */
+ @Override
+ public void undeploy(DeploymentUnit unit)
+ {
+ UnifiedDeploymentInfo udi = unit.getAttachment(UnifiedDeploymentInfo.class);
+ if (udi != null)
+ {
+ log.debug("stopServiceEndpoint: " + udi.getCanonicalName());
+ getServiceEndpointDeployer().stop(udi);
+ }
+ }
+
+ protected ServiceEndpointDeployer getServiceEndpointDeployer()
+ {
+ KernelRegistry registry = KernelLocator.getKernel().getRegistry();
+ KernelRegistryEntry entry = registry.getEntry(ServiceEndpointDeployer.BEAN_NAME);
+ return (ServiceEndpointDeployer)entry.getTarget();
+ }
+}
Property changes on:
trunk/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointLifecycleDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebAppClassLoaderFactory.java
===================================================================
---
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebAppClassLoaderFactory.java 2006-11-03
13:23:31 UTC (rev 1358)
+++
trunk/src/main/java/org/jboss/ws/integration/jboss50/WebAppClassLoaderFactory.java 2006-11-03
15:02:46 UTC (rev 1359)
@@ -77,17 +77,24 @@
File warFile = new File(fileName);
if (warFile.exists())
{
+ // Add root url
+ list.add(new URL(externalForm));
+
ZipFile zipFile = new ZipFile(warFile);
Enumeration en = zipFile.entries();
while (en.hasMoreElements())
{
ZipEntry entry = (ZipEntry)en.nextElement();
String entryName = entry.getName();
+
+ // Add WEB-INF/classes
if (entryName.equals("WEB-INF/classes/"))
{
URL classesURL = new URL(externalForm + entryName);
list.add(classesURL);
}
+
+ // Add WEB-INF/lib/*.jar
if (entryName.startsWith("WEB-INF/lib") &&
entryName.endsWith(".jar"))
{
URL jarURL = new URL(externalForm + entryName);
Modified: trunk/src/main/resources/jbossws.deployer/META-INF/deployer-beans.xml
===================================================================
--- trunk/src/main/resources/jbossws.deployer/META-INF/deployer-beans.xml 2006-11-03
13:23:31 UTC (rev 1358)
+++ trunk/src/main/resources/jbossws.deployer/META-INF/deployer-beans.xml 2006-11-03
15:02:46 UTC (rev 1359)
@@ -13,7 +13,6 @@
<this/>
</parameter>
</uninstall>
- <property name="kernel"><inject
bean="jboss.kernel:service=Kernel"/></property>
<depends>EJBRegistrationDeployer</depends>
<depends>JBossWebAppParsingDeployer</depends>
</bean>
@@ -44,8 +43,34 @@
<this/>
</parameter>
</uninstall>
- <property name="kernel"><inject
bean="jboss.kernel:service=Kernel"/></property>
<depends>JBossWebAppParsingDeployer</depends>
</bean>
+ <bean name="JAXRPCDeployerJSE"
class="org.jboss.ws.integration.jboss50.JAXRPCDeployerJSE">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ <depends>JBossWebAppParsingDeployer</depends>
+ </bean>
+
+ <bean name="ServiceEndpointLifecycleDeployer"
class="org.jboss.ws.integration.jboss50.ServiceEndpointLifecycleDeployer">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ </bean>
+
</deployment>
\ No newline at end of file