[jboss-svn-commits] JBL Code SVN: r16050 - in labs/jbossesb/trunk/product: install/conf and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 24 10:41:19 EDT 2007
Author: kevin.conner at jboss.com
Date: 2007-10-24 10:41:19 -0400 (Wed, 24 Oct 2007)
New Revision: 16050
Added:
labs/jbossesb/trunk/product/install/conf/actionArtifactMap.properties
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java
Modified:
labs/jbossesb/trunk/product/build-distr.xml
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
Log:
Make esb dependencies implicit: JBESB-1104
Modified: labs/jbossesb/trunk/product/build-distr.xml
===================================================================
--- labs/jbossesb/trunk/product/build-distr.xml 2007-10-24 14:00:40 UTC (rev 16049)
+++ labs/jbossesb/trunk/product/build-distr.xml 2007-10-24 14:41:19 UTC (rev 16050)
@@ -132,6 +132,7 @@
<fileset dir="${installation.files.dir}/conf">
<include name="jbossesb-properties.xml"/>
<include name="esb.juddi.properties"/>
+ <include name="actionArtifactMap.properties"/>
</fileset>
<fileset dir="${installation.files.dir}/jUDDI-registry">
<include name="juddi-ds.xml"/>
Added: labs/jbossesb/trunk/product/install/conf/actionArtifactMap.properties
===================================================================
--- labs/jbossesb/trunk/product/install/conf/actionArtifactMap.properties (rev 0)
+++ labs/jbossesb/trunk/product/install/conf/actionArtifactMap.properties 2007-10-24 14:41:19 UTC (rev 16050)
@@ -0,0 +1,52 @@
+#
+# The following actions are included in jbossesb.sar and require
+# no additional dependencies
+#
+# org.jboss.soa.esb.actions.converters.XStreamToObject
+# org.jboss.soa.esb.actions.routing.JMSRouter
+# org.jboss.soa.esb.actions.Aggregator
+# org.jboss.soa.esb.actions.converters.ByteArrayToString
+# org.jboss.soa.esb.actions.routing.EchoRouter
+# org.jboss.soa.esb.actions.naming.FileNameGeneratorAction
+# org.jboss.soa.esb.actions.routing.HttpRouter
+# org.jboss.soa.esb.actions.converters.ObjectInvoke
+# org.jboss.soa.esb.actions.converters.ObjectToCSVString
+# org.jboss.soa.esb.actions.converters.ObjectToXStream
+# org.jboss.soa.esb.actions.StaticWiretap
+# org.jboss.soa.esb.actions.StaticRouter
+# org.jboss.soa.esb.actions.StoreMessageToFile
+# org.jboss.soa.esb.actions.templating.StringTemplateProcessor
+# org.jboss.soa.esb.actions.SystemPrintln
+# org.jboss.soa.esb.actions.Notifier
+# org.jboss.soa.esb.listeners.message.BeanConfigActionProcessor
+# org.jboss.soa.esb.actions.scripting.GroovyActionProcessor
+#
+# The following actions are included in jbossesb.esb and require
+# no additional dependencies
+#
+# org.jboss.soa.esb.actions.MessagePersister
+# org.jboss.soa.esb.actions.MessageRedeliverer
+# org.jboss.soa.esb.monitoring.client.DataCollectorAction
+# org.jboss.soa.esb.monitoring.client.InvokerAction
+# org.jboss.soa.esb.monitoring.client.OperationsCollectorAction
+
+# jbrules.esb actions
+org.jboss.soa.esb.actions.ContentBasedWiretap=jbrules.esb
+org.jboss.soa.esb.actions.ContentBasedRouter=jbrules.esb
+org.jboss.soa.esb.actions.BusinessRulesProcessor=jbrules.esb
+org.jboss.soa.esb.actions.MessageFilter=jbrules.esb
+
+# soap.esb actions
+org.jboss.soa.esb.actions.soap.SOAPClient=soap.esb
+org.jboss.soa.esb.actions.soap.SOAPProcessor=soap.esb
+
+# jbpm.esb actions
+org.jboss.soa.esb.services.jbpm.actions.BpmProcessor=jbpm.esb
+org.jboss.soa.esb.services.jbpm.actions.CommandInterpreter=jbpm.esb
+
+# smooks.esb actions
+org.jboss.soa.esb.actions.converters.SmooksTransformer=smooks.esb
+
+# management.esb actions
+org.jboss.soa.esb.monitoring.server.DataFilerAction=management.esb
+org.jboss.soa.esb.monitoring.server.FilerAction=management.esb
Property changes on: labs/jbossesb/trunk/product/install/conf/actionArtifactMap.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2007-10-24 14:00:40 UTC (rev 16049)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/JBoss4ESBDeployer.java 2007-10-24 14:41:19 UTC (rev 16050)
@@ -23,11 +23,19 @@
import java.io.File;
import java.io.InputStream;
+import java.io.StringReader;
import java.net.URL;
-import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
import org.jboss.deployment.DeploymentException;
import org.jboss.deployment.DeploymentInfo;
@@ -40,8 +48,13 @@
import org.jboss.mx.util.MBeanProxyExt;
import org.jboss.mx.util.ObjectNameConverter;
import org.jboss.soa.esb.lifecycle.LifecycleResourceManager;
+import org.jboss.soa.esb.util.ClassUtil;
+import org.jboss.soa.esb.util.XPathNamespaceContext;
import org.jboss.system.ServiceControllerMBean;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
/**
* comment
@@ -55,9 +68,10 @@
private final static Logger log = Logger.getLogger(JBoss4ESBDeployer.class);
private ServiceControllerMBean serviceController;
+ private Properties actionArtifactProperties;
private static final String PREFIX_CANONICAL_NAME = "jboss.esb:deployment=" ;
- private static final String ESB_CANONICAL_NAME = PREFIX_CANONICAL_NAME + "jbossesb.esb" ;
+ private static final String ESB_ARTIFACT_NAME = "jbossesb.esb" ;
/**
* Default CTOR used to set default values to the Suffixes and RelativeOrder
@@ -118,6 +132,19 @@
*/
protected void startService() throws Exception
{
+ final InputStream actionArtifactIS = ClassUtil.getResourceAsStream("/actionArtifactMap.properties", getClass()) ;
+ if (actionArtifactIS == null)
+ {
+ log.debug("No action artifact mapping") ;
+ }
+ else
+ {
+ log.debug("Loading action artifact mapping") ;
+ final Properties properties = new Properties() ;
+ properties.load(actionArtifactIS) ;
+ actionArtifactProperties = properties ;
+ }
+
serviceController = (ServiceControllerMBean)
MBeanProxyExt.create(ServiceControllerMBean.class,
ServiceControllerMBean.OBJECT_NAME, server);
@@ -216,9 +243,8 @@
}
try
{
- ArrayList<ObjectName> deps = new ArrayList<ObjectName>();
+ Set<ObjectName> deps = new HashSet<ObjectName>();
InputStream in = di.localCl.getResourceAsStream("META-INF/deployment.xml");
- boolean includesESB = false ;
if (in != null)
{
try
@@ -233,10 +259,6 @@
{
Element depend = (Element)depends.next();
ObjectName depOn = new ObjectName(MetaData.getElementContent(depend));
- if (!includesESB && ESB_CANONICAL_NAME.equals(depOn.getCanonicalName()))
- {
- includesESB = true ;
- }
deps.add(depOn);
}
}
@@ -251,15 +273,13 @@
InputStream inputStream = document.openStream();
String jbossEsbXml = Configuration.getStringFromStream(inputStream);
inputStream.close();
+
+ addActionDependencies(di.shortName, jbossEsbXml, deps) ;
+
JBoss4ESBDeployment deployment = new JBoss4ESBDeployment(jbossEsbXml, di.shortName);
deployment.setClassloader(di.ucl);
String name = PREFIX_CANONICAL_NAME + di.shortName;
ObjectName on = ObjectNameConverter.convert(name);
- if (!includesESB && !ESB_CANONICAL_NAME.equals(on.getCanonicalName()))
- {
- final ObjectName esbOn = new ObjectName(ESB_CANONICAL_NAME) ;
- deps.add(esbOn) ;
- }
// Check that the name is not registered
if (server.isRegistered(on) == true)
{
@@ -282,6 +302,71 @@
super.create(di);
}
+ private void addActionDependencies(final String deploymentName,
+ final String configuration, final Set<ObjectName> deps)
+ throws XPathExpressionException, DeploymentException, MalformedObjectNameException
+ {
+ final XmlFileLoader xfl = new XmlFileLoader() ;
+ final StringReader sr = new StringReader(configuration) ;
+ final InputSource is = new InputSource(sr) ;
+ final Element rootElement = xfl.getDocument(is, "META-INF/jboss-esb.xml").getDocumentElement() ;
+
+ final Set<String> artifacts = new HashSet<String>() ;
+ artifacts.add(ESB_ARTIFACT_NAME) ;
+
+ final String namespaceURI = "http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" ;
+
+ final XPath xpathEvaluater = XPathFactory.newInstance().newXPath();
+ final XPathNamespaceContext namespaceContext = new XPathNamespaceContext() ;
+ namespaceContext.setMapping("jbesb", namespaceURI) ;
+ xpathEvaluater.setNamespaceContext(namespaceContext) ;
+
+ final NodeList actionList = (NodeList) xpathEvaluater.evaluate("/jbesb:jbossesb/jbesb:services/jbesb:service/jbesb:actions/jbesb:action",
+ rootElement, XPathConstants.NODESET) ;
+ final int numActions = actionList.getLength() ;
+ if (numActions > 0)
+ {
+ final Set<String> actionClasses = new HashSet<String>() ;
+ for(int count = 0 ; count < numActions ; count++)
+ {
+ final Node actionNode = actionList.item(count) ;
+ if (!(actionNode instanceof Element))
+ {
+ log.warn("Action node is not an element: " + actionNode) ;
+ }
+ else
+ {
+ final Element actionElement = (Element)actionNode ;
+ final String actionClass = actionElement.getAttribute("class") ;
+ actionClasses.add(actionClass) ;
+ }
+ }
+
+ final int numActionClasses = actionClasses.size() ;
+ if (numActionClasses > 0)
+ {
+ for(final String actionClass: actionClasses)
+ {
+ final String artifact = (String)actionArtifactProperties.get(actionClass) ;
+ if (artifact != null)
+ {
+ artifacts.add(artifact) ;
+ }
+ }
+ }
+ }
+
+ for(final String artifact: artifacts)
+ {
+ if (!deploymentName.equals(artifact))
+ {
+ final String canonicalName = PREFIX_CANONICAL_NAME + artifact ;
+ final ObjectName on = ObjectNameConverter.convert(canonicalName) ;
+ deps.add(on) ;
+ }
+ }
+ }
+
public synchronized void start(DeploymentInfo di)
throws DeploymentException
{
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java 2007-10-24 14:41:19 UTC (rev 16050)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, 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.soa.esb.util;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * A simple namespace context used for XPath expression evaluation.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+public class XPathNamespaceContext implements NamespaceContext
+{
+ /**
+ * The prefix to URI mapping.
+ */
+ private final HashMap<String, String> prefixToURI = new HashMap<String, String>() ;
+ /**
+ * The URI to prefix mapping.
+ */
+ private final HashMap<String, String> uriToPrefix = new HashMap<String, String>() ;
+
+ /**
+ * Get the namespace URI for the specified prefix.
+ * @param The prefix.
+ * @return The associated namespace URI.
+ */
+ public String getNamespaceURI(final String prefix)
+ {
+ return prefixToURI.get(prefix) ;
+ }
+
+ /**
+ * Get the prefix for the specified namespace URI.
+ * @param The namespace URI.
+ * @return The associated prefix.
+ */
+ public String getPrefix(final String namespaceURI)
+ {
+ return uriToPrefix.get(namespaceURI) ;
+ }
+
+ /**
+ * Get the prefixes for the specified namespace URI.
+ * @param The namespace URI.
+ * @return The iterator of the associated prefixes.
+ */
+ public Iterator<?> getPrefixes(String namespaceURI)
+ {
+ final String prefix = getPrefix(namespaceURI) ;
+ if (prefix == null)
+ {
+ return Collections.EMPTY_SET.iterator() ;
+ }
+ else
+ {
+ return Arrays.asList(prefix).iterator() ;
+ }
+ }
+
+ /**
+ * Initialise the prefix/namespace URI mapping.
+ * @param prefix The prefix.
+ * @param uri The namespace URI.
+ */
+ public void setMapping(final String prefix, final String uri)
+ {
+ prefixToURI.put(prefix, uri) ;
+ uriToPrefix.put(uri, prefix) ;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/XPathNamespaceContext.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list