Methods Summary |
---|
private void | createSchema()
try
{
tm.begin();
try
{
Connection conn = getConnection();
try
{
boolean success = execute(conn, "CREATE_TABLE_JOB_DETAILS");
if(success)
{
execute(conn, "CREATE_TABLE_JOB_LISTENERS");
execute(conn, "CREATE_TABLE_TRIGGERS");
execute(conn, "CREATE_TABLE_SIMPLE_TRIGGERS");
execute(conn, "CREATE_TABLE_CRON_TRIGGERS");
execute(conn, "CREATE_TABLE_BLOB_TRIGGERS");
execute(conn, "CREATE_TABLE_TRIGGER_LISTENERS");
execute(conn, "CREATE_TABLE_CALENDARS");
execute(conn, "CREATE_TABLE_PAUSED_TRIGGER_GRPS");
execute(conn, "CREATE_TABLE_FIRED_TRIGGERS");
execute(conn, "CREATE_TABLE_SCHEDULER_STATE");
execute(conn, "CREATE_TABLE_LOCKS");
execute(conn, "INSERT_TRIGGER_ACCESS");
execute(conn, "INSERT_JOB_ACCESS");
execute(conn, "INSERT_CALENDAR_ACCESS");
execute(conn, "INSERT_STATE_ACCESS");
execute(conn, "INSERT_MISFIRE_ACCESS");
}
}
finally
{
conn.close();
}
tm.commit();
}
catch(SQLException e)
{
throw new RuntimeException(e);
}
catch (RollbackException e)
{
throw new RuntimeException(e);
}
catch (HeuristicMixedException e)
{
throw new RuntimeException(e);
}
catch (HeuristicRollbackException e)
{
throw new RuntimeException(e);
}
finally
{
if(tm.getStatus() == Status.STATUS_ACTIVE)
tm.rollback();
}
}
catch(SystemException e)
{
throw new RuntimeException(e);
}
catch (NotSupportedException e)
{
throw new RuntimeException(e);
}
|
public javax.ejb.TimerService | createTimerService(javax.management.ObjectName objectName, org.jboss.ejb3.timerservice.TimedObjectInvoker invoker)Create a TimerService for use in a bean container.
Scheduler scheduler = getScheduler();
if (scheduler == null) return null;
return new TimerServiceImpl(scheduler, objectName, invoker);
|
private boolean | execute(java.sql.Connection conn, java.lang.String stmtName)
String sql = sqlProperties.getProperty(stmtName);
if(sql == null)
throw new IllegalStateException("No sql set for '" + stmtName + "'");
PreparedStatement stmt = conn.prepareStatement(sql);
try
{
stmt.execute();
return true;
}
catch(SQLException e)
{
log.warn("sql failed: " + sql);
if(log.isDebugEnabled())
log.debug("sql failed: " + sql, e);
return false;
}
finally
{
stmt.close();
}
|
private java.sql.Connection | getConnection()
return DBConnectionManager.getInstance().getConnection("myDS");
|
protected static org.quartz.Scheduler | getScheduler()
if(scheduler == null)
{
return null;
//throw new IllegalStateException("TimerServiceFactory hasn't been started yet");
}
return scheduler;
|
public void | removeTimerService(javax.ejb.TimerService aTimerService)
TimerServiceImpl timerService = (TimerServiceImpl) aTimerService;
timerService.shutdown();
|
public void | restoreTimerService(javax.ejb.TimerService aTimerService)
// TODO: implement Quartz restore timer service
|
public void | setDataSource(java.lang.String jndiName)
JNDIConnectionProvider connectionProvider = new JNDIConnectionProvider(jndiName, false);
// FIXME: remove hardcoding
DBConnectionManager.getInstance().addConnectionProvider("myDS", connectionProvider);
|
public void | setProperties(java.util.Properties props)
// if(scheduler != null)
// throw new IllegalStateException("already started");
// TODO: precondition the prop
properties = props;
|
public void | setSqlProperties(java.util.Properties props)
this.sqlProperties = props;
|
public synchronized void | start()
if(scheduler != null)
throw new IllegalStateException("already started");
log.debug("properties = " + properties);
InitialContext ctx = new InitialContext();
tm = (TransactionManager) ctx.lookup(TransactionManagerService.JNDI_NAME);
createSchema();
// TODO: bind in JNDI, or is this done by the JMX bean?
SchedulerFactory factory;
if(properties == null)
factory = new StdSchedulerFactory();
else
factory = new StdSchedulerFactory(properties);
scheduler = factory.getScheduler();
// TODO: really start right away?
scheduler.start();
|
public synchronized void | stop()
if(scheduler == null)
throw new IllegalStateException("already stopped");
// TODO: unbind from JNDI
// TODO: standby or shutdown?
scheduler.shutdown();
scheduler = null;
|