当前位置: 首页>>代码示例>>Java>>正文


Java ServletContextEvent类代码示例

本文整理汇总了Java中javax.servlet.ServletContextEvent的典型用法代码示例。如果您正苦于以下问题:Java ServletContextEvent类的具体用法?Java ServletContextEvent怎么用?Java ServletContextEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServletContextEvent类属于javax.servlet包,在下文中一共展示了ServletContextEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {

    ServletContext ctx = sce.getServletContext();

    ServletRegistration.Dynamic sd = ctx.addServlet("DynamicServlet",
            "com.creditease.monitorframework.fat.DynamicServlet");

    sd.addMapping("/DynamicServlet");
    sd.setInitParameter("test", "test");
    sd.setLoadOnStartup(1);
    sd.setAsyncSupported(false);

    FilterRegistration.Dynamic fd = ctx.addFilter("DynamicFilter",
            "com.creditease.monitorframework.fat.filters.DynamicFilter");

    fd.addMappingForUrlPatterns(null, true, "/DynamicServlet");
    fd.setInitParameter("test2", "test2");
    fd.setAsyncSupported(false);

    ctx.addListener("com.creditease.monitorframework.fat.listeners.TestServletInitListener");
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:23,代码来源:DynamicServletInit.java

示例2: contextDestroyed

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
public void contextDestroyed(ServletContextEvent sce) {

        if (!performShutdown) {
            return;
        }

        try {
            if (scheduler != null) {
                scheduler.shutdown();
            }
        } catch (Exception e) {
            log.error("Quartz Scheduler failed to shutdown cleanly: " + e.toString());
            e.printStackTrace();
        }

        log.info("Quartz Scheduler successful shutdown.");
    }
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:18,代码来源:QuartzInitializerListener.java

示例3: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
public void contextInitialized(ServletContextEvent contextEvent) 
{
	Runnable runnable = () -> {
	    try {
	    	RoutingProfileManager.getInstance().toString();
	    }
	    catch (Exception e) {
	    	LOGGER.warn("Unable to initialize ORS.");
			e.printStackTrace();
	    } 
	};

	Thread thread = new Thread(runnable);
	thread.setName("ORS-Init");
	thread.start();
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:17,代码来源:ORSInitContextListener.java

示例4: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            TesterEchoServer.Basic.class, "/{param}").build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:TestWsServerContainer.java

示例5: addEndpointMappingToCasServlet

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
/**
 * Add endpoint mapping to cas servlet.
 *
 * @param sce the sce
 * @param mapping the mapping
 */
protected final void addEndpointMappingToCasServlet(final ServletContextEvent sce, final String mapping) {
    logger.info("Adding [{}] to {} servlet context", mapping, WebUtils.CAS_SERVLET_NAME);
    final ServletRegistration registration = getCasServletRegistration(sce);
    if (registration != null) {

        registration.addMapping(mapping);
        logger.info("Added [{}] to {} servlet context", mapping, WebUtils.CAS_SERVLET_NAME);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:16,代码来源:AbstractServletContextInitializer.java

示例6: contextDestroyed

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
public void contextDestroyed(ServletContextEvent sce) {

        if (!performShutdown) {
            return;
        }

        try {
            if (scheduler != null) {
                scheduler.shutdown(waitOnShutdown);
            }
        } catch (Exception e) {
            log.error("Quartz Scheduler failed to shutdown cleanly: " + e.toString());
            e.printStackTrace();
        }

        log.info("Quartz Scheduler successful shutdown.");
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:QuartzInitializerListener.java

示例7: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Test
public void contextInitialized() throws Exception {
    // given
    ServletContextEvent event = mock(ServletContextEvent.class);

    // when contextInitialized and access logged
    listener.contextInitialized(event);

    logger.logInfo(Log4jLogger.ACCESS_LOG,
            LogMessageIdentifier.INFO_USER_LOGIN_SUCCESS, "test-user",
            "10.140.19.9");

    // then
    final String logEntryRegEx = getInfoEntryStartRegEx()
            + ".*test-user.*logged\\sin.*\\(.*10\\.140\\.19\\.9\\).*";

    assertWrittenToLogFile(logEntryRegEx);

}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:20,代码来源:LoggerInitListenerTest.java

示例8: getServletUrlPattern

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
private static String getServletUrlPattern(final ServletContextEvent servletContextEvent) throws Exception {
    final ServletContext servletContext = servletContextEvent.getServletContext();

    ServletRegistration servletRegistration = servletContext.getServletRegistration(servletName);
    if (servletRegistration == null) {
        throw new NoSuchElementException("no servlet with name \"" + servletName + "\" is found.");
    }
    java.util.Collection<java.lang.String> mappings = servletRegistration.getMappings();
    if (mappings.size() != 1) {
        throw new NoSuchElementException("unable to identify servlet mappings for servlet with name \"" + servletName + "\".");
    }
    String mapping = (String) mappings.toArray()[0];

    //url patterns in  most cases end with '\*'. But a url-pattern with just '\' may be found for exact matches.
    if (mapping.endsWith("*"))
        mapping = mapping.substring(0, mapping.length()-1);
    return mapping;
}
 
开发者ID:EricssonResearch,项目名称:scott-eu,代码行数:19,代码来源:ServletListener.java

示例9: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute(
            Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            Bug58624ServerEndpoint.class, PATH).build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TestCloseBug58624.java

示例10: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);
    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
    try {
        sc.addEndpoint(Async.class);
        sc.addEndpoint(Basic.class);
        sc.addEndpoint(BasicLimitLow.class);
        sc.addEndpoint(BasicLimitHigh.class);
        sc.addEndpoint(RootEcho.class);
    } catch (DeploymentException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TesterEchoServer.java

示例11: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);
    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
    try {
        sc.addEndpoint(ServerEndpointConfig.Builder.create(
                ConstantTxEndpoint.class, PATH).build());
        if (TestWsWebSocketContainer.timeoutOnContainer) {
            sc.setAsyncSendTimeout(TIMEOUT_MS);
        }
    } catch (DeploymentException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestWsWebSocketContainer.java

示例12: contextInitializeServletListener

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
public static void contextInitializeServletListener(final ServletContextEvent servletContextEvent)
    {
        
        // Start of user code contextInitializeServletListener
        final ServletContext context = servletContextEvent.getServletContext();
        final String queryUri = context.getInitParameter(
                "se.ericsson.cf.scott.sandbox.store.query");
        final String updateUri = context.getInitParameter(
                "se.ericsson.cf.scott.sandbox.store.query");
//        warehouseAdaptorClient = new WarehouseAdaptorClient("http://sandbox-warehouse:8080/sandbox-warehouse/services");
//        try {
//            store = StoreFactory.sparql(queryUri, updateUri);
//            // TODO [email protected]: Remember to deactivate when switch to more persistent arch
//            store.removeAll();
//            throw new IOException("test");
//        } catch (IOException e) {
//            log.error("SPARQL Store failed to initialise with the URIs query={};update={}",
//                    new Object[]{queryUri, updateUri, e});
//        }
        // End of user code
    }
 
开发者ID:EricssonResearch,项目名称:scott-eu,代码行数:22,代码来源:TwinManager.java

示例13: getServletContextParam

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
/**
 * Returns the value of the specified servlet context initialization parameter.
 *
 * @param param          the parameter to return
 * @param sce            the <code>ServletContextEvent</code> being handled
 * @param caller         calling object, used for printing information if there is a problem
 * @param throwException if <code>true</code> then the method will throw an exception; if
 *                       <code>false</code> is supplied then it will return <code>null</code>
 * @return the value of the specified servlet context initialization parameter if found;
 *         <code>null</code> otherwise
 * @throws IllegalArgumentException if the parameter does not exist
 */
private static String getServletContextParam(String param, ServletContextEvent sce,
        Object caller, boolean throwException)
        throws IllegalArgumentException
{
    ServletContext context = sce.getServletContext();
    String value = context.getInitParameter(param);

    if (value == null && throwException)
    {
        throw new IllegalArgumentException("'" + param + "' is a required "
                + "servlet context initialization parameter for the \""
                + caller.getClass().getName() + "\" class.  Aborting.");
    }

    return value;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:ConfigurationUtil.java

示例14: contextDestroyed

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Test
public void contextDestroyed() throws Exception {
	ServletContext sc = mock(ServletContext.class);

	BrokerService broker = mock(BrokerService.class);
	doReturn(true).when(broker).isStarted();
	doReturn(true).when(broker).waitUntilStarted();

	WebBrokerInitializer i = spy(WebBrokerInitializer.class);
	doReturn(broker).when(i).createBroker(sc);

	i.contextInitialized(new ServletContextEvent(sc));
	i.contextDestroyed(new ServletContextEvent(sc));
}
 
开发者ID:Hevelian,项目名称:hevelian-activemq,代码行数:15,代码来源:WebBrokerInitializerTest.java

示例15: contextInitialized

import javax.servlet.ServletContextEvent; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);
    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
    try {
        sc.addEndpoint(Endpoint.class);
    } catch (DeploymentException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:TesterFirehoseServer.java


注:本文中的javax.servlet.ServletContextEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。