[jboss-svn-commits] JBL Code SVN: r8721 - in labs/jbossesb/trunk: product/core/listeners/src/org/jboss/soa/esb/listeners product/core/listeners/src/org/jboss/soa/esb/listeners/message qa/junit/src/org/jboss/soa/esb/listeners/message
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Jan 5 14:07:18 EST 2007
Author: kurt.stam at jboss.com
Date: 2007-01-05 14:07:15 -0500 (Fri, 05 Jan 2007)
New Revision: 8721
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java
labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml
Log:
Changing the CbrListener over to use attributes. Also changed the CbrListenerTest over to use the new config.
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerTagNames.java 2007-01-05 17:56:52 UTC (rev 8720)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/ListenerTagNames.java 2007-01-05 19:07:15 UTC (rev 8721)
@@ -63,8 +63,6 @@
/** Content Based Routing */
- public static final String CBR_TAG = "cbr";
-
/** RuleSet reference (Filename) */
public static final String RULE_SET_TAG = "ruleSet";
public static final String RULE_LANGUAGE_TAG = "ruleLanguage";
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java 2007-01-05 17:56:52 UTC (rev 8720)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java 2007-01-05 19:07:15 UTC (rev 8721)
@@ -80,8 +80,13 @@
}
}
- public StandAloneBootStrapper (String configName) throws Exception
+ public StandAloneBootStrapper (String configName) throws Exception
{
+ this(configName, null);
+ }
+
+ public StandAloneBootStrapper (String configName, String validationFileName) throws Exception
+ {
String listenerConfig ="jbossesb-listener.xml";
String gatewayConfig ="jbossesb-gateway.xml";
@@ -94,7 +99,7 @@
sParent = sParent.substring(0,-2+sParent.length());
configFile = new File(sParent,configFile.getName());
- _confController = initiateController(configFile.getAbsolutePath(), gatewayConfig,listenerConfig);
+ _confController = initiateController(configFile.getAbsolutePath(), validationFileName, gatewayConfig,listenerConfig);
listenerConfig = new File(sParent,listenerConfig).getAbsolutePath();
ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(listenerConfig));
@@ -126,7 +131,7 @@
_confController.requestEnd();
} //________________________________
- public ConfigurationController initiateController(String configName,String gwConf, String esbConf)
+ public ConfigurationController initiateController(String configName, String validationName, String gwConf, String esbConf)
throws Exception
{
if (null==configName)
@@ -135,7 +140,7 @@
File configFile = new File(configName);
if (!configFile.exists())
throw new IllegalArgumentException("Missing esb configuration file: "+configFile);
-
+
//Remove the listener and gateway configuration files if the exist
File configDir = configFile.getParentFile();
File listenerFile = new File(configDir,esbConf);
@@ -147,7 +152,7 @@
gatewayFile.delete();
}
- ConfigurationController conf = new ConfigurationController(configFile.toString(),null);
+ ConfigurationController conf = new ConfigurationController(configFile.toString(), validationName);
new Thread(conf).start();
for (int i1=0; i1<10; i1++)
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java 2007-01-05 17:56:52 UTC (rev 8720)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/message/CbrListener.java 2007-01-05 19:07:15 UTC (rev 8721)
@@ -62,15 +62,15 @@
protected void checkMyParms() throws ConfigurationException
{
super.checkMyParms();
- if (_config.getFirstChild(ListenerTagNames.CBR_TAG)==null) {
- _logger.error("Required child element " + ListenerTagNames.CBR_TAG + " not found in " + _config.getName() + ".");
- throw new ConfigurationException("Required child element " + ListenerTagNames.CBR_TAG + " not found.");
+ if (_config.getAttribute(ListenerTagNames.RULE_SET_TAG)==null) {
+ _logger.error("Required attribute " + ListenerTagNames.RULE_SET_TAG + " not found in " + _config.getName() + ".");
+ throw new ConfigurationException("Required attribute" + ListenerTagNames.RULE_SET_TAG + " not found.");
} else {
- _ruleSet =_config.getFirstChild(ListenerTagNames.CBR_TAG).getAttribute(ListenerTagNames.RULE_SET_TAG);
+ _ruleSet =_config.getAttribute(ListenerTagNames.RULE_SET_TAG);
if (_ruleSet==null) {
throw new ConfigurationException("Required attribute " + ListenerTagNames.RULE_SET_TAG + " not found.");
}
- _ruleLanguage =_config.getFirstChild(ListenerTagNames.CBR_TAG).getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
+ _ruleLanguage =_config.getAttribute(ListenerTagNames.RULE_LANGUAGE_TAG);
}
} // ________________________________
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java 2007-01-05 17:56:52 UTC (rev 8720)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.java 2007-01-05 19:07:15 UTC (rev 8721)
@@ -24,7 +24,6 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.DriverManager;
import java.sql.Statement;
@@ -40,9 +39,7 @@
import org.jboss.soa.esb.couriers.Courier;
import org.jboss.soa.esb.couriers.CourierException;
import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.listeners.ListenerManager;
-import org.jboss.soa.esb.listeners.ListenerUtil;
+import org.jboss.soa.esb.listeners.StandAloneBootStrapper;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.services.registry.Registry;
@@ -66,9 +63,8 @@
public class CbrListenerTest
{
private static Logger logger = Logger.getLogger(CbrListenerTest.class);
- private static ListenerManager _proc = null;
+ private static StandAloneBootStrapper _boot = null;
-
private static String mDbDriver;
private static String mDbUrl;
private static String mDbUsername;
@@ -173,9 +169,15 @@
//Now we can bring up the ContentBasedRouter
String deploymentConfigFile = TestEnvironmentUtil.getUserDir("qa")
+ "junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml";
- ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(deploymentConfigFile));
- _proc = ListenerUtil.launchManager(tree, true);
- _proc.waitUntilReady();
+ String validationFileName = TestEnvironmentUtil.getUserDir("product")
+ + "etc/schemas/xml/jbossesb-1.0.xsd";
+ // Make sure this file exists
+ File validationFile = new File(validationFileName);
+ if (!validationFile.exists()){
+ assertTrue(false);
+ }
+ _boot = new StandAloneBootStrapper(deploymentConfigFile, validationFileName);
+
logger.info("Testing to see if we can instantiate and start ListenerManager");
} catch (Throwable e) {
e.printStackTrace();
@@ -193,11 +195,18 @@
@AfterClass
public static void runAfterAllTests() throws Exception {
//Increase Sleep for debugging
- _proc.requestEnd();
- //Give the controller time to finish
+ _boot.requestEnd();
+ //Give the esb time to finish
Thread.sleep(2000);
-
- System.out.println("ListenerManager: Exit state = "+_proc.getState());
+ //Cleaning up the generated files
+ String listenerConfigFile = TestEnvironmentUtil.getUserDir("qa")
+ + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-listener.xml";
+ File listenerFile = new File(listenerConfigFile);
+ if (listenerFile.exists()) listenerFile.delete();
+ String gatewayConfigFile = TestEnvironmentUtil.getUserDir("qa")
+ + "junit/src/org/jboss/soa/esb/listeners/message/jbossesb-gateway.xml";
+ File gatewayFile = new File(gatewayConfigFile);
+ if (gatewayFile.exists()) gatewayFile.delete();
if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
Modified: labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml 2007-01-05 17:56:52 UTC (rev 8720)
+++ labs/jbossesb/trunk/qa/junit/src/org/jboss/soa/esb/listeners/message/CbrListenerTest.xml 2007-01-05 19:07:15 UTC (rev 8721)
@@ -1,46 +1,35 @@
-<!--
-/*
- * 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.
- */
- -->
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.xsd">
-<ContentBasedRouterTest parameterReloadSecs="180">
- <ContentBasedRouter
- service-category="MessageRouting"
- service-name="ContentBasedRoutingService"
- service-description="This CBR routs messages to different service destination based whether the messageType is XML or Serializable"
- listenerClass="org.jboss.soa.esb.listeners.message.CbrListener"
- >
- <EPR
- protocol="jms"
- connection-factory="ConnectionFactory"
- destination-type="queue"
- destination-name="queue/A"
- jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
- jndi-URL="localhost"
- message-selector="service='CBRouting-SerializableOrXml'"
- />
-
- <cbr ruleSet="JBossESBRules.drl" />
-
- </ContentBasedRouter>
-
-</ContentBasedRouterTest>
+ <providers>
+ <jms-provider name="localhost"
+ connection-factory="ConnectionFactory"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-URL="localhost" >
+
+ <jms-bus busid="QueueA">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/A"
+ selector="service='CBRouting-SerializableOrXml'"
+ />
+ </jms-bus>
+ </jms-provider>
+ </providers>
+ <services>
+ <service
+ category="MessageRouting"
+ name="ContentBasedRoutingService"
+ description="CBR Listener"
+ is-gateway="false"
+ service-class="org.jboss.soa.esb.listeners.message.CbrListener">
+ <listeners>
+ <jms-listener name="XPathContentBasedRouter"
+ busidref="QueueA"
+ maxThreads="1">
+ <property name="ruleSet" value="JBossESBRules.drl"/>
+ </jms-listener>
+ </listeners>
+ </service>
+ </services>
+</jbossesb>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list