[jboss-svn-commits] JBL Code SVN: r26036 - labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Apr 15 09:01:29 EDT 2009
Author: beve
Date: 2009-04-15 09:01:29 -0400 (Wed, 15 Apr 2009)
New Revision: 26036
Modified:
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java
Log:
Added undeploy methods to clean up virtual file systems that are added in deploy.
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java 2009-04-15 12:37:12 UTC (rev 26035)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java 2009-04-15 13:01:29 UTC (rev 26036)
@@ -117,7 +117,7 @@
public void create() throws Exception
{
- log.info("EsbConfigParser created");
+ log.info("Created");
actionArtifactProperties = JBossDeployerUtil.getArtifactProperties(actionArtifactsFile);
}
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java 2009-04-15 12:37:12 UTC (rev 26035)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java 2009-04-15 13:01:29 UTC (rev 26036)
@@ -79,7 +79,7 @@
public void create() throws Exception
{
- log.info("EsbDeployer created");
+ log.info("Created");
}
/**
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java 2009-04-15 12:37:12 UTC (rev 26035)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java 2009-04-15 13:01:29 UTC (rev 26036)
@@ -49,9 +49,7 @@
import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.listeners.config.WebserviceInfo;
import org.jboss.virtual.MemoryFileFactory;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
-import org.jboss.wsf.spi.metadata.j2ee.JSEArchiveMetaData;
/**
* EsbWebServiceDeployer is responsible for deploying the web service that will
@@ -67,6 +65,18 @@
private Logger log = Logger.getLogger(EsbWebServiceDeployer.class);
/**
+ * Key used for attaching a VirtualFile representing a ref to
+ * a dynamically created virtual file system.
+ */
+ private static final String DYNAMIC_CL_DIR_KEY = "WS-DYNAMIC-CL-DIR";
+
+ /**
+ * Key used for attaching a URL representing a ref to
+ * a dynamically created virtual file system.
+ */
+ private static final String DYNAMIC_CL_URL_KEY = "WS-DYNAMIC-CL-URL";
+
+ /**
* No-args constructor.
*/
public EsbWebServiceDeployer()
@@ -79,14 +89,14 @@
public void create()
{
- log.info("EsbWebServiceDeployer created");
+ log.info("Created");
}
@Override
public void deploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException
{
final List<WebserviceInfo> endpointServices = esbMetaData.getModel().getWebserviceServices();
- if (endpointServices != null && endpointServices.size() > 0)
+ if (hasWebServices(endpointServices))
{
log.info("Deploying webservices for : " + esbMetaData.getDeploymentName());
@@ -95,38 +105,38 @@
final List<ServletMappingMetaData> servletMappings = new ArrayList<ServletMappingMetaData>();
final FiltersMetaData filters = new FiltersMetaData();
final List<ContractReferencePublisher> publishers = new ArrayList<ContractReferencePublisher>() ;
- WebserviceDescriptionsMetaData descriptions = new WebserviceDescriptionsMetaData();
+ final WebserviceDescriptionsMetaData descriptions = new WebserviceDescriptionsMetaData();
try
{
// Used to dynamically add in-memory files to the deployment.
- URL dynamicClassRoot = new URL("vfsmemory", esbMetaData.getDeploymentName(), "");
- VFS rootDir = MemoryFileFactory.createRoot(dynamicClassRoot);
- deploymentUnit.addClassPath(rootDir.getRoot());
+ final URL dynamicClasspathUrl = new URL("vfsmemory", esbMetaData.getDeploymentName(), "");
+ final VirtualFile dynamicClasspathDir = MemoryFileFactory.createRoot(dynamicClasspathUrl).getRoot();
- MemoryFileFactory.putFile(new URL(dynamicClassRoot.toExternalForm() + "/test.txt"), "test text".getBytes());
- // Add this root to the classpath
-
- URL webInfUrl = new URL(dynamicClassRoot.toExternalForm() + "/WEB-INF");
- //VirtualFile webInfDir = MemoryFileFactory.createDirectory(webInfUrl);
- //deploymentUnit.addClassPath(webInfDir);
-
- URL classesUrl = new URL(webInfUrl + "/classes");
- VirtualFile classesDir = MemoryFileFactory.createDirectory(classesUrl);
+ // Attach the dynamic classpath URL and virtual file to this deployment unit so we can
+ // remove then upon undeploy.
+ deploymentUnit.addAttachment(DYNAMIC_CL_DIR_KEY, dynamicClasspathDir);
+ deploymentUnit.addAttachment(DYNAMIC_CL_URL_KEY, dynamicClasspathUrl);
+
+ // Add the dynamic classpath to this deployment unit.
+ deploymentUnit.addClassPath(dynamicClasspathDir);
+
+ // Create WEB-INF/classes
+ final URL webInfUrl = new URL(dynamicClasspathUrl.toExternalForm() + "/WEB-INF");
+ final URL classesUrl = new URL(webInfUrl + "/classes");
+ final VirtualFile classesDir = MemoryFileFactory.createDirectory(classesUrl);
deploymentUnit.addClassPath(classesDir);
final JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
for (WebserviceInfo webserviceInfo : endpointServices)
{
final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo);
- final Service service = webserviceInfo.getService();
final String handlers = JBossDeployerUtil.getHandlers(serviceInfo);
final boolean includeHandlers = (handlers != null);
if (includeHandlers)
{
final String wsHandlerName = serviceInfo.getPackageName().replace('.', '/') + "/esb-jaxws-handlers.xml";
- URL jaxwsHandlersUrl = new URL(classesUrl + wsHandlerName);
- VirtualFile jaxwsHandlers = MemoryFileFactory.putFile(jaxwsHandlersUrl, handlers.getBytes());
+ VirtualFile jaxwsHandlers = MemoryFileFactory.putFile(new URL(classesUrl + wsHandlerName), handlers.getBytes());
deploymentUnit.addClassPath(jaxwsHandlers);
}
@@ -134,11 +144,14 @@
{
filters.add(createFilter(serviceInfo));
}
+
+ final Service service = webserviceInfo.getService();
// Generate the servlet class bytes
final byte[] servletClass = generator.generate(service.getCategory(), service.getName(), serviceInfo, includeHandlers);
- String servletClassName = serviceInfo.getClassName().replace('.', '/') + ".class";
- URL servletClassUrl = new URL(classesUrl + "/" + servletClassName);
+ final String servletClassName = serviceInfo.getClassName().replace('.', '/') + ".class";
+ final URL servletClassUrl = new URL(classesUrl + "/" + servletClassName);
+ // Add the servlet to the virtual file system.
MemoryFileFactory.putFile(servletClassUrl, servletClass);
log.info("Generated ws impl: " + servletClassUrl);
@@ -171,24 +184,43 @@
}
}
+ private boolean hasWebServices(final List<WebserviceInfo> endpointServices)
+ {
+ return endpointServices != null && endpointServices.size() > 0;
+ }
+
+ @Override
public void undeploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
{
- /*
+ log.debug("Removing dynamic class root for " + deploymentUnit.getName());
try
{
- final VirtualFile dynamicClassRoot = VFS.getRoot(new URL("vfsmemory", esbMetaData.getDeploymentName(), ""));
- deploymentUnit.removeClassPath(dynamicClassRoot);
- }
- catch (Exception e)
+ final VirtualFile classes = deploymentUnit.removeAttachment(DYNAMIC_CL_DIR_KEY, VirtualFile.class);
+ if (classes != null)
+ {
+ deploymentUnit.removeClassPath(classes);
+ }
+ }
+ finally
{
- log.warn("Exception while removing dynamic vfs.", e);
- }
- */
+ try
+ {
+ final URL root = deploymentUnit.removeAttachment(DYNAMIC_CL_URL_KEY, URL.class);
+ if (root != null)
+ {
+ MemoryFileFactory.deleteRoot(root);
+ }
+ }
+ catch (final Exception e)
+ {
+ log.warn("Error deleting dynamic class root for " + deploymentUnit.getName(), e);
+ }
+ }
}
- private ServletMappingMetaData createServletMapping(ESBServiceEndpointInfo serviceInfo)
+ private ServletMappingMetaData createServletMapping(final ESBServiceEndpointInfo serviceInfo)
{
- ServletMappingMetaData servletMapping = new ServletMappingMetaData();
+ final ServletMappingMetaData servletMapping = new ServletMappingMetaData();
servletMapping.setServletName(serviceInfo.getServletName());
servletMapping.setUrlPatterns(Arrays.asList(new String[] { serviceInfo.getServletPath()}));
return servletMapping;
@@ -217,5 +249,4 @@
filter.setInitParam(Arrays.asList(new ParamValueMetaData[] {oneWayInitParam}));
return filter;
}
-
}
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java 2009-04-15 12:37:12 UTC (rev 26035)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java 2009-04-15 13:01:29 UTC (rev 26036)
@@ -32,7 +32,6 @@
import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
import org.jboss.soa.esb.listeners.config.WebserviceInfo;
import org.jboss.virtual.MemoryFileFactory;
-import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
@@ -56,6 +55,9 @@
/** Logger */
private Logger log = Logger.getLogger(EsbWsdlDeployer.class);
+ private static final String DYNAMIC_CL_DIR_KEY = "WSDL-DYNAMIC-CL-DIR";
+ private static final String DYNAMIC_CL_URL_KEY = "WSDL-DYNAMIC-CL-URL";
+
/**
* No-args constructor.
*/
@@ -68,7 +70,7 @@
public void create()
{
- log.info("EsdWsdlDeployer created");
+ log.info("Created");
}
@Override
@@ -80,42 +82,55 @@
log.info("Deploying webservices for : " + esbMetaData.getDeploymentName());
try
{
- URL dynamicClassRoot = new URL("vfsmemory", esbMetaData.getDeploymentName() + "_WSDL", "");
- VFS dynamicRoot = MemoryFileFactory.createRoot(dynamicClassRoot);
+ final URL dynamicClassRoot = new URL("vfsmemory", esbMetaData.getDeploymentName() + "_WSDL", "");
+ final VirtualFile dynamicClasspathDir = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
for (WebserviceInfo webserviceInfo : endpointServices)
{
final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo);
final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo, deploymentUnit.getClassLoader());
- URL wsdlUrl = new URL(dynamicClassRoot + "/" + serviceInfo.getWSDLFileName());
+ final URL wsdlUrl = new URL(dynamicClassRoot + "/" + serviceInfo.getWSDLFileName());
- VirtualFile wsdlFile = MemoryFileFactory.putFile(wsdlUrl, wsdl.getBytes());
- log.info("Added wsdl to deployment metadata location: " + wsdlFile.getParent());
- // As far as I can tell it Does not matter what location is used. The WS deployer will not use the
- // metadata location when searching for the wsdl file.
- // We might need to set the wsdlLocation to a different one when generating the WS impl.
- deploymentUnit.appendMetaDataLocation(dynamicRoot.getRoot());
+ // Add the wsdl in the virtual file system
+ MemoryFileFactory.putFile(wsdlUrl, wsdl.getBytes());
+
+ // Add the root of the virtual file system as a meta data location.
+ deploymentUnit.appendMetaDataLocation(dynamicClasspathDir);
}
}
catch (final Exception e)
{
- throw new DeploymentException("Failed to create webservice artifact", e);
+ throw new DeploymentException("Failed to create webservice artifact", e);
}
}
}
+ @Override
public void undeploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
{
- /*
+ log.debug("Removing dynamic class root for " + deploymentUnit.getName());
try
{
- final VirtualFile integration = VFS.getRoot(new URL("vfsmemory", esbMetaData.getDeploymentName(), ""));
- deploymentUnit.removeClassPath(integration);
- }
- catch (Exception e)
+ final VirtualFile classes = deploymentUnit.removeAttachment(DYNAMIC_CL_DIR_KEY, VirtualFile.class);
+ if (classes != null)
+ {
+ deploymentUnit.removeClassPath(classes);
+ }
+ }
+ finally
{
- log.warn("Exception while removing dynamic vfs.", e);
+ try
+ {
+ final URL root = deploymentUnit.removeAttachment(DYNAMIC_CL_URL_KEY, URL.class);
+ if (root != null)
+ {
+ MemoryFileFactory.deleteRoot(root);
+ }
+ }
+ catch (final Exception e)
+ {
+ log.warn("Error deleting dynamic class root for " + deploymentUnit.getName(), e);
+ }
}
- */
}
}
More information about the jboss-svn-commits
mailing list