本文整理汇总了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);
}