當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。