public void contextInitialized( ServletContextEvent sce ) {
ServletContext ctx = sce.getServletContext();
logger.debug( "Starting HSQLDB Embedded Listener" ); //$NON-NLS-1$
HsqlDatabaseStarterBean starterBean = new HsqlDatabaseStarterBean();
String port = ctx.getInitParameter( "hsqldb-port" ); //$NON-NLS-1$
int portNum = -1;
if ( port != null ) {
logger.debug( String.format( "Port override specified: %s", port ) ); //$NON-NLS-1$
try {
portNum = Integer.parseInt( port );
starterBean.setPort( portNum );
} catch ( NumberFormatException ex ) {
logger.error( Messages.getErrorString( "HsqldbStartupListener.ERROR_0004_INVALID_PORT", "9001" ) ); //$NON-NLS-1$
port = null; // force check default port
}
}
starterBean.setDatabases( getDatabases( ctx ) );
String sampleDataAllowPortFailover = ctx.getInitParameter( "hsqldb-allow-port-failover" ); //$NON-NLS-1$
if ( ( sampleDataAllowPortFailover != null ) && ( sampleDataAllowPortFailover.equalsIgnoreCase( "true" ) ) ) { //$NON-NLS-1$
logger.debug( String.format( "Allow Port Failover specified" ) ); //$NON-NLS-1$
starterBean.setAllowPortFailover( true );
}
if ( starterBean.start() ) {
ctx.setAttribute( "hsqldb-starter-bean", starterBean ); //$NON-NLS-1$
}
}