[jboss-svn-commits] JBL Code SVN: r26534 - in labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta: src/org/jboss/soa/esb/listeners/deployers/mc/util and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu May 14 08:42:01 EDT 2009
Author: beve
Date: 2009-05-14 08:42:01 -0400 (Thu, 14 May 2009)
New Revision: 26534
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/EsbWsdlDeployer.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtil.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployerUnitTest.java
Log:
Minor refactoring.
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-05-14 12:35:30 UTC (rev 26533)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWebServiceDeployer.java 2009-05-14 12:42:01 UTC (rev 26534)
@@ -88,16 +88,19 @@
public EsbWebServiceDeployer()
{
super(EsbMetaData.class);
+ // Set the deployment stage to after parse.
setStage(DeploymentStages.POST_PARSE);
+ // Tell the MicroContainer that we are producing JBossWebMetaData.
setOutput(JBossWebMetaData.class);
+ // Tell the MicroContainer that we are producing EsbMetaData.
setOutput(EsbMetaData.class);
}
@Override
- public void deploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException
+ public void deploy(final VFSDeploymentUnit unit, final EsbMetaData esbMetaData) throws DeploymentException
{
- final List<WebserviceInfo> endpointServices = esbMetaData.getModel().getWebserviceServices();
- if (hasWebServices(endpointServices))
+ final List<WebserviceInfo> webServices = esbMetaData.getModel().getWebserviceServices();
+ if (hasWebServices(webServices))
{
log.debug("Deploying webservices for : " + esbMetaData.getDeploymentName());
@@ -110,31 +113,32 @@
try
{
- // Create an in-memory file system
+ // Create an in-memory file system.
final URL inMemRootUrl = VfsUtil.createInMemUrl(esbMetaData.getDeploymentName());
final VirtualFile inMemRootDir = VfsUtil.createInMemoryFs(inMemRootUrl);
// Attach the in-memory classpath URL and virtual file to this deployment unit so we can remove then upon undeploy.
- deploymentUnit.addAttachment(DYNAMIC_CL_URL_KEY, inMemRootUrl);
- deploymentUnit.addAttachment(DYNAMIC_CL_DIR_KEY, inMemRootDir);
+ attachToDeploymentUnit(unit, inMemRootUrl, inMemRootDir);
// Add the in-memory classpath to this deployment unit.
- deploymentUnit.addClassPath(inMemRootDir);
+ unit.addClassPath(inMemRootDir);
- // Create WEB-INF/classes relative to the in-memory root.
+ // Create WEB-INF/classes relative to the in-memory vfs root.
final URL classesUrl = VfsUtil.createInMemUrl(inMemRootUrl, "/WEB-INF/classes");
final VirtualFile classesDir = MemoryFileFactory.createDirectory(classesUrl);
- deploymentUnit.addClassPath(classesDir);
+
+ // Add the in-memory classes dir to this deployment unit.
+ unit.addClassPath(classesDir);
final JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator();
- for (WebserviceInfo webserviceInfo : endpointServices)
+ for (WebserviceInfo wsInfo : webServices)
{
- final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo);
+ final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(wsInfo);
final String handlers = JBossDeployerUtil.getHandlers(serviceInfo);
- final boolean includeHandlers = (handlers != null);
+ final boolean includeHandlers = handlers != null;
if (includeHandlers)
{
- deploymentUnit.appendMetaDataLocation(classesDir);
+ unit.appendMetaDataLocation(classesDir);
final String wsHandlerName = serviceInfo.getPackageName().replace('.', '/') + "/esb-jaxws-handlers.xml";
VfsUtil.addFile(classesUrl, wsHandlerName, handlers.getBytes());
}
@@ -144,12 +148,13 @@
filters.add(createFilter(serviceInfo));
}
- final Service service = webserviceInfo.getService();
+ final Service service = wsInfo.getService();
// Generate the servlet class bytes
final byte[] servletClass = generator.generate(service.getCategory(), service.getName(), serviceInfo, includeHandlers);
final String servletClassName = serviceInfo.getClassName().replace('.', '/') + ".class";
final URL servletClassUrl = new URL(classesUrl + "/" + servletClassName);
+
// Add the servlet to the virtual file system.
VfsUtil.addFile(classesUrl, servletClassName, servletClass);
log.debug("Generated ws impl: " + servletClassUrl);
@@ -157,13 +162,13 @@
servlets.add(createServlets(service, serviceInfo, generator, includeHandlers));
servletMappings.add(createServletMapping(serviceInfo));
- WebserviceDescriptionMetaData description = new WebserviceDescriptionMetaData();
+ final WebserviceDescriptionMetaData description = new WebserviceDescriptionMetaData();
description.setName(esbMetaData.getDeploymentName());
description.setWebserviceDescriptionName(esbMetaData.getDeploymentName());
description.setWsdlPublishLocation(serviceInfo.getWSDLFileName());
descriptions.add(description);
- final ContractReferencePublisher publisher = new ESBServiceContractPublisher(service, webserviceInfo.getDescription(), serviceInfo.getServletName());
+ final ContractReferencePublisher publisher = new ESBServiceContractPublisher(service, wsInfo.getDescription(), serviceInfo.getServletName());
publishers.add(publisher);
}
}
@@ -179,10 +184,16 @@
webMetaData.setWebserviceDescriptions(descriptions);
esbMetaData.setPublishers(publishers);
- deploymentUnit.addAttachment(JBossWebMetaData.class, webMetaData);
+ unit.addAttachment(JBossWebMetaData.class, webMetaData);
}
}
+ private void attachToDeploymentUnit(final VFSDeploymentUnit unit, final URL url, final VirtualFile vf)
+ {
+ unit.addAttachment(DYNAMIC_CL_URL_KEY, url);
+ unit.addAttachment(DYNAMIC_CL_DIR_KEY, vf);
+ }
+
@Override
public void undeploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
{
@@ -219,10 +230,10 @@
private ServletMappingMetaData createServletMapping(final ESBServiceEndpointInfo serviceInfo)
{
- final ServletMappingMetaData servletMapping = new ServletMappingMetaData();
- servletMapping.setServletName(serviceInfo.getServletName());
- servletMapping.setUrlPatterns(Arrays.asList(new String[] { serviceInfo.getServletPath()}));
- return servletMapping;
+ final ServletMappingMetaData mapping = new ServletMappingMetaData();
+ mapping.setServletName(serviceInfo.getServletName());
+ mapping.setUrlPatterns(Arrays.asList(new String[] { serviceInfo.getServletPath()}));
+ return mapping;
}
private JBossServletMetaData createServlets(final Service service, final ESBServiceEndpointInfo serviceInfo, final JAXWSProviderClassGenerator generator, final boolean includeHandlers) throws WebServicePublishException
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-05-14 12:35:30 UTC (rev 26533)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployer.java 2009-05-14 12:42:01 UTC (rev 26534)
@@ -61,14 +61,14 @@
/**
* Key used for attaching a VirtualFile representing a ref to
- * a dynamically created virtual file system.
+ * a dynamically created in-memory virtual file system.
*/
private static final String DYNAMIC_CL_DIR_KEY = "WSDL-DYNAMIC-CL-DIR";
/**
- * Key used for attaching a VirtualFile representing a ref to
- * a dynamically created virtual file system.
+ * Key used for attaching a URL representing a ref to
+ * a dynamically created in-memory virtual file system.
*/
private static final String DYNAMIC_CL_URL_KEY = "WSDL-DYNAMIC-CL-URL";
@@ -83,7 +83,9 @@
public EsbWsdlDeployer()
{
super(EsbMetaData.class);
+ // Need access to classloaders.
setStage(DeploymentStages.POST_CLASSLOADER);
+ // Tell the MicroContainer that we are producing UnifiedMetaData.
setOutput(UnifiedMetaData.class);
}
@@ -96,44 +98,40 @@
* virtual file system.
* <p/>
*
- * @param deploymentUnit The {@link VFSDeploymentUnit} for this deploment.
+ * @param unit The {@link VFSDeploymentUnit} for this deploment.
* @param esbMetaData The {@link EsbMetaData} for this deployment.
*/
@Override
- public void deploy(final VFSDeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException
+ public void deploy(final VFSDeploymentUnit unit, final EsbMetaData esbMetaData) throws DeploymentException
{
- final List<WebserviceInfo> endpointServices = esbMetaData.getModel().getWebserviceServices();
- if (endpointServices != null && endpointServices.size() > 0)
+ final List<WebserviceInfo> webServices = esbMetaData.getModel().getWebserviceServices();
+ if (webServices != null && webServices.size() > 0)
{
try
{
- final String inMemoryRoot = esbMetaData.getDeploymentName() + "_WSDL";
- final URL inMemRootUrl = VfsUtil.createInMemUrl(inMemoryRoot);
+ final String inMemRootName = esbMetaData.getDeploymentName() + "_WSDL";
+ final URL inMemRootUrl = VfsUtil.createInMemUrl(inMemRootName);
final VirtualFile inMemRootDir = VfsUtil.createInMemoryFs(inMemRootUrl);
// Attach the in-memory classpath URL and virtual file to this deployment unit so we can remove then upon undeploy.
- deploymentUnit.addAttachment(DYNAMIC_CL_URL_KEY, inMemRootUrl);
- deploymentUnit.addAttachment(DYNAMIC_CL_DIR_KEY, inMemRootDir);
+ attachToDeploymentUnit(unit, inMemRootUrl, inMemRootDir);
- for (WebserviceInfo webserviceInfo : endpointServices)
+ for (WebserviceInfo wsInfo : webServices)
{
- final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo);
- final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo, deploymentUnit.getClassLoader());
+ // Generate the wsdl for the web service.
+ final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(wsInfo);
+ final String wsdl = ESBContractGenerator.generateWSDL(wsInfo, serviceInfo, unit.getClassLoader());
final URL wsdlUrl = new URL(inMemRootUrl + "/" + serviceInfo.getWSDLFileName());
log.info("Generating wsdl url : " + wsdlUrl);
// Add the wsdl in the virtual file system
VirtualFile putFile = VfsUtil.addFile(inMemRootUrl, serviceInfo.getWSDLFileName(), wsdl.getBytes());
- //VirtualFile putFile = MemoryFileFactory.putFile(wsdlUrl, wsdl.getBytes());
- // Get any other schemas in the deployment. They might be imports.
- List<VirtualFile> schemas = getAllSchemas(deploymentUnit.getRoot());
+ // Add any additional schemas in the deployment unit to the in-memory vfs.
+ addSchemasToVfs(getSchemas(unit.getRoot()), putFile.getParent(), esbMetaData.getArchiveName());
- // Add the imports to the in-memory virtual file system.
- addSchemasToVfs(schemas, putFile.getParent(), esbMetaData.getArchiveName());
-
// Add the root of the virtual file system as a meta data location.
- deploymentUnit.appendMetaDataLocation(inMemRootDir);
+ unit.appendMetaDataLocation(inMemRootDir);
}
}
catch (final Exception e)
@@ -143,6 +141,12 @@
}
}
+ private void attachToDeploymentUnit(final VFSDeploymentUnit unit, final URL url, final VirtualFile vf)
+ {
+ unit.addAttachment(DYNAMIC_CL_URL_KEY, url);
+ unit.addAttachment(DYNAMIC_CL_DIR_KEY, vf);
+ }
+
/**
* Retrieves all the schemas (.xsd) from the virtual file root passed in.
*
@@ -150,7 +154,7 @@
* @return List<VirtualFile> List of virtual files that are schemas.
* @throws IOException If an exception in the search occurs.
*/
- List<VirtualFile> getAllSchemas(final VirtualFile root) throws IOException
+ List<VirtualFile> getSchemas(final VirtualFile root) throws IOException
{
return root.getChildrenRecursively(schemaFileFilter);
}
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtil.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtil.java 2009-05-14 12:35:30 UTC (rev 26533)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/util/VfsUtil.java 2009-05-14 12:42:01 UTC (rev 26534)
@@ -26,9 +26,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
-import java.util.regex.Pattern;
-import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.util.StreamUtils;
import org.jboss.virtual.MemoryFileFactory;
import org.jboss.virtual.VirtualFile;
@@ -42,10 +40,11 @@
*/
public final class VfsUtil
{
+ /**
+ * Protocol for VFS in-memory URLs.
+ */
private static final String IN_MEMORY_PROTOCOL = "vfsmemory";
- private static Logger log = Logger.getLogger(VfsUtil.class);
-
private VfsUtil() {}
/**
@@ -57,7 +56,6 @@
*/
public static VirtualFile createInMemoryFs(final URL rootUrl) throws IOException
{
- //log.info("Creating in-memory fs : '" + rootUrl + "'");
return MemoryFileFactory.createRoot(rootUrl).getRoot();
}
@@ -142,7 +140,6 @@
return pathPrefix + filePath;
}
}
-
return path;
}
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployerUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployerUnitTest.java 2009-05-14 12:35:30 UTC (rev 26533)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbWsdlDeployerUnitTest.java 2009-05-14 12:42:01 UTC (rev 26534)
@@ -51,7 +51,7 @@
{
final VirtualFile virtualFile = VFS.getVirtualFile(dir, "exploded-esb-archive.esb");
final EsbWsdlDeployer esbWsdlDeployer = new EsbWsdlDeployer();
- final List<VirtualFile> schemas = esbWsdlDeployer.getAllSchemas(virtualFile);
+ final List<VirtualFile> schemas = esbWsdlDeployer.getSchemas(virtualFile);
assertNotNull(schemas);
assertEquals(2, schemas.size());
@@ -62,7 +62,7 @@
final String archiveName = "exploded-esb-archive.esb";
final VirtualFile virtualFile = VFS.getVirtualFile(dir, archiveName);
final EsbWsdlDeployer esbWsdlDeployer = new EsbWsdlDeployer();
- final List<VirtualFile> schemas = esbWsdlDeployer.getAllSchemas(virtualFile);
+ final List<VirtualFile> schemas = esbWsdlDeployer.getSchemas(virtualFile);
final URL dynamicClassRootUrl = new URL("vfsmemory", "junit", "");
final VirtualFile dynamicClasspathDir = MemoryFileFactory.createRoot(dynamicClassRootUrl).getRoot();
@@ -71,7 +71,7 @@
esbWsdlDeployer.addSchemasToVfs(schemas, putFile.getParent(), archiveName);
- final List<VirtualFile> addedSchemas = esbWsdlDeployer.getAllSchemas(dynamicClasspathDir);
+ final List<VirtualFile> addedSchemas = esbWsdlDeployer.getSchemas(dynamicClasspathDir);
assertNotNull(addedSchemas);
assertEquals(2, addedSchemas.size());
More information about the jboss-svn-commits
mailing list