本文整理匯總了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);
}
}