public void init(Properties props) throws Exception {
name = props.getProperty("name");
EjbServer ejbServer = new EjbServer();
ServerServiceAdapter adapter = new ServerServiceAdapter(ejbServer);
SystemInstance systemInstance = SystemInstance.get();
HttpListenerRegistry registry = systemInstance.getComponent(HttpListenerRegistry.class);
if (registry == null){
registry = new HttpListenerRegistry();
systemInstance.setComponent(HttpListenerRegistry.class, registry);
}
registry.addHttpListener(adapter, "/ejb/?.*");
// todo this breaks the http ejb server impl
// the service manage makes a static decision based on the interface of this class to create
// a service daemon socket or not. Since jetty is "self managed" and throws an exception from
// service socket, this breaks this code
// // props can name an implementation
// // if implementation is not named, use jetty if jetty classes are present; otherwise use openejb
// String impl = props.getProperty("impl");
// if ("Jetty".equalsIgnoreCase(impl)) {
// httpServer = (HttpServer) getClass().getClassLoader().loadClass("org.apache.openejb.server.httpd.JettyHttpServer").newInstance();
// } else if ("OpenEJB".equalsIgnoreCase(impl)) {
httpServer = new OpenEJBHttpServer(registry);
// } else if (impl == null) {
// try {
// getClass().getClassLoader().loadClass("org.mortbay.jetty.Server");
// httpServer = (HttpServer) getClass().getClassLoader().loadClass("org.apache.openejb.server.httpd.JettyHttpServer").newInstance();
// } catch (Exception ignored) {
// // Jetty classes not available
// httpServer = new OpenEJBHttpServer(registry);
// }
// } else {
// throw new IllegalArgumentException("Unknown HTTP server impl '" + impl + "'. Valid implementation are OpenEJB and Jetty.");
// }
// register the http server
systemInstance.setComponent(HttpServer.class, httpServer);
httpServer.init(props);
ejbServer.init(props);
}