[jboss-svn-commits] JBL Code SVN: r20218 - labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu May 29 13:20:52 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-05-29 13:20:52 -0400 (Thu, 29 May 2008)
New Revision: 20218

Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2Database.java
Log:
Fix H2 shutdown: JBESB-1778

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2Database.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2Database.java	2008-05-29 15:39:11 UTC (rev 20217)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2Database.java	2008-05-29 17:20:52 UTC (rev 20218)
@@ -115,6 +115,9 @@
     /** Server thread for remote h2. */
     private Thread serverThread;
     
+    /** The remote server instance */
+    private Server remoteServer ;
+    
     /** Server thread delay for remote H2. */
     private long delay = DEFAULT_DELAY ;
 
@@ -376,11 +379,6 @@
             stopStandaloneDatabase();
         }
     }
-       
-    private void stopRemoteDatabase() throws SQLException 
-    {
-        Server.shutdownTcpServer( "tcp://" + address + ":" + port, "", true ); 
-    }
 
     // Private -------------------------------------------------------
    
@@ -415,7 +413,7 @@
      * Start a remote/server database
      * @throws Exception
      */
-    void startRemoteDatabase() throws Exception
+    private void startRemoteDatabase() throws Exception
     {
         final File h2Dir = checkDataDir() ;
         dbPath = new File(h2Dir, name);
@@ -432,7 +430,9 @@
                 			"-baseDir ", dbPath.toURI().toString(), 
                 			"-tcpPort", String.valueOf(port),
                 			"-tcpAllowOthers","" }; //	need the extra empty string or a exception is thrown by H2
-                	Server.createTcpServer( args ).start();
+                	final Server server = Server.createTcpServer(args) ;
+                	server.start() ;
+                	setRemoteServer(server);
 	            }
 	            catch (Exception e)
 	            {
@@ -499,6 +499,36 @@
        log.info("Database in memory closed clean");
    }
    
+   /**
+    * Stop the remote database.
+    */
+   private void stopRemoteDatabase() throws SQLException 
+   {
+       final Server server = getRemoteServer() ;
+       if (server != null)
+       {
+           server.shutdown() ;
+       }
+   }
+   
+   /**
+    * Set the remote server instance.
+    * @param remoteServer The remote server instance.
+    */
+   private synchronized void setRemoteServer(final Server remoteServer)
+   {
+       this.remoteServer = remoteServer ;
+   }
+   
+   /**
+    * Get the remote server instance.
+    * @return The remote server instance.
+    */
+   private synchronized Server getRemoteServer()
+   {
+       return remoteServer ;
+   }
+   
     /**
      * Get the connection.
      * 




More information about the jboss-svn-commits mailing list