I'm trying to embedd Cloudscape in Tomcat 4.0 but all of the documentatin I can find
seems to relate to earlier versions of Tomcat. Can anyone help me get started
converting the following code from Cloudscape to work with the Catalina classes.
Thanks
Kurt
package CloudscapeTomcatTie;
import org.apache.tomcat.core.*;
import java.sql.*;
import RJPing;
/**
*
* CloudscapeTomcatTie supplies the hooks to start and shutdown
* Cloudscape in an orderly fashion within Tomcat.
* <p>
* To register this class with Tomcat, add the line
* <pre>
* <ContextInterceptor className="CloudscapeTomcatTie"/>
* </pre>
* to the tomcat file conf/server.xml.
* You will also need to have this class in your classpath when
* starting the system.
*
* @see org.apache.tomcat.core.BaseInterceptor
*
* @author ames
**/
public class CloudscapeTomcatTie extends BaseInterceptor {
static final String RMI_JDBC_SHUTDOWN_ARGS[] = {"jdbc:cloudscape:rmi", "shutdown"};
// only pay attention to server boot and server shutdown hooks
public void engineInit(ContextManager cm) throws TomcatException {
try {
// boot the Cloudscape engine by loading its JDBC driver
Class.forName("COM.cloudscape.core.JDBCDriver");
} catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
throw new TomcatException(cnfe);
}
// start the RmiJdbcServer to enable remote access
new Thread(new EmbedRmiJdbcServer()).start();
}
public void engineShutdown(ContextManager cm) throws TomcatException {
try {
// shutdown the Cloudscape engine.
// note that a valid user and password may be required if
// your Cloudscape system is configured with authentication
DriverManager.getConnection("jdbc:cloudscape:;shutdown=true;user=none;password=none");
} catch (SQLException se) {
String m = se.getMessage();
// Cloudscape throws an exception on successful shutdown;
// only throw an exception if that was not the one sent.
if (! "CloudscapeSystemShutdown".equals(m)) {
se.printStackTrace();
throw new TomcatException(se);
}
}
// shutdown the RmiJdbcServer
RJPing(RMI_JDBC_SHUTDOWN_ARGS);
}
}
/**
* EmbedRmiJdbcJServer
* will boot RmiJdbc in a separate thread
* upon request.
* This permits remote access to this JVM
* to any local JDBC drivers accessible from RmiJdbc.
*/
public class EmbedRmiJdbcServer implements Runnable {
static public final String ARGS[] = { "COM.cloudscape.core.JDBCDriver" };
static private boolean first = true;
// we only want one of these, so only let it run once
public synchronized void run() {
if (first) {
RmiJdbc.RJJdbcServer.main(ARGS);
first = false;
}
}
public EmbedRmiJdbcServer(){}
}