本文整理汇总了Java中org.eclipse.jetty.servlet.ServletContextHandler.addEventListener方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextHandler.addEventListener方法的具体用法?Java ServletContextHandler.addEventListener怎么用?Java ServletContextHandler.addEventListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.servlet.ServletContextHandler
的用法示例。
在下文中一共展示了ServletContextHandler.addEventListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startComponent
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@Override
public void startComponent() {
// Initialize servlet using RESTEasy and it's Guice bridge.
// The listener must be injected by the same Guice module which also binds the REST endpoints.
ServletContextHandler servletHandler = new ServletContextHandler();
servletHandler.addEventListener(listener);
servletHandler.addServlet(HttpServletDispatcher.class, "/*");
// Starting up Jetty to serve the REST API.
server = new Server(port);
server.setHandler(servletHandler);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: ParticipantHoster
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public ParticipantHoster(final List<ContextParticipantProxy> unregisteredParticipants, final short port) throws Exception {
participants = unregisteredParticipants;
participantsUrl = FluentIterable.from(participants).transform(new Function<ContextParticipantProxy, String>() {
@Override
public String apply(final ContextParticipantProxy input) {
// return "/" + input.getApplicationName() +
// "/ContextParticipant/*";
return input.getApplicationName();
}
}).append("/*");
server = new Server(port);
final ServletContextHandler sch = new ServletContextHandler(server, "/");
sch.addEventListener(new InnerListener());
sch.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
sch.addServlet(DefaultServlet.class, "/");
server.start();
}
示例3: beforeClass
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ccowServer = new Server(serverPort);
final CCOWContextListener c = new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule());
final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
ccowServer.addBean(mbContainer);
final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(ccowServer, "/ws",
ServletContextHandler.SESSIONS);
webSocketServletContextHandler.addEventListener(c);
WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);
final ServletContextHandler restServletContextHandler = new ServletContextHandler(ccowServer, "/");
restServletContextHandler.addEventListener(c);
restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
final ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler});
ccowServer.setHandler(contexts);
ccowServer.start();
}
示例4: main
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Injector injector = Guice.createInjector(getModules(args));
Server server = new Server(injector.getInstance(Key.get(Integer.class, Port.class)));
ServletContextHandler handler = new ServletContextHandler(server, "/pvwatts");
handler.addEventListener(injector.getInstance(
GuiceResteasyBootstrapServletContextListener.class));
ServletHolder sh = new ServletHolder(HttpServletDispatcher.class);
handler.addServlet(sh, "/*");
server.setHandler(handler);
server.start();
server.join();
}
示例5: HelloMain
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public HelloMain(int port) {
this.port = port;
context = new ServletContextHandler();
context.setContextPath("/");
// Use Weld to inject into servlets
context.addEventListener(new org.jboss.weld.environment.servlet.Listener());
jettyServer = new Server(port);
jettyServer.setHandler(context);
addJaxRsApplication(HelloApplication.class);
start();
}
示例6: init
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
/**
* Method used to initialize and start the SSE server
*/
public static void init()
{
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8070);
connector.setAcceptors(3);
connector.setThreadPool(new QueuedThreadPool(50));
connector.setMaxIdleTime(72*60*60*1000);
connector.setAcceptQueueSize(50000);
connector.setRequestBufferSize(50000);
connector.setResponseBufferSize(50000);
server.setConnectors(new Connector[] { connector });
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
//context.setResourceBase(System.getProperty("java.io.tmpdir"));
ServletHolder requestServletHolder = new ServletHolder(EventServer.class);
context.addServlet(requestServletHolder, "/response");
ServletHolder notificationServletHolder = new ServletHolder(NotificationServer.class);
context.addServlet(notificationServletHolder, "/notification");
server.setHandler(context);
context.addEventListener(new ConfigureService());
context.addEventListener(new NotificationService());
try {
server.start();
LOG.info("Server Started");
server.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例7: main
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
ContextHandlerCollection contexts = new ContextHandlerCollection();
ServletContextHandler root = new ServletContextHandler(contexts, "/");
root.addEventListener(new MetricsContextListener());
root.addFilter(MetricsFilter.class, "/*", EnumSet.allOf(DispatcherType.class))
.setAsyncSupported(true);
root.addServlet(ToyWorkServlet.class, "/*");
server.setHandler(contexts);
server.start();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new RunSomeQueries(8080));
server.join();
}
示例8: main
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
// This test server exposes the CCOW ContextManager according to the
// HTTP Web bindings and exposes the ContextParticipant notification
// part through Websockets.
// Connect to the server at
// ws://host:serverPort/ws/ContextManager/{unique-client-id}
// All invocations on ContextParticipants that the ContextManager does
// according to the HTTP Web bindings spec will also be done to the
// Websocket client (see ccow.cma.IContextParticipant for procedures
// that are invoked). As
// ContextParticipant.ContextChangedPending return values the
// connected Websocket client will have a max of 5 seconds to respond
// accordingly.
server = new Server(2116);
final CCOWContextListener servletContextListener = new CCOWContextListener();
final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(server, "/ws",
ServletContextHandler.SESSIONS);
webSocketServletContextHandler.addEventListener(servletContextListener);
WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);
final ServletContextHandler restServletContextHandler = new ServletContextHandler(server, "/");
restServletContextHandler.addEventListener(servletContextListener);
restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
final ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler });
server.setHandler(contexts);
server.start();
server.join();
}
示例9: main
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
// This test server exposes the CCOW ContextManager according to the
// HTTP Web bindings and exposes the ContextParticipant notification
// part through Websockets.
// Connect to the server at
// ws://host:serverPort/ws/ContextManager/{unique-client-id}
// All invocations on ContextParticipants that the ContextManager does
// according to the HTTP Web bindings spec will also be done to the
// Websocket client (see ccow.cma.IContextParticipant for procedures
// that are invoked). As
// ContextParticipant.ContextChangedPending return values the
// connected Websocket client will have a max of 5 seconds to respond
// accordingly.
final Server server = new Server(2116);
final ContextState commonState = new ContextState();
final CCOWContextListener servletContextListener = new CCOWContextListener(commonState);
final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(server, "/ws",
ServletContextHandler.SESSIONS);
webSocketServletContextHandler.addEventListener(servletContextListener);
WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);
final ServletContextHandler restServletContextHandler = new ServletContextHandler(server, "/");
restServletContextHandler.addEventListener(servletContextListener);
restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
final ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler });
server.setHandler(contexts);
server.start();
server.join();
}
示例10: beforeClass
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
server = new Server(port);
final ServletContextHandler sch = new ServletContextHandler(server, "/");
sch.addEventListener(new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule()));
sch.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
sch.addServlet(DefaultServlet.class, "/");
server.start();
}
示例11: beforeClass
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
ccowServer = new Server(serverPort);
final ServletContextHandler sch = new ServletContextHandler(ccowServer, "/");
sch.addEventListener(new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule()));
sch.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
sch.addServlet(DefaultServlet.class, "/");
ccowServer.start();
}
示例12: generateServletContextHandler
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler generateServletContextHandler(WebApplicationContext context) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setErrorHandler(generateErrorHandler());
contextHandler.setContextPath("/");
contextHandler.addServlet(new ServletHolder(generateDispatcherServlet(context)), "/*");
contextHandler.addEventListener(new ContextLoaderListener(context));
return contextHandler;
}
示例13: generateServletContextHandler
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler generateServletContextHandler(
WebApplicationContext webappContext
) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
contextHandler.setContextPath("/");
contextHandler.addServlet(new ServletHolder(new DispatcherServlet(webappContext)), "/*");
contextHandler.addEventListener(new ContextLoaderListener(webappContext));
FilterHolder requestTracingFilterHolder = contextHandler.addFilter(
RequestTracingFilter.class, "/*", EnumSet.allOf(DispatcherType.class)
);
requestTracingFilterHolder.setInitParameter(USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME, USER_ID_HEADER_KEYS);
return contextHandler;
}
示例14: getServletContextHandler
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
WebConfigurer configurer = new WebConfigurer();
configurer.setContext(context);
contextHandler.addEventListener(configurer);
// Create the SessionHandler (wrapper) to handle the sessions
HashSessionManager manager = new HashSessionManager();
SessionHandler sessions = new SessionHandler(manager);
contextHandler.setHandler(sessions);
return contextHandler;
}
示例15: getServletContextHandler
import org.eclipse.jetty.servlet.ServletContextHandler; //导入方法依赖的package包/类
private static ServletContextHandler getServletContextHandler(AnnotationConfigWebApplicationContext context) throws IOException {
ServletContextHandler contextHandler = new ServletContextHandler();
JPAWebConfigurer configurer = new JPAWebConfigurer();
configurer.setContext(context);
contextHandler.addEventListener(configurer);
// Create the SessionHandler (wrapper) to handle the sessions
HashSessionManager manager = new HashSessionManager();
SessionHandler sessions = new SessionHandler(manager);
contextHandler.setHandler(sessions);
return contextHandler;
}