org.apache.catalina.Context.addApplicationListener()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(141)

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

Context.addApplicationListener介绍

[英]Add a new Listener class name to the set of Listeners configured for this application.
[中]向为此应用程序配置的侦听器集中添加新的侦听器类名。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
protected void initServer() throws Exception {
  this.tomcatServer = new Tomcat();
  this.tomcatServer.setBaseDir(baseDir);
  this.tomcatServer.setHostname(getHost());
  this.tomcatServer.setPort(getPort());
  ServletHttpHandlerAdapter servlet = initServletAdapter();
  File base = new File(System.getProperty("java.io.tmpdir"));
  Context rootContext = tomcatServer.addContext(this.contextPath, base.getAbsolutePath());
  Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet).setAsyncSupported(true);
  rootContext.addServletMappingDecoded(this.servletMapping, "httpHandlerServlet");
  if (wsListener != null) {
    rootContext.addApplicationListener(wsListener.getName());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void deployConfig(WebApplicationContext wac, Filter... filters) {
  Assert.state(this.port != -1, "setup() was never called.");
  this.context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
  this.context.addApplicationListener(WsContextListener.class.getName());
  Tomcat.addServlet(this.context, "dispatcherServlet", new DispatcherServlet(wac)).setAsyncSupported(true);
  this.context.addServletMappingDecoded("/", "dispatcherServlet");
  for (Filter filter : filters) {
    FilterDef filterDef = new FilterDef();
    filterDef.setFilterName(filter.getClass().getName());
    filterDef.setFilter(filter);
    filterDef.setAsyncSupported("true");
    this.context.addFilterDef(filterDef);
    FilterMap filterMap = new FilterMap();
    filterMap.setFilterName(filter.getClass().getName());
    filterMap.addURLPattern("/*");
    filterMap.setDispatcher("REQUEST,FORWARD,INCLUDE,ASYNC");
    this.context.addFilterMap(filterMap);
  }
}

代码示例来源:origin: OryxProject/oryx

context.addApplicationListener(ModelManagerListener.class.getName());

代码示例来源:origin: pippo-java/pippo

context.addApplicationListener(PippoServletContextListener.class.getName());
listeners.forEach(listener -> context.addApplicationListener(listener.getName()));

代码示例来源:origin: spring-projects/spring-integration

public TomcatWebSocketTestServer(Class<?>... serverConfigs) {
  this.tomcatServer = new Tomcat();
  this.tomcatServer.setPort(0);
  this.tomcatServer.setBaseDir(createTempDir());
  this.serverContext = new AnnotationConfigWebApplicationContext();
  this.serverContext.register(serverConfigs);
  Context context = this.tomcatServer.addContext("", System.getProperty("java.io.tmpdir"));
  context.addApplicationListener(WsContextListener.class.getName());
  Tomcat.addServlet(context, "dispatcherServlet", new DispatcherServlet(this.serverContext))
      .setAsyncSupported(true);
  context.addServletMappingDecoded("/", "dispatcherServlet");
}

代码示例来源:origin: org.picketlink.distribution/picketlink-jbas7

@Override
  public void registerSessionListener(Class<? extends HttpSessionListener> listener) {
    context.addApplicationListener(listener.getName());
  }
});

代码示例来源:origin: org.picketlink/picketlink-tomcat-common

@Override
  public void registerSessionListener(Class<? extends HttpSessionListener> listener) {
    context.addApplicationListener(listener.getName());
  }
});

代码示例来源:origin: org.picketlink.distribution/picketlink-jbas5

@Override
  public void registerSessionListener(Class<? extends HttpSessionListener> listener) {
    context.addApplicationListener(listener.getName());
  }
});

代码示例来源:origin: tomcat/catalina

private void processCache(File tldCache ) throws IOException {
  // read the cache and return;
  try {
    FileInputStream in=new FileInputStream(tldCache);
    ObjectInputStream ois=new ObjectInputStream( in );
    String list[]=(String [])ois.readObject();
    if( log.isDebugEnabled() )
      log.debug("Reusing tldCache " + tldCache + " " + list.length);
    for( int i=0; list!=null && i<list.length; i++ ) {
      context.addApplicationListener(list[i]);
    }
    ois.close();
  } catch( ClassNotFoundException ex ) {
    ex.printStackTrace();
  }
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-server

@Override
public void addLifecycleListener(ServletContextListenerDescriptor descriptor) {
  Context context = getContextForPath(descriptor.getContext());
  context.addApplicationListener(descriptor.getClazz().getName());
}

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

public class Main {
  public static void main(String[] args) throws ServletException, LifecycleException {
    Tomcat tomcat = new Tomcat();
    Context ctx = tomcat.addContext("/", new File("src/main/resources").getAbsolutePath());

    Tomcat.addServlet(ctx, "hello", HelloWorldServlet.class.getName());
    ctx.addServletMapping("/*", "hello");

    ctx.addApplicationListener(Listener.class.getName());

    tomcat.start();
    tomcat.getServer().await();
  }

  public static class HelloWorldServlet extends HttpServlet {
    @Inject
    private BeanManager manager;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
      resp.setContentType("text/plain");
      resp.getWriter().append("Hello from " + manager);
    }
  }
}

