[jboss-svn-commits] JBL Code SVN: r8799 - labs/jbossesb/trunk/product/samples/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jan 10 11:01:57 EST 2007


Author: estebanschifman
Date: 2007-01-10 11:01:54 -0500 (Wed, 10 Jan 2007)
New Revision: 8799

Modified:
   labs/jbossesb/trunk/product/samples/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java
Log:
Add main method to TbBootStrapper

Modified: labs/jbossesb/trunk/product/samples/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java
===================================================================
--- labs/jbossesb/trunk/product/samples/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java	2007-01-10 15:46:08 UTC (rev 8798)
+++ labs/jbossesb/trunk/product/samples/trailblazer/esb/src/org/jboss/soa/esb/samples/trailblazer/util/TbBootStrapper.java	2007-01-10 16:01:54 UTC (rev 8799)
@@ -4,6 +4,7 @@
 import java.sql.Connection;
 import java.sql.Statement;
 
+import org.apache.log4j.Logger;
 import org.apache.log4j.xml.DOMConfigurator;
 import org.jboss.internal.soa.esb.persistence.format.db.DBConnectionManager;
 import org.jboss.soa.esb.common.Configuration;
@@ -13,6 +14,49 @@
 
 public class TbBootStrapper extends StandAloneBootStrapper {
 	
+	protected static Logger _logger = Logger.getLogger(TbBootStrapper.class);
+	
+	public static void main(String[] args) throws Exception
+	{
+		Exception eT = null;
+		if (args.length < 1)
+		{
+			eT = new Exception ("No configuration file specified - Ending immediately");
+			_logger.fatal(eT);
+			throw eT;
+		}
+		TbBootStrapper boot = null;
+
+		String configName = args[0];
+		long lSecondsToRun = 365 * 24 * 3600;   // run for 1 year (is it enough ?)
+		if (args.length > 1)
+			try 
+		{ 
+			lSecondsToRun = Long.parseLong(args[1]);
+		}
+		catch (Exception e)
+		{
+			_logger.fatal(e);
+			throw e;
+		}
+		try
+		{
+			boot = new TbBootStrapper(configName);
+			if (lSecondsToRun < 5)
+				lSecondsToRun = 5;
+			long lRunTo = System.currentTimeMillis()+1000*lSecondsToRun;
+
+			while (System.currentTimeMillis() < lRunTo)
+				try { Thread.sleep(1000); }
+				catch (InterruptedException e) { break; }
+		}
+		finally
+		{
+			if (null!=boot)
+				boot.requestEnd();
+		}
+	}
+	
 	private TbBootStrapper() throws Exception {super(null);}
 	
 	public TbBootStrapper (String configName) throws Exception
@@ -24,16 +68,7 @@
 	{
 		super(configName, validationFileName);		
 	}
-	
-	public void requestEnd()
-	{
-   		super.requestEnd();
-   		try { Thread.sleep(5000); }
-   		catch (InterruptedException e) {}
-   		try { runAfter(); }
-   		catch (Exception e) {}
-	} //________________________________
-	
+
 	/*
 	 * Setup HSQLDB for the Registry and the MessageStore
 	 */
@@ -86,13 +121,15 @@
 				e.printStackTrace();
 			}
 		}
-			
 		}
 		
 	/*
 	 * Shuts down the HSQLDB instance
 	 */
-		protected void runAfter(){
+		protected void runAfter()
+		{
+			try { Thread.sleep(5000); }
+			catch (InterruptedException e) {}
 			
 			//shutdown message store if using hsqldb
 			if (Configuration.getStoreDriver().equals("org.hsqldb.jdbcDriver")) {




More information about the jboss-svn-commits mailing list