org.glassfish.grizzly.servlet.WebappContext.addListener()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中org.glassfish.grizzly.servlet.WebappContext.addListener()方法的一些代码示例,展示了WebappContext.addListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebappContext.addListener()方法的具体详情如下:
包路径:org.glassfish.grizzly.servlet.WebappContext
类名称:WebappContext
方法名:addListener

WebappContext.addListener介绍

[英]Adds the given listener class to this WebappContext.

The given listener must be an instance of one or more of the following interfaces:

  • ServletContextAttributeListener
  • javax.servlet.ServletRequestListener
  • javax.servlet.ServletRequestAttributeListener
  • javax.servlet.http.HttpSessionListener
  • javax.servlet.http.HttpSessionAttributeListener

If the given listener is an instance of a listener interface whose invocation order corresponds to the declaration order (i.e., if it is an instance of javax.servlet.ServletRequestListener, ServletContextListener, or javax.servlet.http.HttpSessionListener), then the listener will be added to the end of the ordered list of listeners of that interface.
[中]将给定的侦听器类添加到此WebappContext。
给定的侦听器必须是以下一个或多个接口的实例:
*ServletContextAttributeListener
*javax。servlet。ServletRequestListener
*javax。servlet。ServletRequestAttributeListener
*javax。servlet。http。HttpSessionListener
*javax。servlet。http。HttpSessionAttributeListener
如果给定的侦听器是其调用顺序与声明顺序对应的侦听器接口的实例(即,如果它是javax.servlet.ServletRequestListener、ServletContextListener或javax.servlet.http.HttpSessionListener的实例),然后,侦听器将被添加到该接口的侦听器有序列表的末尾。

代码示例

代码示例来源:origin: jersey/jersey

context.addListener(eventListener);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(listenerClass));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: stackoverflow.com

private static HttpServer create(URI u, Servlet servlet) throws IOException {

  String path = u.getPath();
  path = String.format("/%s", UriComponent.decodePath(u.getPath(), true)
         .get(1).toString());

  WebappContext context = new WebappContext("GrizzlyContext", path);
  context.addListener(MyListener.class);
  ServletRegistration registration;
  registration = context.addServlet(servlet.getClass().getName(), servlet);
  registration.addMapping("/*");

  HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u);
  context.deploy(server);
  return server;
}

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: javaee/grizzly

addListener(createEventListenerInstance(className));
} catch (Exception e) {
  throw new IllegalStateException(e);

代码示例来源:origin: stackoverflow.com

@Before
public void setUp() throws Exception {
  if (server == null) {
    System.out.println("Initializing an instance of Grizzly Container");
    final ResourceConfig rc = new ResourceConfig(A.class, B.class);

    WebappContext ctx = new WebappContext() {};
    ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml");

    ctx.addListener("com.package.something.AServletContextListener");

    server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
      ctx.deploy(server);
    }
  }

代码示例来源:origin: stackoverflow.com

@Before
 public void setup() throws Exception {
   if (server == null) {
     System.out.println("Initializing an instance of Grizzly Container ...");
     final ResourceConfig rc = new ResourceConfig(ResourceEndpointIntegrationTest.class, ..., ..., ...); //update
     WebappContext ctx = new WebappContext("IntegrationTestContext");
           //register your listeners from web.xml in here
     ctx.addListener("com.xxx.yyy.XEndpointServletContextListener");
           //register your applicationContext.xml here
     ctx.addContextInitParameter("contextConfigLocation", "classpath:applicationContext.xml");
           //ServletRegistration is needed to load the ResourceConfig rc inside ServletContainer or you will have no 
           //Servlet-based features available 
     ServletRegistration registration = ctx.addServlet("ServletContainer",
         new ServletContainer(rc));
           //Initialize the Grizzly server passing it base URL
     server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI));
           //Deploy the server using our custom context
     ctx.deploy(server);
   }
 }

代码示例来源:origin: stackoverflow.com

reg.addMapping("/*");
ctx.addContextInitParameter("contextConfigLocation", "classpath:spring-context.xml");
ctx.addListener("org.springframework.web.context.ContextLoaderListener");
ctx.addListener("org.springframework.web.context.request.RequestContextListener");
ctx.deploy(server);

代码示例来源:origin: com.sun.jersey.jersey-test-framework/jersey-test-framework-grizzly2

context.addListener(eventListener);

代码示例来源:origin: org.glassfish.jersey.test-framework.providers/jersey-test-framework-provider-grizzly2

context.addListener(eventListener);

相关文章

WebappContext类方法