代码示例来源:origin: org.wso2.esb/service-samples

public void startPeopleService() throws Exception {
  final File base = createBaseDirectory();
  log.info("Using base folder: " + base.getAbsolutePath());
  final Tomcat tomcat = new Tomcat();
  tomcat.setPort(8080);
  tomcat.setBaseDir(base.getAbsolutePath());
  Context context = tomcat.addContext("/", base.getAbsolutePath());
  Tomcat.addServlet(context, "CXFServlet", new CXFServlet());
  context.addServletMapping("/rest/*", "CXFServlet");
  context.addApplicationListener(ContextLoaderListener.class.getName());
  context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
  context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
  context.addParameter("contextConfigLocation", AppConfig.class.getName());
  tomcat.start();
  tomcat.getServer().await();
}

代码示例来源:origin: org.wso2.ei/service-samples

public void startPeopleService() throws Exception {
  final File base = createBaseDirectory();
  log.info("Using base folder: " + base.getAbsolutePath());
  final Tomcat tomcat = new Tomcat();
  tomcat.setPort(8080);
  tomcat.setBaseDir(base.getAbsolutePath());
  Context context = tomcat.addContext("/", base.getAbsolutePath());
  Tomcat.addServlet(context, "CXFServlet", new CXFServlet());
  context.addServletMapping("/rest/*", "CXFServlet");
  context.addApplicationListener(ContextLoaderListener.class.getName());
  context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));
  context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
  context.addParameter("contextConfigLocation", AppConfig.class.getName());
  tomcat.start();
  tomcat.getServer().await();
}

代码示例来源:origin: org.wso2.esb/service-samples

public static void main(final String[] args) throws Exception {
  final File base = createBaseDirectory();
  log.info("Using base folder: " + base.getAbsolutePath());
  final Tomcat tomcat = new Tomcat();
  tomcat.setPort(8080);
  tomcat.setBaseDir( base.getAbsolutePath() );
  Context context = tomcat.addContext( "/", base.getAbsolutePath() );
  Tomcat.addServlet( context, "CXFServlet", new CXFServlet() );
  context.addServletMapping( "/rest/*", "CXFServlet" );
  context.addApplicationListener( ContextLoaderListener.class.getName() );
  context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) );
  context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
  context.addParameter( "contextConfigLocation", MusicConfig.class.getName() );
  tomcat.start();
  tomcat.getServer().await();
}

代码示例来源:origin: org.wso2.ei/service-samples

public static void main(final String[] args) throws Exception {
  final File base = createBaseDirectory();
  log.info("Using base folder: " + base.getAbsolutePath());
  final Tomcat tomcat = new Tomcat();
  tomcat.setPort(8080);
  tomcat.setBaseDir( base.getAbsolutePath() );
  Context context = tomcat.addContext( "/", base.getAbsolutePath() );
  Tomcat.addServlet( context, "CXFServlet", new CXFServlet() );
  context.addServletMapping( "/rest/*", "CXFServlet" );
  context.addApplicationListener( ContextLoaderListener.class.getName() );
  context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) );
  context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
  context.addParameter( "contextConfigLocation", MusicConfig.class.getName() );
  tomcat.start();
  tomcat.getServer().await();
}

代码示例来源:origin: org.apache.tomee/tomee-catalina

final ServletContainerInitializer instance = (ServletContainerInitializer) myfacesInitializer.newInstance();
  context.addServletContainerInitializer(instance, getJsfClasses(context));
  context.addApplicationListener(TOMEE_MYFACES_CONTEXT_LISTENER); // cleanup listener
} catch (final Exception | NoClassDefFoundError ignored) {

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

context.addApplicationListener(list[i]);

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

context.addApplicationListener(list[i]);

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

context.addApplicationListener(list[i]);

代码示例来源:origin: ops4j/org.ops4j.pax.exam2

private void registerBeanManager(Context appContext, String jndiObjectFactory,
  String servletListener) {
  ContextResource resource = new ContextResource();
  resource.setAuth("Container");
  resource.setName(BEAN_MANAGER_NAME);
  resource.setType(BEAN_MANAGER_TYPE);
  resource.setProperty("factory", jndiObjectFactory);
  appContext.getNamingResources().addResource(resource);
  ContextResourceEnvRef resourceRef = new ContextResourceEnvRef();
  resourceRef.setName(BEAN_MANAGER_NAME);
  resourceRef.setType(BEAN_MANAGER_TYPE);
  appContext.getNamingResources().addResourceEnvRef(resourceRef);
  appContext.addApplicationListener(servletListener);
}

相关文章

微信公众号

最新文章

更多

Context类方法