Search in sources :

Example 1 with ProcessEngineLifecycleListener

use of org.activiti.engine.ProcessEngineLifecycleListener in project Activiti by Activiti.

the class AbstractActviti6Test method initializeH2WebApp.

protected void initializeH2WebApp(ProcessEngine processEngine) {
    try {
        final Server server = Server.createWebServer("-web");
        // Shutdown hook
        final ProcessEngineConfiguration processEngineConfiguration = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration();
        final ProcessEngineLifecycleListener originalLifecycleListener = processEngineConfiguration.getProcessEngineLifecycleListener();
        processEngineConfiguration.setProcessEngineLifecycleListener(new ProcessEngineLifecycleListener() {

            @Override
            public void onProcessEngineClosed(ProcessEngine processEngine) {
                server.stop();
                originalLifecycleListener.onProcessEngineClosed(processEngine);
            }

            @Override
            public void onProcessEngineBuilt(ProcessEngine processEngine) {
                originalLifecycleListener.onProcessEngineBuilt(processEngine);
            }
        });
        // Actually start the web server
        server.start();
    } catch (SQLException e) {
        logger.warn("Could not start H2 webapp", e);
    }
}
Also used : ProcessEngineConfiguration(org.activiti.engine.ProcessEngineConfiguration) Server(org.h2.tools.Server) SQLException(java.sql.SQLException) ProcessEngineImpl(org.activiti.engine.impl.ProcessEngineImpl) ProcessEngineLifecycleListener(org.activiti.engine.ProcessEngineLifecycleListener) ProcessEngine(org.activiti.engine.ProcessEngine)

Aggregations

SQLException (java.sql.SQLException)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 ProcessEngineConfiguration (org.activiti.engine.ProcessEngineConfiguration)1 ProcessEngineLifecycleListener (org.activiti.engine.ProcessEngineLifecycleListener)1 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)1 Server (org.h2.tools.Server)1