本文整理了Java中org.apache.catalina.Container
类的一些代码示例,展示了Container
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Container
类的具体详情如下:
包路径:org.apache.catalina.Container
类名称:Container
[英]A Container is an object that can execute requests received from a client, and return responses based on those requests. A Container may optionally support a pipeline of Valves that process the request in an order configured at runtime, by implementing the Pipeline interface as well.
Containers will exist at several conceptual levels within Catalina. The following examples represent common cases:
A Container may also be associated with a number of support components that provide functionality which might be shared (by attaching it to a parent Container) or individually customized. The following support components are currently recognized:
log()
method signatures of the ServletContext
interface.ServletContext
接口的log()
方法签名。代码示例来源:origin: magro/memcached-session-manager
protected MemcachedNodesManager createMemcachedNodesManager(final String memcachedNodes, final String failoverNodes) {
final Context context = _manager.getContext();
final String webappVersion = Reflections.invoke(context, "getWebappVersion", null);
final StorageKeyFormat storageKeyFormat = StorageKeyFormat.of(_storageKeyPrefix, context.getParent().getName(), context.getName(), webappVersion);
return MemcachedNodesManager.createFor( memcachedNodes, failoverNodes, storageKeyFormat, _storageClientCallback);
}
代码示例来源:origin: psi-probe/psi-probe
@Override
public String getConfigBase() {
File configBase = new File(System.getProperty("catalina.base"), "conf");
Container baseHost = null;
Container thisContainer = host;
while (thisContainer != null) {
if (thisContainer instanceof Host) {
baseHost = thisContainer;
}
thisContainer = thisContainer.getParent();
}
if (baseHost != null) {
configBase = new File(configBase, baseHost.getName());
}
return configBase.getAbsolutePath();
}
代码示例来源:origin: magro/memcached-session-manager
public void shutdown() {
_log.info( "Stopping services." );
_manager.getContext().getParent().getPipeline().removeValve(_trackingHostValve);
_manager.getContext().getPipeline().removeValve(_trackingContextValve);
_backupSessionService.shutdown();
if ( _lockingStrategy != null ) {
_lockingStrategy.shutdown();
}
if ( _storage != null ) {
_storage.shutdown();
_storage = null;
}
_transcoderFactory = null;
_invalidSessionsCache.clear();
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
/**
* Unregister context.
*/
private void unregisterContext(Context context) {
// Don't un-map a context that is paused
if (context.getPaused()){
return;
}
String contextPath = context.getPath();
if ("/".equals(contextPath)) {
contextPath = "";
}
String hostName = context.getParent().getName();
if(log.isDebugEnabled())
log.debug(sm.getString("mapperListener.unregisterContext",
contextPath, connector));
mapper.removeContextVersion(hostName, contextPath,
context.getWebappVersion());
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
ErrorPage errorPage) {
if (container.getLogger().isDebugEnabled()) {
container.getLogger().debug("Processing " + errorPage);
request.getContext().getServletContext();
RequestDispatcher rd =
servletContext.getRequestDispatcher(errorPage.getLocation());
container.getLogger().error(
sm.getString("standardHostValue.customStatusFailed", errorPage.getLocation()));
return false;
rd.include(request.getRequest(), response.getResponse());
} else {
response.setContentLength(-1);
rd.forward(request.getRequest(), response.getResponse());
ExceptionUtils.handleThrowable(t);
container.getLogger().error("Exception Processing " + errorPage, t);
return false;
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
/**
* Perform the internal processing required to passivate
* this session.
*/
public void passivate() {
// Notify interested session event listeners
fireSessionEvent(Session.SESSION_PASSIVATED_EVENT, null);
// Notify ActivationListeners
HttpSessionEvent event = null;
String keys[] = keys();
for (int i = 0; i < keys.length; i++) {
Object attribute = attributes.get(keys[i]);
if (attribute instanceof HttpSessionActivationListener) {
if (event == null)
event = new HttpSessionEvent(getSession());
try {
((HttpSessionActivationListener)attribute)
.sessionWillPassivate(event);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
manager.getContainer().getLogger().error
(sm.getString("standardSession.attributeEvent"), t);
}
}
}
}
代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina
@Override
public void sessionDestroyed(HttpSessionEvent se) {
// Close all Comet connections associated with this session
Request[] reqs = (Request[])
se.getSession().getAttribute(cometRequestsAttribute);
if (reqs != null) {
for (int i = 0; i < reqs.length; i++) {
Request req = reqs[i];
try {
CometEventImpl event = req.getEvent();
event.setEventType(CometEvent.EventType.END);
event.setEventSubType(CometEvent.EventSubType.SESSION_END);
((CometProcessor)
req.getWrapper().getServlet()).event(event);
event.close();
} catch (Exception e) {
req.getWrapper().getParent().getLogger().warn(sm.getString(
"cometConnectionManagerValve.listenerEvent"), e);
}
}
}
}
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Unregister wrapper.
*/
private void unregisterWrapper(Wrapper wrapper) {
String contextPath = ((Context) wrapper.getParent()).getPath();
String wrapperName = wrapper.getName();
if ("/".equals(contextPath)) {
contextPath = "";
}
String version = ((Context) wrapper.getParent()).getWebappVersion();
String hostName = wrapper.getParent().getParent().getName();
String[] mappings = wrapper.findMappings();
for (String mapping : mappings) {
mapper.removeWrapper(hostName, contextPath, version, mapping);
}
if(log.isDebugEnabled()) {
log.debug(sm.getString("mapperListener.unregisterWrapper",
wrapperName, contextPath, service));
}
}
代码示例来源:origin: org.apache.openejb/openejb-tomcat-catalina
public void clearWsContainer(String virtualHost, String contextRoot, String servletName) {
if (virtualHost == null) virtualHost = engine.getDefaultHost();
Container host = engine.findChild(virtualHost);
if (host == null) {
throw new IllegalArgumentException("Invalid virtual host '" + virtualHost + "'. Do you have a matchiing Host entry in the server.xml?");
}
Context context = (Context) host.findChild("/" + contextRoot);
if (context == null) {
throw new IllegalArgumentException("Could not find web application context " + contextRoot + " in host " + host.getName());
}
Wrapper wrapper = (Wrapper) context.findChild(servletName);
if (wrapper == null) {
throw new IllegalArgumentException("Could not find servlet " + contextRoot + " in web application context " + context.getName());
}
// clear the webservice ref in the servlet context
String webServicecontainerId = wrapper.findInitParameter(WsServlet.WEBSERVICE_CONTAINER);
if (webServicecontainerId != null) {
context.getServletContext().removeAttribute(webServicecontainerId);
wrapper.removeInitParameter(WsServlet.WEBSERVICE_CONTAINER);
}
}
代码示例来源:origin: org.mobicents.arquillian.container/mss-tomcat-embedded-6
@Override
public synchronized void removeContext(Context context) {
if( log.isDebugEnabled() )
log.debug("Removing context[" + context.getPath() + "]");
boolean isContextExists = isContextExists(context);
if(!isContextExists)
return;
// Remove this Context from the associated Host
if( log.isDebugEnabled() )
log.debug(" Removing this Context");
context.getParent().removeChild(context);
}
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina-ha
/**
* Reset DeltaRequest from session
* @param session HttpSession from current request or cross context session
*/
protected void resetDeltaRequest(Session session) {
if(log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.resetDeltaRequest" ,
session.getManager().getContainer().getName() ));
}
((DeltaSession)session).resetDeltaRequest();
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
protected void processChildren(Container container) {
ClassLoader originalClassLoader = null;
try {
if (container instanceof Context) {
Loader loader = ((Context) container).getLoader();
// Loader will be null for FailedContext instances
if (loader == null) {
return;
}
// Ensure background processing for Contexts and Wrappers
// is performed under the web app's class loader
originalClassLoader = ((Context) container).bind(false, null);
}
container.backgroundProcess();
Container[] children = container.findChildren();
for (int i = 0; i < children.length; i++) {
if (children[i].getBackgroundProcessorDelay() <= 0) {
processChildren(children[i]);
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("containerBase.backgroundProcess.error"), t);
} finally {
if (container instanceof Context) {
((Context) container).unbind(false, originalClassLoader);
}
}
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
/**
* Close the specified database connection.
*/
protected void close() {
// Do nothing if the database connection is already closed
if (conn == null) {
return;
}
// Close our prepared statements (if any)
try {
ps.close();
} catch (Throwable f) {
ExceptionUtils.handleThrowable(f);
}
this.ps = null;
// Close this database connection, and log any errors
try {
conn.close();
} catch (SQLException e) {
container.getLogger().error(sm.getString("jdbcAccessLogValve.close"), e); // Just log it here
} finally {
this.conn = null;
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
public SingleSignOnSessionKey(Session session) {
this.sessionId = session.getId();
Context context = session.getManager().getContext();
this.contextName = context.getName();
this.hostName = context.getParent().getName();
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
@Override
public void lifecycleEvent(LifecycleEvent event) {
if (Lifecycle.BEFORE_STOP_EVENT.equals(event.getType())) {
// The container is getting stopped, close all current connections
Iterator<Request> iterator = cometRequests.iterator();
while (iterator.hasNext()) {
Request request = iterator.next();
// Remove the session tracking attribute as it isn't
// serializable or required.
HttpSession session = request.getSession(false);
if (session != null) {
session.removeAttribute(cometRequestsAttribute);
}
// Close the comet connection
try {
CometEventImpl cometEvent = request.getEvent();
cometEvent.setEventType(CometEvent.EventType.END);
cometEvent.setEventSubType(
CometEvent.EventSubType.WEBAPP_RELOAD);
getNext().event(request, request.getResponse(), cometEvent);
cometEvent.close();
} catch (Exception e) {
container.getLogger().warn(
sm.getString("cometConnectionManagerValve.event"),
e);
}
}
cometRequests.clear();
}
}
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina-ha
/**
* Send the changed Sessionid to all clusternodes.
*
* @see JvmRouteSessionIDBinderListener#messageReceived(
* org.apache.catalina.ha.ClusterMessage)
* @param sessionId
* current failed sessionid
* @param newSessionID
* new session id, bind to the new cluster node
*/
protected void sendSessionIDClusterBackup(Request request, String sessionId,
String newSessionID) {
CatalinaCluster c = getCluster();
if (c != null && !(getManager(request) instanceof BackupManager)) {
SessionIDMessage msg = new SessionIDMessage();
msg.setOrignalSessionID(sessionId);
msg.setBackupSessionID(newSessionID);
Context context = request.getContext();
msg.setContextName(context.getName());
msg.setHost(context.getParent().getName());
c.send(msg);
}
}
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
/**
* Set the JNDI name of a DataSource-factory to use for db access
*
* @param dataSourceName The JNDI name of the DataSource-factory
*/
public void setDataSourceName(String dataSourceName) {
if (dataSourceName == null || "".equals(dataSourceName.trim())) {
manager.getContainer().getLogger().warn(
sm.getString(getStoreName() + ".missingDataSourceName"));
return;
}
this.dataSourceName = dataSourceName;
}
代码示例来源:origin: org.glassfish.main.web/web-core
this.context = context;
if (context != null) {
this.servletContext = context.getServletContext();
Pipeline p = context.getParent().getPipeline();
if (p != null) {
hostValve = p.getBasic();
String reqEncoding = this.servletContext.getRequestCharacterEncoding();
if (reqEncoding != null) {
setCharacterEncoding(reqEncoding);
getResponse().getResponse().setCharacterEncoding(resEncoding);
initSessionTracker();
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
/**
* Attempt to load a class using the given Container's class loader. If the
* class cannot be loaded, a debug level log message will be written to the
* Container's log and null will be returned.
*/
public static Class<?> loadClass(Container container, String className) {
ClassLoader cl = container.getLoader().getClassLoader();
Log log = container.getLogger();
Class<?> clazz = null;
try {
clazz = cl.loadClass(className);
} catch (ClassNotFoundException e) {
log.debug(sm.getString("introspection.classLoadFailed"), e);
} catch (NoClassDefFoundError e) {
log.debug(sm.getString("introspection.classLoadFailed"), e);
} catch (ClassFormatError e) {
log.debug(sm.getString("introspection.classLoadFailed"), e);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.debug(sm.getString("introspection.classLoadFailed"), t);
}
return clazz;
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
@Override
public void setContainer(Container container) {
super.setContainer(container);
if (appName == null) {
appName = makeLegalForJAAS(container.getName());
log.info(sm.getString("jaasRealm.appName", appName));
}
}
内容来源于网络,如有侵权,请联系作者删除!