[jboss-svn-commits] JBL Code SVN: r25798 - in labs/jbossesb/workspace/dbevenius/jbossas5/product: rosetta/src/org/jboss/soa/esb/listeners/config and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 24 09:28:57 EDT 2009
Author: beve
Date: 2009-03-24 09:28:57 -0400 (Tue, 24 Mar 2009)
New Revision: 25798
Added:
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBossDeployerUtil.java
Removed:
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java
Modified:
labs/jbossesb/workspace/dbevenius/jbossas5/product/install/build.xml
labs/jbossesb/workspace/dbevenius/jbossas5/product/install/esb-deployers-jboss-beans.xml
labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
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/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParserUnitTest.xml
Log:
Still a work in progress but deploys with esb-console.war.
Still have work on the deployers to complete.
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/install/build.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/install/build.xml 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/install/build.xml 2009-03-24 13:28:57 UTC (rev 25798)
@@ -162,7 +162,7 @@
<!-- soapui-client.sar -->
<copy todir="${deploy.dir}/soapui-client.sar">
- <fileset dir="${org.jboss.esb.dist.lib}/soapui-client.sar" excludes="${messaging.excludes}, META-INF/jbossesb-service-as5.xml"/>
+ <fileset dir="${org.jboss.esb.dist.lib}/soapui-client.sar" excludes="${messaging.excludes}, META-INF/jboss-service-as5.xml"/>
</copy>
<!-- contracts app -->
@@ -295,7 +295,7 @@
<!-- soapui-client.sar -->
<copy todir="${deploy.dir}/soapui-client.sar">
- <fileset dir="${org.jboss.esb.dist.lib}/soapui-client.sar" excludes="${messaging.excludes}, META-INF/jbossesb-service-as5.xml"/>
+ <fileset dir="${org.jboss.esb.dist.lib}/soapui-client.sar" excludes="${messaging.excludes} META-INF/jboss-service-as5.xml"/>
</copy>
<copy tofile="${deploy.dir}/soapui-client.sar/META-INF/jboss-service.xml" file="${org.jboss.esb.dist.lib}/soapui-client.sar/META-INF/jboss-service-as5.xml" overwrite="true"/>
@@ -305,24 +305,17 @@
<!-- install h2 jar -->
<copy file="${org.jboss.esb.dist.lib}/h2-1.0.68.jar" todir="${server.lib.dir}"/>
- <!-- embedded jopr console
+ <!-- embedded jopr console -->
<ant dir="embedded-console" target="replace">
<property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
<property name="org.jboss.esb.server.config" value="${org.jboss.esb.server.config}"/>
</ant>
- -->
<ant dir="jbpm-patch" target="replace">
<property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
<property name="org.jboss.esb.server.config" value="${org.jboss.esb.server.config}"/>
</ant>
- <!--
- <ant dir="${product.dir}/tools/console/management-esb" target="deploy">
- <property name="org.jboss.esb.server.home" value="${org.jboss.esb.server.home}"/>
- <property name="org.jboss.esb.server.config" value="${org.jboss.esb.server.config}"/>
- </ant>
- -->
</target>
<target name="undeploy" depends="check.deploy.props, undeploy.bindings" description="Undeploy ESB components.">
@@ -334,13 +327,15 @@
<delete dir="${deploy.dir}/spring.esb" quiet="true"/>
<delete dir="${deploy.dir}/soap.esb" quiet="true"/>
<delete dir="${deploy.dir}/soapui-client.sar" quiet="true"/>
- <delete dir="${deploy.dir}/contract.war" quiet="true"/>
- <delete dir="${conf.dir}/action-templates.xml" quiet="true"/>
- <!--antcall target="undeploy.jbossas5"/-->
+ <delete file="${deploy.dir}/contract.war" quiet="true"/>
+ <delete file="${deploy.dir}/esb-console.war"/>
+ <delete file="${deploy.dir}/management.esb" quiet="true"/>
+ <delete file="${conf.dir}/action-templates.xml" quiet="true"/>
+ <antcall target="undeploy.jbossas5"/>
</target>
<target name="undeploy.jbossas5" if="jbossas5" >
- <delete dir="${server.dir}/deployers" quiet="true"/>
+ <delete dir="${server.dir}/deployers/esb.deployer"/>
</target>
<property name="org.jboss.esb.tomcat.55lib"
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/install/esb-deployers-jboss-beans.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/install/esb-deployers-jboss-beans.xml 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/install/esb-deployers-jboss-beans.xml 2009-03-24 13:28:57 UTC (rev 25798)
@@ -4,18 +4,12 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Make MC aware of .esb suffixes -->
- <bean name="EsbExtensionProvider" class="org.jboss.soa.esb.listeners.deployers.mc.EsbExtensionProvider"/>
- <bean name="EsbStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
- <incallback method="addJarExtension">
- <parameter><inject bean="EsbExtensionProvider"/></parameter>
- </incallback>
- </bean>
-
<!-- Will pickup and parse jboss-esb.xml configuration files from esb archives. -->
<bean name="EsbConfigParser" class="org.jboss.soa.esb.listeners.deployers.mc.EsbConfigParser"/>
- <!-- Will create the BeanMetaData that describes a esb deployment -->
- <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer"/>
+ <!-- Will create the BeanMetaData that describes a esb deployment -->
+ <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer">
+ <property name="serverTmpDir">${jboss.server.temp.dir}</property>
+ </bean>
</deployment>
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -167,7 +167,6 @@
*/
protected void startService() throws Exception
{
- log.info("starting JBossESBDeployer service");
final InputStream actionArtifactIS = ClassUtil.getResourceAsStream("/actionArtifactMap.properties", getClass()) ;
if (actionArtifactIS == null)
{
@@ -187,7 +186,6 @@
mainDeployer.addDeployer(this);
LifecycleResourceManager.deactivateHook() ;
- log.info("done starting JBossESBDeployer service");
}
@Override
Added: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBossDeployerUtil.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBossDeployerUtil.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBossDeployerUtil.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors 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.soa.esb.listeners.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.webservice.AddressingHandler;
+import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
+import org.jboss.mx.util.MBeanProxyExt;
+import org.jboss.system.server.ServerConfig;
+import org.jboss.system.server.ServerConfigImplMBean;
+
+/**
+ * Util class for JBoss AS Deployers.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JBossDeployerUtil
+{
+ private static final String HANDLER_CHAIN_PREFIX = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<handler-chains xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd\">" + "<handler-chain><protocol-bindings>##SOAP11_HTTP</protocol-bindings>";
+ private static final String HANDLER_CHAIN_POSTFIX = "</handler-chain></handler-chains>";
+ private static final String HANDLER_PREFIX = "<handler><handler-name>";
+ private static final String HANDLER_MIDDLE = "</handler-name><handler-class>";
+ private static final String HANDLER_POSTFIX = "</handler-class></handler>";
+
+ private static final String WSADDR_NAME = "WSAddressing Handler";
+ private static final String WSADDR_HANDLER = "org.jboss.ws.extensions.addressing.jaxws.WSAddressingServerHandler";
+
+ private static final String WSADDR_CONTEXT_NAME = "WSAddressing Context Handler";
+ private static final String WSADDR_CONTEXT_HANDLER = AddressingHandler.class.getName();
+
+ private JBossDeployerUtil()
+ {
+ }
+
+ public static String getHandlers(final ESBServiceEndpointInfo serviceInfo)
+ {
+ final String result;
+
+ if (!serviceInfo.isAddressing())
+ {
+ result = null;
+ } else
+ {
+ final StringBuilder sb = new StringBuilder(HANDLER_CHAIN_PREFIX);
+ if (serviceInfo.isAddressing())
+ {
+ sb.append(HANDLER_PREFIX).append(WSADDR_CONTEXT_NAME).append(HANDLER_MIDDLE).append(WSADDR_CONTEXT_HANDLER).append(HANDLER_POSTFIX);
+ sb.append(HANDLER_PREFIX).append(WSADDR_NAME).append(HANDLER_MIDDLE).append(WSADDR_HANDLER).append(HANDLER_POSTFIX);
+ }
+ sb.append(HANDLER_CHAIN_POSTFIX);
+ result = sb.toString();
+ }
+ return result;
+ }
+
+ public static void addFile(final ZipOutputStream zos, final String filename, final String contents) throws IOException
+ {
+ addFile(zos, filename, contents.getBytes());
+ }
+
+ public static void addFile(final ZipOutputStream zos, final String filename, final byte[] contents) throws IOException
+ {
+ final ZipEntry entry = new ZipEntry(filename);
+ zos.putNextEntry(entry);
+ zos.write(contents);
+ zos.closeEntry();
+ }
+
+ public static File getESBWarFile(final String deploymentName, final String esbName, final boolean createDir, final File dir)
+ {
+ final File esbDir = new File(dir, deploymentName) ;
+ if (!esbDir.exists())
+ {
+ if (!createDir)
+ {
+ return null ;
+ }
+ esbDir.mkdir() ;
+ }
+
+ final int lastSeparator = esbName.lastIndexOf('.') ;
+ final String warFileName = ((lastSeparator >= 0) ? esbName.substring(0, lastSeparator) : esbName) + ".war" ;
+
+ return new File(esbDir, warFileName) ;
+ }
+
+ public static File createWarFilesDir(final String tmpDirName, String warFileDirName)
+ {
+ AssertArgument.isNotNullAndNotEmpty(tmpDirName, "tmpDirName");
+
+ final File tmpDir = new File(tmpDirName);
+ final File esbWarFiles = new File(tmpDir, warFileDirName) ;
+ esbWarFiles.mkdirs() ;
+ return esbWarFiles;
+ }
+
+ public static String readEsbConfig(final InputStream in) throws DeploymentException
+ {
+ try
+ {
+ final StringWriter sw = new StringWriter() ;
+ XMLHelper.replaceSystemProperties(XMLHelper.getXMLStreamReader(in), XMLHelper.getXMLStreamWriter(sw)) ;
+ return sw.toString();
+ }
+ catch (XMLStreamException e)
+ {
+ throw new DeploymentException(e.getMessage(), e);
+ }
+ finally
+ {
+ try { in.close(); } catch (IOException ignore) {}
+ }
+
+ }
+
+
+
+}
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-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParser.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -59,6 +59,11 @@
* The default suffix of JBossESB archives that should be accepted.
*/
private static final String ESB_ARCHIVE_SUFFIX = ".esb";
+
+ /**
+ * File filter for esb config files.
+ */
+ private static EsbConfigFileFilter configFileFileter = new EsbConfigFileFilter();
/**
* No args constructor.
@@ -97,7 +102,7 @@
List<VirtualFile> esbConfigFiles;
try
{
- esbConfigFiles = file.getChildrenRecursively(new EsbConfigFileFilter());
+ esbConfigFiles = file.getChildrenRecursively(configFileFileter);
}
catch (final IOException e)
{
@@ -119,6 +124,7 @@
return esbConfigFiles.get(0);
}
}
+
/**
* Filter for filtering out ESB configuration files.
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-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployer.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -20,9 +20,17 @@
*/
package org.jboss.soa.esb.listeners.deployers.mc;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import java.util.zip.ZipOutputStream;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -30,22 +38,42 @@
import org.apache.log4j.Logger;
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployment.DeploymentException;
+import org.jboss.internal.soa.esb.publish.ContractReferencePublisher;
+import org.jboss.internal.soa.esb.webservice.ESBContractGenerator;
+import org.jboss.internal.soa.esb.webservice.ESBResponseFilter;
+import org.jboss.internal.soa.esb.webservice.ESBServiceContractPublisher;
+import org.jboss.internal.soa.esb.webservice.ESBServiceEndpointInfo;
+import org.jboss.internal.soa.esb.webservice.JAXWSProviderClassGenerator;
import org.jboss.metadata.MetaData;
import org.jboss.metadata.XmlFileLoader;
+import org.jboss.soa.esb.Service;
import org.jboss.soa.esb.listeners.config.JBoss4ESBDeployment;
+import org.jboss.soa.esb.listeners.config.JBossDeployerUtil;
+import org.jboss.soa.esb.listeners.config.WebserviceInfo;
+import org.jboss.soa.esb.listeners.config.model.ModelAdapter;
+import org.jboss.soa.esb.listeners.config.model.ModelParser;
import org.jboss.virtual.VirtualFile;
import org.w3c.dom.Element;
/**
- * EsbRuntimeDeployer takes care of the deployment of an {@link BeanMetaData} instance.
- * This deployer actually only creates a BeanMetaData object describing a {@link EsbDeployment}.
- * The MicroContainer will take care of the actual creation and starting of the deployment
- * using it's lifecycle callbacks.
- * <p/>
+ * EsbRuntimeDeployer takes care of the deployment of an {@link BeanMetaData}
+ * instance.
*
+ * This deployer actually only creates a BeanMetaData object describing a
+ * {@link EsbDeployment}. The MicroContainer will take care of the actual
+ * creation and starting of the deployment using it's lifecycle callbacks. <p/>
+ *
+ * Example configuration:
+ * <pre>{@code
+ * <bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer">
+ * <property name="serverTmpDir">${jboss.server.temp.dir}</property>
+ * </bean>
+ * }</pre>
+ *
* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
public class EsbDeployer extends AbstractSimpleRealDeployer<EsbMetaData>
@@ -61,6 +89,12 @@
private static final String BEAN_PREFIX = "jboss.esb";
/**
+ * A temp directory where esb war files will be created. Will be set
+ * by MC and must be set as a property in -beans.xml.
+ */
+ private String tmpDir;
+
+ /**
* No args constructor.
*/
public EsbDeployer()
@@ -69,40 +103,56 @@
// Tell the MicroContainer that we are producing BeanMetaData.
setOutput(BeanMetaData.class);
- setRelativeOrder(1000);
-
- log.info("Created EsbDeployer with a relative deployment order of " + getRelativeOrder());
+ // Will be using classloaders.
+ setStage(DeploymentStages.POST_CLASSLOADER);
}
/**
* Creates an {@link BeanMetaData} instance that describes the JBossESB
- * deployment.
- * The BeanMetaData is created using the information from the
+ * deployment. The BeanMetaData is created using the information from the
* EsbMetaData object, such as the jboss-esb.xml and the archive name.
*
* The BeanMeatData is then attached to the Microcontainers deployment unit
* and will be picked up by the BeanMetaDataDeployer.
*
- * @param deploymentUnit The deployment unit to deploy.
- * @param esbMetaData The ESB MetaData that is associated with the deployment unit.
+ * @param deploymentUnit
+ * The deployment unit to deploy.
+ * @param esbMetaData
+ * The ESB MetaData that is associated with the deployment unit.
*/
@Override
- public final void deploy(final DeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
+ public final void deploy(final DeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws org.jboss.deployers.spi.DeploymentException
{
- final BeanMetaData beanMetaData = createBeanMetaData(deploymentUnit, esbMetaData);
- deploymentUnit.addAttachment(BeanMetaData.class, beanMetaData);
-
- log.debug("Created beanMetaData : " + beanMetaData);
+ try
+ {
+ BeanMetaData beanMetaData = createBeanMetaData(deploymentUnit, esbMetaData);
+ deploymentUnit.addAttachment(BeanMetaData.class.getName() + "_ESB" , beanMetaData);
+ log.debug("Created beanMetaData : " + beanMetaData);
+ }
+ catch (DeploymentException e)
+ {
+ throw new org.jboss.deployers.spi.DeploymentException(e.getMessage(), e);
+ }
+ catch (IOException e)
+ {
+ throw new org.jboss.deployers.spi.DeploymentException(e.getMessage(), e);
+ }
}
/**
- * Creates a {@link BeanMetaData} that describes the {@link JBoss4ESBDeployment} class.
+ * Creates a {@link BeanMetaData} that describes the
+ * {@link JBoss4ESBDeployment} class.
*
- * @param deploymentUnit The deployment unit to deploy.
- * @param esbMetaData The ESB MetaData that is associated with the deployment unit.
- * @return BeanMetaData The {@link BeanMetaData} describing the EsbDeployment.
+ * @param deploymentUnit
+ * The deployment unit to deploy.
+ * @param esbMetaData
+ * The ESB MetaData that is associated with the deployment unit.
+ * @return BeanMetaData The {@link BeanMetaData} describing the
+ * EsbDeployment.
+ * @throws IOException
+ * @throws DeploymentException
*/
- private BeanMetaData createBeanMetaData(final DeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
+ private BeanMetaData createBeanMetaData(final DeploymentUnit deploymentUnit, final EsbMetaData esbMetaData) throws DeploymentException, IOException
{
BeanMetaDataBuilder bmdBuilder = BeanMetaDataBuilder.createBuilder(BEAN_PREFIX + "." + deploymentUnit.getName(), EsbDeployment.class.getName());
// Setup the first constructor argument (esb config file).
@@ -138,68 +188,187 @@
bmdBuilder.addDependency(depOn.getCanonicalName());
}
}
- // TODO: Refactor and add the rest from jboss4.x deployment. Extract the code
- /*
Iterator esbDepends = MetaData.getChildrenByTagName(jboss, "esb-depends");
if ((esbDepends != null) && esbDepends.hasNext())
{
- final Map<String, DeploymentInfo> subDeploymentLocationMap;
- if (di.subDeployments.size() > 0)
+ Element depend = (Element)esbDepends.next();
+ final String deployable = MetaData.getElementContent(depend) ;
+ if (deployable.endsWith(".war"))
{
- subDeploymentLocationMap = new HashMap<String, DeploymentInfo>();
- final Set<DeploymentInfo> subDeployments = (Set<DeploymentInfo>) di.subDeployments;
- for (DeploymentInfo subDI : subDeployments)
- {
- final String urlPath = subDI.url.getPath();
- final String deployablePath = (urlPath.endsWith("/") ? urlPath.substring(0, urlPath.length() - 1) : urlPath);
- final int lastSeparator = deployablePath.lastIndexOf('/');
- final String deployable = (lastSeparator >= 0 ? deployablePath.substring(lastSeparator + 1) : deployablePath);
- if (subDeploymentLocationMap.put(deployable, subDI) != null)
- {
- throw new DeploymentException("Duplicate subDeployment name: " + deployable);
- }
- }
- } else
- {
- throw new DeploymentException("No subdeployments to match esb-depends");
+ String objectName = "jboss.web.deployment:war=/" + deployable.substring(0, deployable.indexOf('.'));
+ log.info("war objectName : " + objectName);
+ bmdBuilder.addDependency(objectName);
}
-
- do
- {
- Element depend = (Element) esbDepends.next();
- final String deployable = MetaData.getElementContent(depend);
- final DeploymentInfo subDI = subDeploymentLocationMap.get(deployable);
- if ((subDI != null) && subDI.context.containsKey(AbstractWebContainer.WEB_MODULE))
- {
- final ObjectName jmxName = (ObjectName) subDI.context.get(AbstractWebContainer.WEB_MODULE);
- bmdBuilder.addDependency(jmxName);
- } else
- {
- throw new DeploymentException("Could not locate WAR subdeployment matching: " + deployable);
- }
- } while (esbDepends.hasNext());
}
- */
}
- catch (final DeploymentException e)
- {
- e.printStackTrace();
- }
catch (final MalformedObjectNameException e)
{
- e.printStackTrace();
+ throw new org.jboss.deployment.DeploymentException(e.getMessage(), e);
}
- catch (final NullPointerException e)
- {
- e.printStackTrace();
- }
finally
{
- try { in.close(); } catch (IOException ignore) { }
+ try { in.close(); } catch (IOException ignore) { }
}
}
+
+ final String jbossEsbXml = JBossDeployerUtil.readEsbConfig(esbMetaData.getEsbConfigXml().openStream()) ;
+ final ModelAdapter model = getJbossEsbModel(jbossEsbXml) ;
+
+ // create webservice WAR
+ final ClassLoader origCL = Thread.currentThread().getContextClassLoader() ;
+ final List<ContractReferencePublisher> publishers = new ArrayList<ContractReferencePublisher>() ;
+ final File warFile ;
+ try
+ {
+ Thread.currentThread().setContextClassLoader(deploymentUnit.getClassLoader());
+ warFile = createWebserviceWars(deploymentUnit.getSimpleName(), model, esbMetaData.getArchiveName(), publishers) ;
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(origCL) ;
+ }
+
+ /*
+ if (warFile != null)
+ {
+ deployment.setPublishers(publishers) ;
+ final URL warFileURL = warFile.toURL() ;
+ deployUrl(di, warFileURL, warFile.getName()) ;
+ }
+ */
return bmdBuilder.getBeanMetaData();
}
+
+ private File createWebserviceWars(final String esbName, final ModelAdapter model, final String deploymentName, final List<ContractReferencePublisher> publishers) throws DeploymentException
+ {
+ File warFilesDir = JBossDeployerUtil.createWarFilesDir(tmpDir, "esbwarfiles");
+
+ final List<WebserviceInfo> endpointServices = model.getWebserviceServices() ;
+ if (endpointServices != null)
+ {
+ if (endpointServices.size() > 0)
+ {
+ final StringWriter filterDefinitions = new StringWriter() ;
+ final StringWriter filterMappings = new StringWriter() ;
+ final StringWriter servletDefinitions = new StringWriter() ;
+ final StringWriter servletMappings = new StringWriter() ;
+
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
+ final ZipOutputStream zos = new ZipOutputStream(baos) ;
+ zos.setComment("ESB war file for exposing webservices: " + esbName) ;
+ try
+ {
+ final JAXWSProviderClassGenerator generator = new JAXWSProviderClassGenerator() ;
+
+ for(WebserviceInfo webserviceInfo: endpointServices)
+ {
+ final ESBServiceEndpointInfo serviceInfo = new ESBServiceEndpointInfo(webserviceInfo) ;
+ final String wsdl = ESBContractGenerator.generateWSDL(webserviceInfo, serviceInfo) ;
+ JBossDeployerUtil.addFile(zos, serviceInfo.getWSDLFileName(), wsdl) ;
+
+ final Service service = webserviceInfo.getService() ;
+ final String handlers = JBossDeployerUtil.getHandlers(serviceInfo) ;
+ final boolean includeHandlers = (handlers != null) ;
+ if (includeHandlers)
+ {
+ final String wsHandlerName = "WEB-INF/classes/" + serviceInfo.getPackageName().replace('.', '/') + "/esb-jaxws-handlers.xml" ;
+ JBossDeployerUtil.addFile(zos, wsHandlerName, handlers) ;
+ }
+
+ final byte[] wsClass = generator.generate(service.getCategory(),
+ service.getName(), serviceInfo, includeHandlers) ;
+ final String wsClassName = serviceInfo.getClassName().replace('.', '/') + ".class" ;
+ JBossDeployerUtil.addFile(zos, "WEB-INF/classes/" + wsClassName, wsClass) ;
+ // Filter...
+ // At the moment we only need the filter to overcome a bug in JBossWS re In-Only endpoints, so
+ // we only include for one way services...
+ if(serviceInfo.isOneWay()) {
+ String filterName = serviceInfo.getServletName() + "_Filter";
+
+ filterDefinitions.append("<filter><filter-name>") ;
+ filterDefinitions.append(filterName) ;
+ filterDefinitions.append("</filter-name><filter-class>") ;
+ filterDefinitions.append(ESBResponseFilter.class.getName()) ;
+ filterDefinitions.append("</filter-class>") ;
+ filterDefinitions.append("<init-param><param-name>OneWay</param-name><param-value>true</param-value></init-param>") ;
+ filterDefinitions.append("</filter>") ;
+
+ filterMappings.append("<filter-mapping><filter-name>") ;
+ filterMappings.append(filterName) ;
+ filterMappings.append("</filter-name><servlet-name>") ;
+ filterMappings.append(serviceInfo.getServletName()) ;
+ filterMappings.append("</servlet-name></filter-mapping>") ;
+ }
+
+ // Servlet....
+ servletDefinitions.append("<servlet><servlet-name>") ;
+ servletDefinitions.append(serviceInfo.getServletName()) ;
+ servletDefinitions.append("</servlet-name><servlet-class>") ;
+ servletDefinitions.append(serviceInfo.getClassName()) ;
+ servletDefinitions.append("</servlet-class></servlet>") ;
+
+ servletMappings.append("<servlet-mapping><servlet-name>") ;
+ servletMappings.append(serviceInfo.getServletName()) ;
+ servletMappings.append("</servlet-name><url-pattern>") ;
+ servletMappings.append(serviceInfo.getServletPath()) ;
+ servletMappings.append("</url-pattern></servlet-mapping>") ;
+
+ final ContractReferencePublisher publisher = new ESBServiceContractPublisher(service, webserviceInfo.getDescription(), serviceInfo.getServletName()) ;
+ publishers.add(publisher) ;
+ }
+
+ final StringWriter webXml = new StringWriter() ;
+ webXml.append("<web-app xmlns=\"http://java.sun.com/xml/ns/j2ee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"") ;
+ webXml.append(" xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" version=\"2.4\">") ;
+ webXml.append(filterDefinitions.getBuffer()) ;
+ webXml.append(filterMappings.getBuffer()) ;
+ webXml.append(servletDefinitions.getBuffer()) ;
+ webXml.append(servletMappings.getBuffer()) ;
+ webXml.append("</web-app>") ;
+
+ JBossDeployerUtil.addFile(zos, "WEB-INF/web.xml", webXml.toString()) ;
+ zos.close() ;
+
+ final File warFile = JBossDeployerUtil.getESBWarFile(deploymentName, esbName, true, warFilesDir) ;
+
+ final FileOutputStream fos = new FileOutputStream(warFile) ;
+ fos.write(baos.toByteArray()) ;
+ fos.close() ;
+ return warFile ;
+ }
+ catch (final Exception ex)
+ {
+ throw new DeploymentException("Failed to create webservice artifact", ex) ;
+ }
+ }
+ }
+ return null ;
+ }
+
+ private ModelAdapter getJbossEsbModel(final String configuration) throws DeploymentException
+ {
+ try
+ {
+ final StringReader sr = new StringReader(configuration) ;
+ return ModelParser.getParser().parse(sr) ;
+ }
+ catch (final Exception ex)
+ {
+ throw new DeploymentException("Failed to parse jboss-esb.xml", ex) ;
+ }
+ }
+
+ /**
+ * Specifies a temp directory where ESBWS web applications will be
+ * created.
+ *
+ * @param tmpDir A tmp directory that cat be used for staging web applications.
+ */
+ public void setServerTmpDir(final String tmpDir)
+ {
+ this.tmpDir = tmpDir;
+ }
+
}
Deleted: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbExtensionProvider.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
- * LLC, and individual contributors 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.soa.esb.listeners.deployers.mc;
-
-import org.jboss.deployers.spi.deployer.matchers.JarExtensionProvider;
-
-/**
- * Simply adds the '.esb' extension.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class EsbExtensionProvider implements JarExtensionProvider
-{
- /**
- * Returns '.esb'.
- *
- * @return String The '.esb' extension.
- */
- public final String getJarExtension()
- {
- return ".esb";
- }
-
-}
Deleted: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbStructure.java 2009-03-24 13:28:57 UTC (rev 25798)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
- * LLC, and individual contributors 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.soa.esb.listeners.deployers.mc;
-
-import java.util.HashSet;
-
-import org.apache.log4j.Logger;
-import org.jboss.deployers.vfs.plugins.structure.jar.JARStructure;
-
-/**
- * A StructureDeployer that can identify .esb archives.
- *
- * A StructureDeployer is a deployer that runs prior to normal deployers.
- *
- * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
- *
- */
-public class EsbStructure extends JARStructure
-{
- /**
- * Logger.
- */
- private Logger log = Logger.getLogger(EsbStructure.class);
-
- /**
- * Suffix used to identify a esb archive(file or directory).
- */
- private static final String ESB_JAR_SUFFIX = ".esb";
-
- /**
- * The suffixes that this structure handles.
- */
- private HashSet<String> suffixes;
-
- /**
- *
- */
- public EsbStructure()
- {
- setRelativeOrder(1000);
- suffixes = new HashSet<String>();
- suffixes.add(ESB_JAR_SUFFIX);
- setSuffixes(suffixes);
- addJarExtension(null);
- log.info(this);
- }
-
- /**
- * Returns a string representation of this instance.
- * @return String The string representation of this instance.
- *
- */
- @Override
- public final String toString()
- {
- return "EsbStructure [suffixes='" + suffixes + "']";
- }
-
-
-}
Modified: labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParserUnitTest.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParserUnitTest.xml 2009-03-24 13:23:11 UTC (rev 25797)
+++ labs/jbossesb/workspace/dbevenius/jbossas5/product/rosetta/tests/src/org/jboss/soa/esb/listeners/deployers/mc/EsbConfigParserUnitTest.xml 2009-03-24 13:28:57 UTC (rev 25798)
@@ -6,14 +6,6 @@
<bean name="EsbConfigParser" class="org.jboss.soa.esb.listeners.deployers.mc.EsbConfigParser"/>
- <bean name="EsbExtensionProvider" class="org.jboss.soa.esb.listeners.deployers.mc.EsbExtensionProvider"/>
-
- <bean name="EsbStructure" class="org.jboss.deployers.vfs.plugins.structure.jar.JARStructure">
- <incallback method="addJarExtension">
- <parameter><inject bean="EsbExtensionProvider"/></parameter>
- </incallback>
- </bean>
-
<!-- bean name="EsbDeployer" class="org.jboss.soa.esb.listeners.deployers.mc.EsbDeployer"/-->
<bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
More information about the jboss-svn-commits
mailing list