本文整理匯總了Java中org.eclipse.jetty.server.Server.addBean方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.addBean方法的具體用法?Java Server.addBean怎麽用?Java Server.addBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.Server
的用法示例。
在下文中一共展示了Server.addBean方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compose
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void compose(Server server) {
//Servlets + Guice
ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
servletContextHandler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
servletContextHandler.addServlet(DefaultServlet.class, "/");
//JMX stuff...
MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addEventListener(mbContainer);
server.addBean(mbContainer);
server.addBean(Log.getLog());
}
示例2: startServer
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void startServer() throws ServletException {
QueuedThreadPool threadPool = new QueuedThreadPool(10);
threadPool.setDaemon(true);
threadPool.setMaxThreads(10);
Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
http.setPort(2992);
server.addConnector(http);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setBaseResource(Resource.newClassPathResource("/org/lwjglx/debug/static"));
context.setWelcomeFiles(new String[] { "index.html" });
server.setHandler(context);
WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(context);
// wsfilter.getFactory().getPolicy().setIdleTimeout(5000);
wsfilter.addMapping(new ServletPathSpec("/ws"), new ProfilingConnectionCreator());
ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
holderDefault.setInitParameter("dirAllowed", "true");
context.addServlet(holderDefault, "/");
try {
server.start();
} catch (Exception e) {
throw new AssertionError("Could not start profiling server", e);
}
}
示例3: configureBasicAuthentication
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
protected ConstraintSecurityHandler configureBasicAuthentication(Server server,
ServerConnector connector, AvaticaServerConfiguration config) {
final String[] allowedRoles = config.getAllowedRoles();
final String realm = config.getHashLoginServiceRealm();
final String loginServiceProperties = config.getHashLoginServiceProperties();
HashLoginService loginService = new HashLoginService(realm, loginServiceProperties);
server.addBean(loginService);
return configureCommonAuthentication(server, connector, config, Constraint.__BASIC_AUTH,
allowedRoles, new BasicAuthenticator(), null, loginService);
}
示例4: configureDigestAuthentication
import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
protected ConstraintSecurityHandler configureDigestAuthentication(Server server,
ServerConnector connector, AvaticaServerConfiguration config) {
final String[] allowedRoles = config.getAllowedRoles();
final String realm = config.getHashLoginServiceRealm();
final String loginServiceProperties = config.getHashLoginServiceProperties();
HashLoginService loginService = new HashLoginService(realm, loginServiceProperties);
server.addBean(loginService);
return configureCommonAuthentication(server, connector, config, Constraint.__DIGEST_AUTH,
allowedRoles, new DigestAuthenticator(), null, loginService);
}