當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContextHandler.addEventListener方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:mnemonic-no,項目名稱:act-platform,代碼行數:19,代碼來源:ApiServer.java

示例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();
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:21,代碼來源:ParticipantHoster.java

示例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();

}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:26,代碼來源:WebSocketsTestSuite.java

示例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();
}
 
開發者ID:spharris,項目名稱:pvwatts-java,代碼行數:17,代碼來源:PvWattsServer.java

示例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();
}
 
開發者ID:chonton,項目名稱:apm-client,代碼行數:16,代碼來源:HelloMain.java

示例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();
	}


}
 
開發者ID:opendaylight,項目名稱:fpc,代碼行數:43,代碼來源:JettyServer.java

示例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();
}
 
開發者ID:yahoo,項目名稱:metrics-api,代碼行數:16,代碼來源:EmbeddedMetricsToy.java

示例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();
	}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:40,代碼來源:EmbeddedJettyInstance.java

示例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();
	}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:41,代碼來源:EmbeddedJettyTester.java

示例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();
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:10,代碼來源:ClientTestSuite.java

示例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();
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:10,代碼來源:IntegrationTests.java

示例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;
}
 
開發者ID:Nike-Inc,項目名稱:backstopper,代碼行數:9,代碼來源:Main.java

示例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;
}
 
開發者ID:Nike-Inc,項目名稱:wingtips,代碼行數:14,代碼來源:Main.java

示例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;
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:14,代碼來源:TestServerUtil.java

示例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;
}
 
開發者ID:flowable,項目名稱:flowable-engine,代碼行數:14,代碼來源:BaseJPARestTestCase.java


注:本文中的org.eclipse.jetty.servlet.ServletContextHandler.addEventListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。