[jboss-svn-commits] JBL Code SVN: r15685 - in labs/jbossesb/trunk/product: samples/quickstarts/transform_XML2XML_simple and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 9 06:36:05 EDT 2007
Author: tfennelly
Date: 2007-10-09 06:36:05 -0400 (Tue, 09 Oct 2007)
New Revision: 15685
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/readme.txt
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksInstanceManager.java
labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksTransformer.java
Log:
transformation reloading doesn't work: http://jira.jboss.com/jira/browse/JBESB-1085
Modified: labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/samples/quickstarts/fun_cbr/deployment.xml 2007-10-09 10:36:05 UTC (rev 15685)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbossesb-deployment>
+ <depends>jboss.esb:deployment=smooks.esb</depends>
<depends>jboss.esb:deployment=jbrules.esb</depends>
<depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_GW</depends>
<depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_Fun_CBR_Request_ESB</depends>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/build.xml 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/build.xml 2007-10-09 10:36:05 UTC (rev 15685)
@@ -9,8 +9,7 @@
<!-- Import the base Ant build script... -->
<import file="../conf/base-build.xml"/>
- <target name="runtest" depends="compile"
- description="runs Test JMS Sender">
+ <target name="runtest" depends="compile" description="runs Test JMS Sender">
<echo>Runs Test JMS Sender</echo>
<java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.transformxml2xmlsimple.test.SendJMSMessage" failonerror="true">
<arg value="SampleOrder.xml" />
@@ -18,4 +17,13 @@
</java>
</target>
+ <target name="notifyUpdate" depends="compile" description="Send a notification message to the JMS Topic">
+ <echo>Sending transformation update notification for transform "simple-transform" to deployed ESB.</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.testutils.JMSUtil" failonerror="true" classpathref="exec-classpath">
+ <arg value="topic/org.jboss.soa.esb.transformation.Update"/>
+ <arg value="topic"/>
+ <arg value="simple-transform"/>
+ </java>
+ </target>
+
</project>
Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/jboss-esb.xml 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/jboss-esb.xml 2007-10-09 10:36:05 UTC (rev 15685)
@@ -30,7 +30,7 @@
<action name="print-before" class="org.jboss.soa.esb.actions.SystemPrintln">
<property name="message" value="[transform_XML2XML_simple] Message before transformation" />
</action>
- <action name="transform" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
+ <action name="simple-transform" class="org.jboss.soa.esb.actions.converters.SmooksTransformer">
<property name="resource-config" value="/smooks-res.xml" />
</action>
<action name="print-after" class="org.jboss.soa.esb.actions.SystemPrintln">
Modified: labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/readme.txt 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/samples/quickstarts/transform_XML2XML_simple/readme.txt 2007-10-09 10:36:05 UTC (rev 15685)
@@ -44,16 +44,27 @@
As stated above, reading MessageTransformation.pdf would be of great benefit
in understanding JBoss ESB Transformations.
- jbossesb.xml:
+ jboss-esb.xml:
The ESB configuration file in this Quickstart simply defines a JMS Listener
for receiving the contents of the SampleOrder.xml file located in this
- folder (line 31). The listener configuration then executes the
- "SmooksTransformer" action for the Message Exchange between "A" and "B".
+ folder. This XML message will be transformed by this service.
smooks-res.xml:
This file defines the Transformations for the Quickstart. In this case, it
simply defines a single XSL transformation for the order line items.
+ notifyUpdate Ant target:
+ JBossESB Transformations are hot reloadable. To test this out:
+ 1. Redeploy the .esb as an exploded archive.
+ 2. Run the sample to view the output ("ant runtest").
+ 3. Modify the transformation in the exploded .esb.
+ 4. Rerun the sample ("ant runtest"). Transformation should still
+ be the same i.e. no update.
+ 5. Notify the .esb deployment of the transformation update by
+ running "ant notifyUpdate".
+ 6. Rerun the sample again ("ant runtest") and notice the
+ transformation update.
+
Playing with this Transformation through the Administration Console:
====================================================================
To load the Transformation Configurations defined in smooks-res.xml into the
Modified: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksInstanceManager.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksInstanceManager.java 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksInstanceManager.java 2007-10-09 10:36:05 UTC (rev 15685)
@@ -20,6 +20,7 @@
package org.jboss.soa.esb.actions.converters;
import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.util.ClassUtil;
import org.jboss.soa.esb.helpers.NamingContext;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.apache.log4j.Logger;
@@ -34,6 +35,7 @@
import javax.naming.InitialContext;
import java.io.InputStream;
import java.io.IOException;
+import java.util.Arrays;
/**
* Smooks instance manager.
@@ -76,8 +78,15 @@
}
private Smooks createSmooksInstance() throws SmooksException{
+ // We're not synchronizing creation of (or access to) the Smooks
+ // instances, so there is a possiblility that 1+ instances of
+ // Smooks could be "in circulation" for brief intervals (after an
+ // update notification). This is OK and not an issue. The
+ // older instance(s) will eventually get GC'd.
try {
- return new Smooks(configurationSourceURI);
+ Smooks instance = new Smooks(configurationSourceURI);
+ addBaseConfigs(instance);
+ return instance;
} catch (SAXException e) {
throw new SmooksException("Invalid Smooks resource config '" + configurationSourceURI + "'.", e);
} catch (IOException e) {
@@ -85,6 +94,27 @@
}
}
+ private void addBaseConfigs(Smooks instance) {
+ String baseConfigs = config.getProperty("smooks.base.configs", "creators.xml");
+ String[] resources = baseConfigs.split(",");
+ if(logger.isDebugEnabled()) {
+ logger.debug("smooks-base-configs: " + Arrays.asList(resources));
+ }
+ for(String resource : resources) {
+ String fullResPath = "/smooks-base-configs/" + resource.trim();
+ try {
+ InputStream smooksRes = ClassUtil.getResourceAsStream(fullResPath, getClass());
+ if(smooksRes != null) {
+ instance.addConfigurations("/smooks-base-configs/", smooksRes);
+ } else {
+ logger.warn("Configured Smooks resource '" + fullResPath + "' doesn't exist on the classpath.");
+ }
+ } catch(Throwable t) {
+ logger.warn("Exception while loading Smooks resource '" + fullResPath + "'.", t);
+ }
+ }
+ }
+
/**
* JMS Listener for receiving configuration update notifications.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
@@ -102,7 +132,9 @@
*/
private ConfigurationUpdateListener() {
try {
- connect();
+ if(!connect()) {
+ logger.warn("Failed to start Smooks Configuration Update listener. Turn on debug logging for more info.");
+ }
} catch(Throwable t) {
logger.error("Unexpected error while attempting to connect Transformation configuration Update Listener. Update listener not enabled!", t);
close();
@@ -114,18 +146,28 @@
* Receive a notification message.
*/
public void onMessage(javax.jms.Message message) {
- if(message instanceof TextMessage) {
- try {
- String updatedSourceName = ((TextMessage)message).getText();
+ String updatedSourceName = null;
- if(updatedSourceName != null && updatedSourceName.equals(configurationSourceName)) {
- logger.info("Transformation configuration update notification received for configuration source '" + configurationSourceName + "'. Resetting SmooksTransformer in order to force a configuration re-read.");
- smooksInstance = createSmooksInstance();
+ try {
+ if(message instanceof TextMessage) {
+ updatedSourceName = ((TextMessage)message).getText();
+ } else if(message instanceof ObjectMessage) {
+ try {
+ updatedSourceName = (String) ((ObjectMessage)message).getObject();
+ } catch(Throwable t) {
+ logger.error("Failed to read updateSourceName from JMS ObjectMessage. Expecting a String object. Error: " + t.getMessage());
}
- } catch (JMSException e) {
- logger.warn("Error reading Smooks Update Notification configuration source name from JMS message.", e);
- return;
}
+ } catch (JMSException e) {
+ logger.warn("Error reading Smooks Update Notification configuration source name from JMS message.", e);
+ return;
+ }
+
+ if(updatedSourceName != null) {
+ if(updatedSourceName.equals(configurationSourceName)) {
+ logger.info("Transformation configuration update notification received for configuration source '" + configurationSourceName + "'. Resetting SmooksTransformer in order to force a configuration re-read.");
+ smooksInstance = createSmooksInstance();
+ }
} else {
logger.info("Transformation configuration update notification received (global notification). Resetting SmooksTransformer in order to force a configuration re-read.");
smooksInstance = createSmooksInstance();
@@ -185,10 +227,10 @@
try {
connectionFactory = (TopicConnectionFactory) getJmsConnectionFactory();
} catch (ConfigurationException e) {
- logger.error("Lookup of the JMS ConnectionFactory failed for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("Lookup of the JMS ConnectionFactory failed for the Transformation configuration Update Listener. Update listener not enabled!", e);
return false;
} catch (ClassCastException e) {
- logger.error("Invalid JMS ConnectionFactory config for the Transformation configuration Update Listener. ConnectionFactory doesn't implement " + TopicConnectionFactory.class.getName() + ". Update listener not enabled!", e);
+ logger.debug("Invalid JMS ConnectionFactory config for the Transformation configuration Update Listener. ConnectionFactory doesn't implement " + TopicConnectionFactory.class.getName() + ". Update listener not enabled!", e);
return false;
}
@@ -196,7 +238,7 @@
try {
conn = connectionFactory.createTopicConnection();
} catch (JMSException e) {
- logger.error("Failed to open JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("Failed to open JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
return false;
}
@@ -207,11 +249,11 @@
topic = (Topic) context.lookup(notificationTopicName);
context.close();
} catch (ConfigurationException e) {
- logger.error("Topic lookup failed for the Transformation configuration Update Listener. Topic name '" + notificationTopicName + "'. \n\t\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check properties '" + UPDATE_TOPIC_NAME + "' and '" + Context.PROVIDER_URL + "' in '" + SmooksConfiguration.SMOOKS_ESB_PROPERTIES + "'). \n\t\tUpdate listener not enabled!", e);
+ logger.debug("Topic lookup failed for the Transformation configuration Update Listener. Topic name '" + notificationTopicName + "'. \n\t\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check properties '" + UPDATE_TOPIC_NAME + "' and '" + Context.PROVIDER_URL + "' in '" + SmooksConfiguration.SMOOKS_ESB_PROPERTIES + "'). \n\t\tUpdate listener not enabled!", e);
close();
return false;
} catch (NamingException e) {
- logger.warn("Topic lookup failed for the Transformation configuration Update Listener. Topic name '" + notificationTopicName + "'. \n\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check properties '" + UPDATE_TOPIC_NAME + "' and '" + Context.PROVIDER_URL + "' in '" + SmooksConfiguration.SMOOKS_ESB_PROPERTIES + "'). \n\tUpdate listener not enabled!");
+ logger.debug("Topic lookup failed for the Transformation configuration Update Listener. Topic name '" + notificationTopicName + "'. \n\tThis JMS Topic may not be deployed, or this ESB instance may not be looking at the correct JMS provider (check properties '" + UPDATE_TOPIC_NAME + "' and '" + Context.PROVIDER_URL + "' in '" + SmooksConfiguration.SMOOKS_ESB_PROPERTIES + "'). \n\tUpdate listener not enabled!");
close();
return false;
}
@@ -220,7 +262,7 @@
try {
session = conn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
} catch (JMSException e) {
- logger.error("TopicSession creation failed for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("TopicSession creation failed for the Transformation configuration Update Listener. Update listener not enabled!", e);
close();
return false;
}
@@ -229,7 +271,7 @@
try {
conn.start();
} catch (JMSException e) {
- logger.error("Failed to start JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("Failed to start JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
close();
return false;
}
@@ -239,7 +281,7 @@
TopicSubscriber topicSubscriber = session.createSubscriber(topic);
topicSubscriber.setMessageListener(this);
} catch (JMSException e) {
- logger.error("Failed to start JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("Failed to start JMS TopicConnection for the Transformation configuration Update Listener. Update listener not enabled!", e);
close();
return false;
}
@@ -248,7 +290,7 @@
try {
conn.setExceptionListener(new ExceptionListener());
} catch (JMSException e) {
- logger.error("Failed to attach an ExceptionListener for the Transformation configuration Update Listener. Update listener not enabled!", e);
+ logger.debug("Failed to attach an ExceptionListener for the Transformation configuration Update Listener. Update listener not enabled!", e);
close();
return false;
}
Modified: labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksTransformer.java
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksTransformer.java 2007-10-09 09:53:06 UTC (rev 15684)
+++ labs/jbossesb/trunk/product/services/smooks/src/main/java/org/jboss/soa/esb/actions/converters/SmooksTransformer.java 2007-10-09 10:36:05 UTC (rev 15685)
@@ -229,30 +229,8 @@
private void initialiseLocalSmooksInstanceManager(String resourceConfig) {
String actionName = actionConfig.getAttribute("action");
- SmooksConfiguration smooksEsbConfig = new SmooksConfiguration();
- String baseConfigs = smooksEsbConfig.getProperty("smooks.base.configs", "creators.xml");
- Smooks smooks;
smooksInstanceManager = new SmooksInstanceManager(actionName, resourceConfig);
- smooks = smooksInstanceManager.getSmooksInstance();
-
- String[] resources = baseConfigs.split(",");
- if(logger.isDebugEnabled()) {
- logger.debug("smooks-base-configs: " + Arrays.asList(resources));
- }
- for(String resource : resources) {
- String fullResPath = "/smooks-base-configs/" + resource.trim();
- try {
- InputStream smooksRes = ClassUtil.getResourceAsStream(fullResPath, getClass());
- if(smooksRes != null) {
- smooks.addConfigurations("/smooks-base-configs/", smooksRes);
- } else {
- logger.warn("Configured Smooks resource '" + fullResPath + "' doesn't exist on the classpath.");
- }
- } catch(Throwable t) {
- logger.warn("Exception while loading Smooks resource '" + fullResPath + "'.", t);
- }
- }
}
public void destroy() throws ActionLifecycleException {
More information about the jboss-svn-commits
mailing list