private JettyServer server;
public void start(ExtensionPointRegistry extensionPointRegistry) {
// Register a Jetty Servlet host
ServletHostExtensionPoint servletHosts =
extensionPointRegistry.getExtensionPoint(ServletHostExtensionPoint.class);
List<ServletHost> hosts = servletHosts.getServletHosts();
if (hosts != null) {
// Clear out any other hosts (eg webapp or tomcat) and add this jetty host is default
hosts.clear();
UtilityExtensionPoint utilities = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class);
final WorkScheduler workScheduler = utilities.getUtility(WorkScheduler.class);
// Allow privileged access to start MBeans. Requires MBeanPermission in security policy.
try {
server = AccessController.doPrivileged(new PrivilegedAction<JettyServer>() {
public JettyServer run() {
return new JettyServer(workScheduler);
}
});
servletHosts.addServletHost(server);
} catch (Exception e) {
logger.log(Level.WARNING, "Exception creating JettyServer", e);
}
}
}