[jboss-svn-commits] JBL Code SVN: r20114 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product: rosetta/tests/src/org/jboss/internal/soa/esb/dependencies and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu May 22 14:32:46 EDT 2008
Author: beve
Date: 2008-05-22 14:32:46 -0400 (Thu, 22 May 2008)
New Revision: 20114
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/h2/
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/h2/create.sql
Removed:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/hsqldb/
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/H2DatabaseMBean.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/build.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jboss-esb.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jbossesb-service.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/quickstart-ds.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbpm-ds.xml
Log:
Work for JBESB-1695 "jBPM datasource should be XA datasource"
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-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2Database.java 2008-05-22 18:32:46 UTC (rev 20114)
@@ -25,8 +25,10 @@
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
+import java.sql.SQLException;
import java.sql.Statement;
+import org.h2.tools.Server;
import org.jboss.system.ServiceMBeanSupport;
import org.jboss.system.server.ServerConfigLocator;
@@ -40,257 +42,429 @@
* @author <a href="mailto:vesco.claudio at previnet.it">Claudio Vesco</a>
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @author <a href="mailto:kevin.conner at jboss.org">Kevin Conner</a>
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
* @version $Revision$
*/
-public class H2Database extends ServiceMBeanSupport
- implements H2DatabaseMBean
+public class H2Database extends ServiceMBeanSupport implements H2DatabaseMBean
{
- /** Default password: <code>empty string</code>. */
- private static final String DEFAULT_PASSWORD = "";
+ /** Default password: <code>empty string</code>. */
+ private static final String DEFAULT_PASSWORD = "";
+
+ /** Default user: <code>sa</code>. */
+ private static final String DEFAULT_USER = "sa";
+
+ /** JDBC Driver class: <code>org.h2.Driver</code>. */
+ private static final String JDBC_DRIVER_CLASS = "org.h2.Driver";
+
+ /** JDBC URL common prefix: <code>jdbc:h2:</code>. */
+ private static final String JDBC_URL_PREFIX = "jdbc:h2:";
- /** Default user: <code>sa</code>. */
- private static final String DEFAULT_USER = "sa";
+ /** JDBC in memory URL prefix: <code>jdbc:h2:mem:</code>. */
+ private static final String JDBC_MEM_URL_PREFIX = JDBC_URL_PREFIX + "mem:";
+
+ /** JDBC flags */
+ private static final String DEFAULT_FLAGS = ";MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE";
+
+ /** Default data subdir: <code>h2</code>. */
+ private static final String H2_DATA_DIR = "h2";
+
+ /** Default database name: <code>default</code>. */
+ private static final String DEFAULT_DATABASE_NAME = "default";
+
+ /** Default address for remote h2: <code>0.0.0.0</code>. */
+ private static final String DEFAULT_ADDRESS = "0.0.0.0";
+
+ /** Default port for remote h2: <code>9092</code>. */
+ private static final int DEFAULT_PORT = 9092;
+
+ /** Default delay for remote hypersonic initialisation (ms): <code>5000</code>. */
+ private static final long DEFAULT_DELAY = 5000;
+
+ // Private Data --------------------------------------------------
+
+ /** Full path to db/h2. */
+ private File dbPath;
+
+ /** Database name. */
+ private String name = DEFAULT_DATABASE_NAME;
+
+ /** In memory mode. */
+ private boolean inMemoryMode ;
+
+ /** Database user. */
+ private String user = DEFAULT_USER;
+
+ /** Database password. */
+ private String password = DEFAULT_PASSWORD;
+
+ /** Database flags */
+ private String flags = DEFAULT_FLAGS ;
+
+ /** Hold a connection for in memory h2. */
+ private Connection connection;
+
+ /** Default address. */
+ private String address = DEFAULT_ADDRESS;
+
+ /** Default port. */
+ private int port = DEFAULT_PORT;
+
+ /** Server/remote mode. */
+ private boolean serverMode = false;
- /** JDBC Driver class: <code>org.h2.Driver</code>. */
- private static final String JDBC_DRIVER_CLASS = "org.h2.Driver";
-
- /** JDBC URL common prefix: <code>jdbc:h2:</code>. */
- private static final String JDBC_URL_PREFIX = "jdbc:h2:";
-
- /** JDBC in memory URL prefix: <code>jdbc:h2:mem:</code>. */
- private static final String JDBC_MEM_URL_PREFIX = JDBC_URL_PREFIX + "mem:";
-
- /** JDBC flags */
- private static final String DEFAULT_FLAGS = ";MVCC=TRUE;DB_CLOSE_ON_EXIT=FALSE" ;
-
- /** Default data subdir: <code>h2</code>. */
- private static final String H2_DATA_DIR = "h2";
-
- /** Default database name: <code>default</code>. */
- private static final String DEFAULT_DATABASE_NAME = "default";
+ /** Server thread for remote h2. */
+ private Thread serverThread;
+
+ /** Server thread delay for remote H2. */
+ private long delay = DEFAULT_DELAY ;
- // Private Data --------------------------------------------------
+ // Attributes ----------------------------------------------------
- /** Full path to db/h2. */
- private File dbPath;
+ /**
+ * Set the database name.
+ *
+ * @jmx.managed-attribute
+ */
+ public void setDatabase(String name)
+ {
+ if (name == null)
+ {
+ name = DEFAULT_DATABASE_NAME;
+ }
+ this.name = name;
+ }
- /** Database name. */
- private String name = DEFAULT_DATABASE_NAME;
-
- /** In memory mode. */
- private boolean inMemoryMode ;
-
- /** Database user. */
- private String user = DEFAULT_USER;
-
- /** Database password. */
- private String password = DEFAULT_PASSWORD;
-
- /** Database flags */
- private String flags = DEFAULT_FLAGS ;
-
- /** Hold a connection for in memory h2. */
- private Connection connection;
+ /**
+ * Get the database name.
+ *
+ * @jmx.managed-attribute
+ */
+ public String getDatabase()
+ {
+ return name;
+ }
+
+ /**
+ * Get the full database path.
+ *
+ * @jmx.managed-attribute
+ */
+ public String getDatabasePath()
+ {
+ if (dbPath != null)
+ {
+ return dbPath.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * @return the <code>inMemoryMode</code> flag.
+ *
+ * @jmx.managed-attribute
+ */
+ public boolean isInMemoryMode()
+ {
+ return inMemoryMode;
+ }
+ /**
+ * If <b>true</b> the h2 is in memory mode otherwise embedded mode.
+ *
+ * @param b in memory mode.
+ *
+ * @jmx.managed-attribute
+ */
+ public void setInMemoryMode( boolean b )
+ {
+ inMemoryMode = b;
+ }
+
+ /**
+ * @return the password
+ *
+ * @jmx.managed-attribute
+ */
+ public String getPassword()
+ {
+ return password;
+ }
- // Attributes ----------------------------------------------------
+ /**
+ * @return the user
+ *
+ * @jmx.managed-attribute
+ */
+ public String getUser()
+ {
+ return user;
+ }
+
+ /**
+ * @return the flags
+ *
+ * @jmx.managed-attribute
+ */
+ public String getFlags()
+ {
+ return flags;
+ }
+
+ /**
+ * @param password
+ *
+ * @jmx.managed-attribute
+ */
+ public void setPassword(String password)
+ {
+ if (password == null)
+ {
+ password = DEFAULT_PASSWORD;
+ }
+ this.password = password;
+ }
+
+ /**
+ * @param user
+ *
+ * @jmx.managed-attribute
+ */
+ public void setUser(String user)
+ {
+ if (user == null)
+ {
+ user = DEFAULT_USER;
+ }
+ this.user = user;
+ }
+
+ /**
+ * @param flags
+ *
+ * @jmx.managed-attribute
+ */
+ public void setFlags(String flags)
+ {
+ if (flags == null)
+ {
+ flags = DEFAULT_FLAGS;
+ }
+ this.flags = flags;
+ }
- /**
- * Set the database name.
- *
- * @jmx.managed-attribute
- */
- public void setDatabase(String name)
- {
- if (name == null)
- {
- name = DEFAULT_DATABASE_NAME;
- }
- this.name = name;
- }
+ /**
+ * @return the serverMode
+ *
+ * @jmx.managed-attribute
+ */
+ public boolean isServerMode()
+ {
+ return serverMode;
+ }
- /**
- * Get the database name.
- *
- * @jmx.managed-attribute
- */
- public String getDatabase()
- {
- return name;
- }
+ /**
+ * @param serverMode
+ *
+ * @jmx.managed-attribute
+ */
+ public void setServerMode( boolean serverMode )
+ {
+ this.serverMode = serverMode;
+ }
- /**
- * Get the full database path.
- *
- * @jmx.managed-attribute
- */
- public String getDatabasePath()
- {
- if (dbPath != null)
- {
- return dbPath.toString();
- }
- else
- {
- return null;
- }
- }
+ /**
+ * @return the address
+ *
+ * @jmx.managed-attribute
+ */
+ public String getBindAddress()
+ {
+ return address;
+ }
- /**
- * @return the <code>inMemoryMode</code> flag.
- *
- * @jmx.managed-attribute
- */
- public boolean isInMemoryMode()
- {
- return inMemoryMode;
- }
+ /**
+ * @return the port
+ *
+ * @jmx.managed-attribute
+ */
+ public int getPort()
+ {
+ return port;
+ }
- /**
- * If <b>true</b> the h2 is in memory mode otherwise h2 is in server or remote mode.
- *
- * @param b in memory mode.
- *
- * @jmx.managed-attribute
- */
- public void setInMemoryMode(boolean b)
- {
- inMemoryMode = b;
- }
+ /**
+ * @param address
+ *
+ * @jmx.managed-attribute
+ */
+ public void setBindAddress(String address)
+ {
+ this.address = address;
+ }
- /**
- * @return the password
- *
- * @jmx.managed-attribute
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
- * @return the user
- *
- * @jmx.managed-attribute
- */
- public String getUser()
- {
- return user;
- }
-
- /**
- * @return the flags
- *
- * @jmx.managed-attribute
- */
- public String getFlags()
- {
- return flags;
- }
-
- /**
- * @param password
- *
- * @jmx.managed-attribute
- */
- public void setPassword(String password)
- {
- if (password == null)
- {
- password = DEFAULT_PASSWORD;
- }
- this.password = password;
- }
-
- /**
- * @param user
- *
- * @jmx.managed-attribute
- */
- public void setUser(String user)
- {
- if (user == null)
- {
- user = DEFAULT_USER;
- }
- this.user = user;
- }
-
- /**
- * @param flags
- *
- * @jmx.managed-attribute
- */
- public void setFlags(String flags)
- {
- if (flags == null)
- {
- flags = DEFAULT_FLAGS;
- }
- this.flags = flags;
- }
-
- // Lifecycle -----------------------------------------------------
+ /**
+ * @param port
+ *
+ * @jmx.managed-attribute
+ */
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+
+ /**
+ * Set the delay for remote hypersonic initialisation.
+ *
+ * @jmx.managed-attribute
+ */
+ public void setDelay(final long delay)
+ {
+ this.delay = delay;
+ }
+
+ /**
+ * Get the delay for remote hypersonic initialisation.
+ *
+ * @jmx.managed-attribute
+ */
+ public long getDelay()
+ {
+ return delay;
+ }
+
+ // Lifecycle -----------------------------------------------------
- /**
- * Start the database
- */
- protected void startService() throws Exception
- {
- if (inMemoryMode)
- {
- startInMemoryDatabase();
- }
- else
- {
- startStandaloneDatabase();
- }
- }
+ /**
+ * Start the database
+ */
+ protected void startService() throws Exception
+ {
+ if (serverMode)
+ {
+ startRemoteDatabase();
+ }
+ else if (inMemoryMode)
+ {
+ startInMemoryDatabase();
+ }
+ else
+ {
+ startStandaloneDatabase();
+ }
+ }
- /**
- * We now close the connection clean by calling the
- * serverSocket throught jdbc. The MBeanServer calls this
- * method at closing time.
- */
- protected void stopService() throws Exception
- {
- if (inMemoryMode)
- {
- stopInMemoryDatabase();
- }
- else
- {
- stopStandaloneDatabase();
- }
- }
-
- // Private -------------------------------------------------------
-
- /**
- * Start the standalone (in process) database.
- */
- private void startStandaloneDatabase() throws Exception
- {
- final File h2Dir = checkDataDir() ;
+ /**
+ * We now close the connection clean by calling the
+ * serverSocket throught jdbc. The MBeanServer calls this
+ * method at closing time.
+ */
+ protected void stopService() throws Exception
+ {
+ if (serverMode)
+ {
+ stopRemoteDatabase();
+ }
+ else if (inMemoryMode)
+ {
+ stopInMemoryDatabase();
+ }
+ else
+ {
+ stopStandaloneDatabase();
+ }
+ }
- dbPath = new File(h2Dir, name);
+ private void stopRemoteDatabase() throws SQLException
+ {
+ Server.shutdownTcpServer( "tcp://" + address + ":" + port, "", true );
+ }
- final String dbURL = JDBC_URL_PREFIX + dbPath.toURI().toString() + flags ;
+ // Private -------------------------------------------------------
+
+ /**
+ * Start the standalone (in process) database.
+ */
+ private void startStandaloneDatabase() throws Exception
+ {
+ final File h2Dir = checkDataDir() ;
+
+ dbPath = new File(h2Dir, name);
+
+ final String dbURL = JDBC_URL_PREFIX + dbPath.toURI().toString() + flags ;
+ log.info(dbURL);
+
+ // Check we have connectivity
+ connection = getConnection(dbURL);
+ }
- // Check we have connectivity
- connection = getConnection(dbURL);
- }
-
- /**
+ /**
* Start the only in memory database.
*/
- private void startInMemoryDatabase() throws Exception
- {
- final String dbURL = JDBC_MEM_URL_PREFIX + name + flags ;
+ private void startInMemoryDatabase() throws Exception
+ {
+ final String dbURL = JDBC_MEM_URL_PREFIX + name + flags ;
- // hold a connection so h2 does not close the database
- connection = getConnection(dbURL);
- }
+ // hold a connection so h2 does not close the database
+ connection = getConnection(dbURL);
+ }
+
+ /**
+ * Start a remote/server database
+ * @throws Exception
+ */
+ void startRemoteDatabase() throws Exception
+ {
+ final File h2Dir = checkDataDir() ;
+ dbPath = new File(h2Dir, name);
+
+ // Start DB in new thread, or else it will block us
+ serverThread = new Thread("h2-" + name)
+ {
+ public void run()
+ {
+ try
+ {
+ log.debug( "Starting remote h2 db with port : " + port );
+ final String[] args = new String[] {
+ "-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();
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to start database", e);
+ }
+ }
+ };
+
+ serverThread.start();
+
+ if (delay > 0)
+ {
+ log.debug("Waiting for Database initialisation: maximum " + delay + " milliseconds") ;
+ try
+ {
+ serverThread.join(delay) ;
+ }
+ catch (final InterruptedException ie)
+ {
+ Thread.currentThread().interrupt() ;
+ }
+
+ if (serverThread.isAlive())
+ {
+ log.warn("Database initialisation is still active") ;
+ }
+ else
+ {
+ log.debug("Database initialisation completed") ;
+ }
+ }
+ }
/**
* Stop the standalone (in process) database.
@@ -325,47 +499,51 @@
log.info("Database in memory closed clean");
}
- /**
- * Get the connection.
- *
- * @param dbURL jdbc url.
- * @return the connection, allocate one if needed.
- * @throws Exception
- */
- private synchronized Connection getConnection(String dbURL) throws Exception
- {
- if (connection == null)
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- Class.forName(JDBC_DRIVER_CLASS, true, cl).newInstance();
- connection = DriverManager.getConnection(dbURL, user, password);
- }
- return connection;
- }
+ /**
+ * Get the connection.
+ *
+ * @param dbURL jdbc url.
+ * @return the connection, allocate one if needed.
+ * @throws Exception
+ */
+ private synchronized Connection getConnection(String dbURL) throws Exception
+ {
+ if (connection == null)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ Class.forName(JDBC_DRIVER_CLASS, true, cl).newInstance();
+ connection = DriverManager.getConnection(dbURL, user, password);
+ }
+ return connection;
+ }
- /**
- * Check the existence of the h2 data directory.
- * @return The h2 data directory.
- * @throws IOException For errors checking/creating the h2 data directory.
- */
- private File checkDataDir()
- throws IOException
- {
- // Get the server data directory
- final File dataDir = ServerConfigLocator.locate().getServerDataDir();
+ /**
+ * Check the existence of the h2 data directory.
+ * @return The h2 data directory.
+ * @throws IOException For errors checking/creating the h2 data directory.
+ */
+ private File checkDataDir() throws IOException
+ {
+ // Get the server data directory
+ final File dataDir = getDataDir();
- // Get DB directory
- final File h2Dir = new File(dataDir, H2_DATA_DIR);
+ // Get DB directory
+ final File h2Dir = new File(dataDir, H2_DATA_DIR);
- if (!h2Dir.exists())
- {
- h2Dir.mkdirs();
- }
- else if (!h2Dir.isDirectory())
- {
- throw new IOException("Failed to create directory: " + h2Dir);
- }
- return h2Dir ;
- }
+ if (!h2Dir.exists())
+ {
+ h2Dir.mkdirs();
+ }
+ else if (!h2Dir.isDirectory())
+ {
+ throw new IOException("Failed to create directory: " + h2Dir);
+ }
+ return h2Dir ;
+ }
+
+ File getDataDir()
+ {
+ return ServerConfigLocator.locate().getServerDataDir();
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseMBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseMBean.java 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseMBean.java 2008-05-22 18:32:46 UTC (rev 20114)
@@ -33,7 +33,7 @@
* A few notes on h2 running modes:
*
* remote (server) mode
- * Not supported yet
+ * h2 can be connected to vid tcp
*
* in-process (standalone) mode
* h2 can only be contacted from in-vm clients
@@ -69,7 +69,19 @@
boolean isInMemoryMode() ;
void setInMemoryMode(boolean b) ;
+ /** Server/remote mode */
+ boolean isServerMode() ;
+ void setServerMode(boolean mode) ;
+
/** The flags to use when connecting to the DB, default is "" */
String getFlags();
void setFlags(String flags);
+
+ /** The listening port when in remove server mode, default is '9092' */
+ int getPort();
+ void setPort(int port);
+
+ /** The binding address, default is '0.0.0.0' */
+ String getBindAddress();
+ void setBindAddress(String address);
}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/internal/soa/esb/dependencies/H2DatabaseUnitTest.java 2008-05-22 18:32:46 UTC (rev 20114)
@@ -0,0 +1,93 @@
+/*
+ * 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.internal.soa.esb.dependencies;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link H2Database}
+ * <p/>
+ *
+ * @author <a href="mailto:kbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public class H2DatabaseUnitTest
+{
+ private final int port = 9098;
+ private H2Database database;
+
+ @Test
+ public void startRemoteDatabase() throws Exception
+ {
+ database.setServerMode( true );
+ database.startRemoteDatabase();
+
+ // give the database time to start up.
+ Thread.sleep( 1000 );
+
+ assertDatabaseIsStarted();
+ database.stop();
+ }
+
+ @Before
+ public void setup()
+ {
+ database = new H2DatabaseMock();
+ database.setDatabase( "test" );
+ database.setPort( port );
+ }
+
+ private void assertDatabaseIsStarted() throws UnknownHostException, IOException
+ {
+ Socket socket = null;
+ try
+ {
+ socket = new Socket( InetAddress.getLocalHost(), port );
+ boolean bound = socket.isBound();
+ assertTrue ( bound );
+ }
+ finally
+ {
+ if ( socket != null )
+ socket.close();
+ }
+ }
+
+ private static class H2DatabaseMock extends H2Database
+ {
+ @Override
+ File getDataDir()
+ {
+ return new File( System.getProperty( "java.io.tmpdir" ) );
+ }
+ }
+
+}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/build.xml 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/build.xml 2008-05-22 18:32:46 UTC (rev 20114)
@@ -18,120 +18,120 @@
todir="${org.jboss.esb.server.deploy.dir}"
overwrite="false"/>
</target>
+
+ <target name="quickstart-specific-undeploys" description="Quickstart specific undeploys">
+ <delete file="${org.jboss.esb.server.deploy.dir}/quickstart-ds.xml"/>
+ </target>
+
+ <target name="init" depends="dependencies">
+ <property name="driver" value="org.h2.Driver"/>
+ <property name="driver.jar" value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/h2.jar"/>
+ <property name="url" value="jdbc:h2:tcp://localhost:9095/file:${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/data/h2/h2DB"/>
+ </target>
+
- <target name="runtest" depends="dependencies" description="Insert row data into sql table polled by gateway">
- <property name="hsqldb.jar"
- value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
- <echo>Insert row data into sql table polled by gateway</echo>
- <sql
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
- userid="sa"
- autocommit="true"
- password="">
- <classpath>
- <pathelement path="${hsqldb.jar}"/>
- </classpath>
+ <target name="runtest" depends="init" description="Insert row data into sql table polled by gateway">
+ <echo>Insert row data into sql table polled by gateway</echo>
+ <sql
+ driver="${driver}"
+ url="${url}"
+ userid="sa"
+ autocommit="true"
+ password="">
+ <classpath>
+ <pathelement path="${driver.jar}"/>
+ </classpath>
<transaction src="populate.sql"/>
- </sql>
+ </sql>
</target>
- <target name="create" depends="dependencies" description="create table tx_esb_messages">
- <property name="hsqldb.jar"
- value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
+ <target name="create" depends="init" description="create table tx_esb_messages">
<echo>create table tx_esb_messages</echo>
<sql
print="true"
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ driver="${driver}"
+ url="${url}"
userid="sa"
autocommit="true"
password="">
<classpath>
- <pathelement path="${hsqldb.jar}"/>
+ <pathelement path="${driver.jar}"/>
</classpath>
<transaction>
- create table tx_esb_messages(MESSAGE_ID varchar, STATUS_COL varchar NOT NULL, TIMESTAMP_COL bigint, DATA_COL varchar NOT NULL);
+ create table tx_esb_messages(MESSAGE_ID varchar, STATUS_COL varchar NOT NULL, TIMESTAMP_COL bigint, DATA_COL varchar NOT NULL);
</transaction>
- </sql>
-
+ </sql>
</target>
- <target name="drop" depends="dependencies" description="drop table tx_esb_messages">
- <property name="hsqldb.jar"
- value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
+ <target name="drop" depends="init" description="drop table tx_esb_messages">
<echo>drop table tx_esb_messages</echo>
<sql
print="true"
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ driver="${driver}"
+ url="${url}"
userid="sa"
autocommit="true"
password="">
<classpath>
- <pathelement path="${hsqldb.jar}"/>
+ <pathelement path="${driver.jar}"/>
</classpath>
<transaction>
- drop table tx_esb_messages
+ drop table tx_esb_messages
</transaction>
- </sql>
-
+ </sql>
</target>
- <target name="drop2" depends="dependencies" description="drop table gateway_table">
- <property name="hsqldb.jar"
- value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
+ <target name="drop2" depends="init" description="drop table gateway_table">
+ <echo>drop table tx_esb_messages</echo>
<echo>drop table gateway_table</echo>
<sql
print="true"
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ driver="${driver}"
+ url="${url}"
userid="sa"
autocommit="true"
password="">
<classpath>
- <pathelement path="${hsqldb.jar}"/>
+ <pathelement path="${driver.jar}"/>
</classpath>
<transaction>
- drop table gateway_table
+ drop table gateway_table
</transaction>
- </sql>
-
+ </sql>
</target>
- <target name="select" depends="dependencies" description="select * from gateway_table">
- <property name="hsqldb.jar"
- value="${org.jboss.esb.server.home}/server/${org.jboss.esb.server.config}/lib/hsqldb.jar"/>
- <echo>Select * from gateway_table</echo>
+ <target name="select" depends="init" description="select * from gateway_table">
+ <echo>Select * from tx_esb_messages</echo>
<sql
print="true"
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ driver="${driver}"
+ url="${url}"
userid="sa"
autocommit="true"
password="">
<classpath>
- <pathelement path="${hsqldb.jar}"/>
+ <pathelement path="${driver.jar}"/>
</classpath>
<transaction>
- select * from tx_esb_messages
+ select * from tx_esb_messages
</transaction>
- </sql>
+ </sql>
+
+ <echo>Select * from gateway_table</echo>
<sql
print="true"
- driver="org.hsqldb.jdbcDriver"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ driver="${driver}"
+ url="${url}"
userid="sa"
autocommit="true"
password="">
<classpath>
- <pathelement path="${hsqldb.jar}"/>
+ <pathelement path="${driver.jar}"/>
</classpath>
<transaction>
- select * from gateway_table
+ select * from gateway_table where DATA_COLUMN like 'data%' and upper(STATUS_COL) like 'P%' order by DATA_COLUMN
</transaction>
- </sql>
-
+ </sql>
</target>
<target name="deploy-jms-dests">
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jboss-esb.xml 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jboss-esb.xml 2008-05-22 18:32:46 UTC (rev 20114)
@@ -3,16 +3,14 @@
<providers>
<sql-provider name="GatewaySQLprovider"
- url="jdbc:hsqldb:hsql://localhost:1703"
- driver="org.hsqldb.jdbcDriver"
- username="sa"
- password="">
+ url="jdbc:h2:tcp://localhost:9095/file:${jboss.server.data.dir}${/}h2${/}h2DB"
+ datasource="java:/QuickstartDB">
<sql-bus busid="helloSQLChannel" >
<sql-message-filter
- tablename="GATEWAY_TABLE"
+ tablename="gateway_table"
status-column="STATUS_COL"
- order-by="DATA_COLUMN"
- where-condition="DATA_COLUMN like 'data%'"
+ order-by="DATA_COLUMN"
+ where-condition="DATA_COLUMN like 'data%'"
message-column="DATA_COLUMN"
message-id-column="UNIQUE_ID"
insert-timestamp-column="TIMESTAMP_COL"
@@ -21,15 +19,15 @@
</sql-provider>
<sql-provider name="SQLprovider"
- url="jdbc:hsqldb:hsql://localhost:1703"
+ url="jdbc:h2:tcp://localhost:9095/file:${jboss.server.data.dir}${/}h2${/}h2DB"
datasource="java:/QuickstartDB">
<sql-bus busid="TxHelloSQLChannel" >
<sql-message-filter
tablename="TX_ESB_MESSAGES"
- message-id-column="MESSAGE_ID"
+ message-id-column="MESSAGE_ID"
status-column="STATUS_COL"
- insert-timestamp-column="TIMESTAMP_COL"
- message-column="DATA_COLUMN"
+ insert-timestamp-column="TIMESTAMP_COL"
+ message-column="DATA_COLUMN"
/>
</sql-bus>
</sql-provider>
@@ -37,27 +35,16 @@
</providers>
<services>
- <service
- category="myCategory"
- name="myTxListener"
- description="Hello World TX SQL Action (esb jdbc listener)">
+ <service category="myCategory" name="myTxListener" description="Hello World TX SQL Action (esb jdbc listener)">
<listeners>
- <sql-listener name="SqlGateway"
- busidref="helloSQLChannel"
- maxThreads="1"
- is-gateway="true"/>
- <sql-listener name="TxSqlListener"
- busidref="TxHelloSQLChannel"
- maxThreads="1">
- <property name="transacted" value="true"/>
+ <sql-listener name="SqlGateway" busidref="helloSQLChannel" maxThreads="1" is-gateway="true"/>
+ <sql-listener name="TxSqlListener" busidref="TxHelloSQLChannel" maxThreads="1">
+ <property name="transacted" value="true"/>
</sql-listener>
</listeners>
<actions mep="OneWay">
- <action name="action1"
- class="org.jboss.soa.esb.samples.quickstart.helloworldtxsqlaction.MyAction"
- process="displayMessage"
- />
- <action name="action2" class="org.jboss.soa.esb.actions.SystemPrintln" />
+ <action name="action1" class="org.jboss.soa.esb.samples.quickstart.helloworldtxsqlaction.MyAction" process="displayMessage" />
+ <action name="action2" class="org.jboss.soa.esb.actions.SystemPrintln" />
</actions>
</service>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jbossesb-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jbossesb-service.xml 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/jbossesb-service.xml 2008-05-22 18:32:46 UTC (rev 20114)
@@ -5,9 +5,7 @@
name="jboss.esb:service=QuickstartDatabaseInitializer">
<attribute name="Datasource">java:/QuickstartDB</attribute>
<attribute name="ExistsSql">select * from gateway_table</attribute>
- <attribute name="SqlFiles">
- hsqldb/create.sql
- </attribute>
+ <attribute name="SqlFiles">h2/create.sql</attribute>
<depends>jboss.jca:name=QuickstartDB,service=DataSourceBinding</depends>
</mbean>
</server>
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/quickstart-ds.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/quickstart-ds.xml 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/quickstart-ds.xml 2008-05-22 18:32:46 UTC (rev 20114)
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
- <local-tx-datasource>
- <jndi-name>QuickstartDB</jndi-name>
- <connection-url>jdbc:hsqldb:hsql://${jboss.bind.address}:1703</connection-url>
- <driver-class>org.hsqldb.jdbcDriver</driver-class>
- <user-name>sa</user-name>
- <password></password>
- <min-pool-size>5</min-pool-size>
- <max-pool-size>20</max-pool-size>
- <idle-timeout-minutes>0</idle-timeout-minutes>
- <depends>jboss:service=Hypersonic</depends>
- <prepared-statement-cache-size>32</prepared-statement-cache-size>
- </local-tx-datasource>
+ <xa-datasource>
+ <jndi-name>QuickstartDB</jndi-name>
+ <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
+ <track-connection-by-tx/>
+ <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
+ <xa-datasource-property name="URL">jdbc:h2:tcp://localhost:9095/file:${jboss.server.data.dir}/h2/h2DB</xa-datasource-property>
+ <xa-datasource-property name="User">sa</xa-datasource-property>
+ <xa-datasource-property name="Password"></xa-datasource-property>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ <idle-timeout-minutes>0</idle-timeout-minutes>
+ <prepared-statement-cache-size>32</prepared-statement-cache-size>
+ <depends>jboss:service=h2,database=h2DB</depends>
+ </xa-datasource>
- <!-- For hsqldb accessed from jboss only, in-process (standalone) mode -->
- <mbean code="org.jboss.jdbc.HypersonicDatabase"
- name="jboss:service=Hypersonic">
- <attribute name="Port">1703</attribute>
- <attribute name="BindAddress">${jboss.bind.address}</attribute>
- <attribute name="Database">QuickstartDB</attribute>
- <attribute name="Silent">true</attribute>
- <attribute name="Trace">false</attribute>
- <attribute name="No_system_exit">true</attribute>
+ <mbean code="org.jboss.internal.soa.esb.dependencies.H2Database" name="jboss:service=h2,database=h2DB">
+ <attribute name="Database">h2DB</attribute>
+ <attribute name="ServerMode">true</attribute>
+ <attribute name="Port">9095</attribute>
+ <attribute name="InMemoryMode">false</attribute>
</mbean>
+
</datasources>
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/h2/create.sql
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/h2/create.sql (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/samples/quickstarts/helloworld_tx_sql_action/src/h2/create.sql 2008-05-22 18:32:46 UTC (rev 20114)
@@ -0,0 +1,15 @@
+CREATE TABLE gateway_table
+(
+unique_id INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY,
+data_column VARCHAR(255) NOT NULL,
+status_col VARCHAR(255) NOT NULL,
+timestamp_col VARCHAR(255)
+);
+
+CREATE TABLE TX_ESB_MESSAGES
+(
+message_id VARCHAR(255) NOT NULL,
+data_column VARCHAR(6055) NOT NULL,
+status_col VARCHAR(255) NOT NULL,
+timestamp_col VARCHAR(255)
+);
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbpm-ds.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbpm-ds.xml 2008-05-22 11:56:56 UTC (rev 20113)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/jbpm/src/main/resources/jbpm-ds.xml 2008-05-22 18:32:46 UTC (rev 20114)
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
-<!--
<xa-datasource>
<jndi-name>JbpmDS</jndi-name>
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
@@ -16,20 +15,7 @@
<prepared-statement-cache-size>32</prepared-statement-cache-size>
<depends>jboss:service=h2,database=jbpmDB</depends>
</xa-datasource>
--->
- <local-tx-datasource>
- <jndi-name>JbpmDS</jndi-name>
- <connection-url>jdbc:h2:${jboss.server.data.dir}${/}h2${/}jbpmDB;MVCC=TRUE</connection-url>
- <driver-class>org.h2.Driver</driver-class>
- <user-name>sa</user-name>
- <password/>
- <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
- <min-pool-size>5</min-pool-size>
- <max-pool-size>20</max-pool-size>
- <idle-timeout-minutes>0</idle-timeout-minutes>
- <prepared-statement-cache-size>32</prepared-statement-cache-size>
- <depends>jboss:service=h2,database=jbpmDB</depends>
- </local-tx-datasource>
+
<mbean code="org.jboss.internal.soa.esb.dependencies.H2Database"
name="jboss:service=h2,database=jbpmDB">
<attribute name="Database">jbpmDB</attribute>
More information about the jboss-svn-commits
mailing list