[jboss-svn-commits] JBL Code SVN: r8498 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 21 10:03:24 EST 2006
Author: estebanschifman
Date: 2006-12-21 10:03:22 -0500 (Thu, 21 Dec 2006)
New Revision: 8498
Added:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java
Log:
Stand alone launcher for the ConfigController/ListenerManager/GatewayController ensemble
Added: 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 2006-12-21 14:32:07 UTC (rev 8497)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/StandAloneBootStrapper.java 2006-12-21 15:03:22 UTC (rev 8498)
@@ -0,0 +1,114 @@
+/*
+ * 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.listeners;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.config.ConfigurationController;
+import org.jboss.soa.esb.listeners.gateway.GatewayListenerController;
+
+
+public class StandAloneBootStrapper
+{
+ private ConfigurationController _confController;
+ private ListenerManager _manager;
+ private GatewayListenerController _gatewayController;
+
+ private static Logger _logger = Logger.getLogger(StandAloneBootStrapper.class);
+
+ public StandAloneBootStrapper (String configName) throws Exception
+ {
+ String listenerConfig ="jbossesb-listener.xml";
+ String gatewayConfig ="jbossesb-gateway.xml";
+
+
+ try
+ {
+ _confController = initiateController(configName, gatewayConfig,listenerConfig);
+
+ ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(listenerConfig));
+ _logger.debug("starting message aware listener with config file - " +listenerConfig);
+ _manager = ListenerUtil.launchManager(tree, true);
+ _manager.waitUntilReady();
+
+ _logger.info("starting gateway listener with config file - " + gatewayConfig);
+ _gatewayController = new GatewayListenerController(gatewayConfig);
+ new Thread(_gatewayController).start();
+ System.out.println("**Listeners Ready**");
+ }
+ catch (Exception e)
+ {
+ requestEnd();
+ throw new Exception(e);
+ }
+
+ } //________________________________
+
+ public void requestEnd()
+ {
+ if (null!= _gatewayController)
+ _gatewayController.requestEnd();
+ if (null!= _manager)
+ _manager.requestEnd();
+ if (null!= _confController)
+ _confController.requestEnd();
+ } //________________________________
+
+ public ConfigurationController initiateController(String configName,String gwConf, String esbConf)
+ throws Exception
+ {
+ if (null==configName)
+ throw new IllegalArgumentException("Null configuration file specified");
+
+ 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);
+ if (listenerFile.exists()) {
+ listenerFile.delete();
+ }
+ File gatewayFile = new File(configDir,gwConf);
+ if (gatewayFile.exists()) {
+ gatewayFile.delete();
+ }
+
+ ConfigurationController conf = new ConfigurationController(configName);
+ new Thread(conf).start();
+
+ for (int i1=0; i1<10; i1++)
+ {
+ if (listenerFile.exists() && gatewayFile.exists())
+ return conf;
+ else
+ Thread.sleep(200);
+ }
+ conf.requestEnd();
+ throw new Exception("Unable to generate gateway and listener configurations");
+ } //________________________________
+}
More information about the jboss-svn-commits
mailing list