ejbServerProps.putAll(props);
ejbServerProps.setProperty("openejb.ejbd.uri", "http://127.0.0.1:8080/openejb/ejb");
ejbServer.init(ejbServerProps);
// Add our naming context listener to the server which registers all Tomcat resources with OpenEJB
StandardServer standardServer = (StandardServer) ServerFactory.getServer();
OpenEJBNamingContextListener namingContextListener = new OpenEJBNamingContextListener(standardServer);
// Standard server has no state property, so we check global naming context to determine if server is started yet
if (standardServer.getGlobalNamingContext() != null) {
namingContextListener.start();
}
standardServer.addLifecycleListener(namingContextListener);
// Process all applications already started. This deploys EJBs, PersistenceUnits
// and modifies JNDI ENC references to OpenEJB managed objects such as EJBs.
processRunningApplications(tomcatWebAppBuilder, standardServer);
if (Boolean.getBoolean("openejb.servicemanager.enabled")) {
manager = ServiceManager.getManager();
manager.init();
manager.start(false);
} else {
try {
ServerService serverService = (ServerService) Class.forName("org.apache.openejb.server.cxf.CxfService").newInstance();
serverService.start();
} catch (Exception ignored) {
}
}
standardServer.addLifecycleListener(new LifecycleListener() {
public void lifecycleEvent(LifecycleEvent event) {
String type = event.getType();
if (Lifecycle.AFTER_STOP_EVENT.equals(type)) {
TomcatLoader.this.destroy();
}