本文整理汇总了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");
}
示例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.");
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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.");
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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
}
示例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;
}
示例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));
}
示例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);
}
}