本文整理汇总了Java中org.apache.catalina.Context.getManager方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getManager方法的具体用法?Java Context.getManager怎么用?Java Context.getManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Context
的用法示例。
在下文中一共展示了Context.getManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doImminentSessionTimeout
import org.apache.catalina.Context; //导入方法依赖的package包/类
private void doImminentSessionTimeout(Context activeContext) {
ManagerBase manager = (ManagerBase) activeContext.getManager();
Session[] sessions = manager.findSessions();
for (int i = 0; i < sessions.length; i++) {
if (sessions[i]!=null && sessions[i].isValid()) {
sessions[i].setMaxInactiveInterval(EXTRA_DELAY_SECS);
// leave it to be expired by the manager
}
}
try {
Thread.sleep(REASONABLE_MSECS_TO_EXPIRY);
} catch (InterruptedException ie) {
// ignored
}
// paranoid verification that active sessions have now gone
sessions = manager.findSessions();
assertTrue(sessions.length == 0);
}
示例2: invoke
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Log the interesting request parameters, invoke the next Valve in the
* sequence, and log the interesting response parameters.
*
* @param request The servlet request to be processed
* @param response The servlet response to be created
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet error occurs
*/
@Override
public void invoke(Request request, Response response)
throws IOException, ServletException
{
long totalstart = 0;
//this happens before the request
if(doStatistics()) {
totalstart = System.currentTimeMillis();
}
if (primaryIndicator) {
createPrimaryIndicator(request) ;
}
Context context = request.getContext();
boolean isCrossContext = context != null
&& context instanceof StandardContext
&& ((StandardContext) context).getCrossContext();
try {
if(isCrossContext) {
if(log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.add"));
//FIXME add Pool of Arraylists
crossContextSessions.set(new ArrayList<DeltaSession>());
}
getNext().invoke(request, response);
if(context != null && cluster != null
&& context.getManager() instanceof ClusterManager) {
ClusterManager clusterManager = (ClusterManager) context.getManager();
// valve cluster can access manager - other cluster handle replication
// at host level - hopefully!
if(cluster.getManager(clusterManager.getName()) == null)
return ;
if(cluster.hasMembers()) {
sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster);
} else {
resetReplicationRequest(request,isCrossContext);
}
}
} finally {
// Array must be remove: Current master request send endAccess at recycle.
// Don't register this request session again!
if(isCrossContext) {
if(log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.remove"));
// crossContextSessions.remove() only exist at Java 5
// register ArrayList at a pool
crossContextSessions.set(null);
}
}
}
示例3: getSessionsForName
import org.apache.catalina.Context; //导入方法依赖的package包/类
protected List<Session> getSessionsForName(ContextName cn,
StringManager smClient) {
if ((cn == null) || !(cn.getPath().startsWith("/") ||
cn.getPath().equals(""))) {
String path = null;
if (cn != null) {
path = cn.getPath();
}
throw new IllegalArgumentException(smClient.getString(
"managerServlet.invalidPath",
RequestUtil.filter(path)));
}
Context ctxt = (Context) host.findChild(cn.getName());
if (null == ctxt) {
throw new IllegalArgumentException(smClient.getString(
"managerServlet.noContext",
RequestUtil.filter(cn.getDisplayName())));
}
Manager manager = ctxt.getManager();
List<Session> sessions = new ArrayList<Session>();
sessions.addAll(Arrays.asList(manager.findSessions()));
if (manager instanceof DistributedManager && showProxySessions) {
// Add dummy proxy sessions
Set<String> sessionIds =
((DistributedManager) manager).getSessionIdsFull();
// Remove active (primary and backup) session IDs from full list
for (Session session : sessions) {
sessionIds.remove(session.getId());
}
// Left with just proxy sessions - add them
for (String sessionId : sessionIds) {
sessions.add(new DummyProxySession(sessionId));
}
}
return sessions;
}
示例4: expire
import org.apache.catalina.Context; //导入方法依赖的package包/类
private void expire(SingleSignOnSessionKey key) {
if (engine == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key));
return;
}
Container host = engine.findChild(key.getHostName());
if (host == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key));
return;
}
Context context = (Context) host.findChild(key.getContextName());
if (context == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key));
return;
}
Manager manager = context.getManager();
if (manager == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key));
return;
}
Session session = null;
try {
session = manager.findSession(key.getSessionId());
} catch (IOException e) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e);
return;
}
if (session == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.sessionNotFound", key));
return;
}
session.expire();
}
示例5: invoke
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Log the interesting request parameters, invoke the next Valve in the
* sequence, and log the interesting response parameters.
*
* @param request
* The servlet request to be processed
* @param response
* The servlet response to be created
*
* @exception IOException
* if an input/output error occurs
* @exception ServletException
* if a servlet error occurs
*/
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
long totalstart = 0;
// this happens before the request
if (doStatistics()) {
totalstart = System.currentTimeMillis();
}
if (primaryIndicator) {
createPrimaryIndicator(request);
}
Context context = request.getContext();
boolean isCrossContext = context != null && context instanceof StandardContext
&& ((StandardContext) context).getCrossContext();
try {
if (isCrossContext) {
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.add"));
// FIXME add Pool of Arraylists
crossContextSessions.set(new ArrayList<DeltaSession>());
}
getNext().invoke(request, response);
if (context != null && cluster != null && context.getManager() instanceof ClusterManager) {
ClusterManager clusterManager = (ClusterManager) context.getManager();
// valve cluster can access manager - other cluster handle
// replication
// at host level - hopefully!
if (cluster.getManager(clusterManager.getName()) == null)
return;
if (cluster.hasMembers()) {
sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster);
} else {
resetReplicationRequest(request, isCrossContext);
}
}
} finally {
// Array must be remove: Current master request send endAccess at
// recycle.
// Don't register this request session again!
if (isCrossContext) {
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.remove"));
// crossContextSessions.remove() only exist at Java 5
// register ArrayList at a pool
crossContextSessions.set(null);
}
}
}
示例6: getSessionsForName
import org.apache.catalina.Context; //导入方法依赖的package包/类
protected List<Session> getSessionsForName(ContextName cn, StringManager smClient) {
if ((cn == null) || !(cn.getPath().startsWith("/") || cn.getPath().equals(""))) {
String path = null;
if (cn != null) {
path = cn.getPath();
}
throw new IllegalArgumentException(
smClient.getString("managerServlet.invalidPath", RequestUtil.filter(path)));
}
Context ctxt = (Context) host.findChild(cn.getName());
if (null == ctxt) {
throw new IllegalArgumentException(
smClient.getString("managerServlet.noContext", RequestUtil.filter(cn.getDisplayName())));
}
Manager manager = ctxt.getManager();
List<Session> sessions = new ArrayList<Session>();
sessions.addAll(Arrays.asList(manager.findSessions()));
if (manager instanceof DistributedManager && showProxySessions) {
// Add dummy proxy sessions
Set<String> sessionIds = ((DistributedManager) manager).getSessionIdsFull();
// Remove active (primary and backup) session IDs from full list
for (Session session : sessions) {
sessionIds.remove(session.getId());
}
// Left with just proxy sessions - add them
for (String sessionId : sessionIds) {
sessions.add(new DummyProxySession(sessionId));
}
}
return sessions;
}
示例7: expire
import org.apache.catalina.Context; //导入方法依赖的package包/类
private void expire(SingleSignOnSessionKey key) {
if (engine == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.engineNull", key));
return;
}
Container host = engine.findChild(key.getHostName());
if (host == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.hostNotFound", key));
return;
}
Context context = (Context) host.findChild(key.getContextName());
if (context == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.contextNotFound", key));
return;
}
Manager manager = context.getManager();
if (manager == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerNotFound", key));
return;
}
Session session = null;
try {
session = manager.findSession(key.getSessionId());
} catch (IOException e) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.managerError", key), e);
return;
}
if (session == null) {
containerLog.warn(sm.getString("singleSignOn.sessionExpire.sessionNotFound", key));
return;
}
session.expire();
}
示例8: checkUndeploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Check for old versions of applications using parallel deployment that are
* now unused (have no active sessions) and undeploy any that are found.
*/
public synchronized void checkUndeploy() {
// Need ordered set of names
SortedSet<String> sortedAppNames = new TreeSet<String>();
sortedAppNames.addAll(deployed.keySet());
if (sortedAppNames.size() < 2) {
return;
}
Iterator<String> iter = sortedAppNames.iterator();
ContextName previous = new ContextName(iter.next(), false);
do {
ContextName current = new ContextName(iter.next(), false);
if (current.getPath().equals(previous.getPath())) {
// Current and previous are same path - current will always
// be a later version
Context previousContext = (Context) host.findChild(previous.getName());
Context currentContext = (Context) host.findChild(current.getName());
if (previousContext != null && currentContext != null &&
currentContext.getState().isAvailable() &&
!isServiced(previous.getName())) {
Manager manager = previousContext.getManager();
if (manager != null) {
int sessionCount;
if (manager instanceof DistributedManager) {
sessionCount = ((DistributedManager) manager).getActiveSessionsFull();
} else {
sessionCount = manager.getActiveSessions();
}
if (sessionCount == 0) {
if (log.isInfoEnabled()) {
log.info(sm.getString(
"hostConfig.undeployVersion", previous.getName()));
}
DeployedApplication app = deployed.get(previous.getName());
String[] resources = app.redeployResources.keySet().toArray(new String[0]);
// Version is unused - undeploy it completely
// The -1 is a 'trick' to ensure all redeploy
// resources are removed
undeploy(app);
deleteRedeployResources(app, resources, -1, true);
}
}
}
}
previous = current;
} while (iter.hasNext());
}
示例9: createMBeans
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Create the MBeans for the specified Context and its nested components.
*
* @param context Context for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Context context) throws Exception {
// Create the MBean for the Context itself
// if (log.isDebugEnabled())
// log.debug("Creating MBean for Context " + context);
// MBeanUtils.createMBean(context);
context.addContainerListener(this);
if (context instanceof StandardContext) {
((StandardContext) context).addPropertyChangeListener(this);
((StandardContext) context).addLifecycleListener(this);
}
// If the context is privileged, give a reference to it
// in a servlet context attribute
if (context.getPrivileged()) {
context.getServletContext().setAttribute
(Globals.MBEAN_REGISTRY_ATTR,
MBeanUtils.createRegistry());
context.getServletContext().setAttribute
(Globals.MBEAN_SERVER_ATTR,
MBeanUtils.createServer());
}
// Create the MBeans for the associated nested components
Loader cLoader = context.getLoader();
if (cLoader != null) {
if (log.isDebugEnabled())
log.debug("Creating MBean for Loader " + cLoader);
//MBeanUtils.createMBean(cLoader);
}
Manager cManager = context.getManager();
if (cManager != null) {
if (log.isDebugEnabled())
log.debug("Creating MBean for Manager " + cManager);
//MBeanUtils.createMBean(cManager);
}
Realm hRealm = context.getParent().getRealm();
Realm cRealm = context.getRealm();
if ((cRealm != null) && (cRealm != hRealm)) {
if (log.isDebugEnabled())
log.debug("Creating MBean for Realm " + cRealm);
//MBeanUtils.createMBean(cRealm);
}
// Create the MBeans for the NamingResources (if any)
NamingResources resources = context.getNamingResources();
createMBeans(resources);
}
示例10: destroyMBeans
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deregister the MBeans for the specified Context and its nested
* components.
*
* @param context Context for which to deregister MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Context context) throws Exception {
// Deregister ourselves as a ContainerListener
context.removeContainerListener(this);
// Destroy the MBeans for the associated nested components
Realm hRealm = context.getParent().getRealm();
Realm cRealm = context.getRealm();
if ((cRealm != null) && (cRealm != hRealm)) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Realm " + cRealm);
//MBeanUtils.destroyMBean(cRealm);
}
Manager cManager = context.getManager();
if (cManager != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Manager " + cManager);
//MBeanUtils.destroyMBean(cManager);
}
Loader cLoader = context.getLoader();
if (cLoader != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Loader " + cLoader);
//MBeanUtils.destroyMBean(cLoader);
}
// Destroy the MBeans for the NamingResources (if any)
NamingResources resources = context.getNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// deregister the MBean for the Context itself
if (log.isDebugEnabled())
log.debug("Destroying MBean for Context " + context);
//MBeanUtils.destroyMBean(context);
if (context instanceof StandardContext) {
((StandardContext) context).
removePropertyChangeListener(this);
}
}
示例11: createMBeans
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Create the MBeans for the specified Context and its nested components.
*
* @param context Context for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Context context) throws Exception {
// Create the MBean for the Context itself
if (debug >= 4)
log("Creating MBean for Context " + context);
MBeanUtils.createMBean(context);
context.addContainerListener(this);
if (context instanceof StandardContext) {
((StandardContext) context).addPropertyChangeListener(this);
((StandardContext) context).addLifecycleListener(this);
}
// If the context is privileged, give a reference to it
// in a servlet context attribute
if (context.getPrivileged()) {
context.getServletContext().setAttribute
(Globals.MBEAN_REGISTRY_ATTR,
MBeanUtils.createRegistry());
context.getServletContext().setAttribute
(Globals.MBEAN_SERVER_ATTR,
MBeanUtils.createServer());
}
// Create the MBeans for the associated nested components
Loader cLoader = context.getLoader();
if (cLoader != null) {
if (debug >= 4)
log("Creating MBean for Loader " + cLoader);
MBeanUtils.createMBean(cLoader);
}
Logger hLogger = context.getParent().getLogger();
Logger cLogger = context.getLogger();
if ((cLogger != null) && (cLogger != hLogger)) {
if (debug >= 4)
log("Creating MBean for Logger " + cLogger);
MBeanUtils.createMBean(cLogger);
}
Manager cManager = context.getManager();
if (cManager != null) {
if (debug >= 4)
log("Creating MBean for Manager " + cManager);
MBeanUtils.createMBean(cManager);
}
Realm hRealm = context.getParent().getRealm();
Realm cRealm = context.getRealm();
if ((cRealm != null) && (cRealm != hRealm)) {
if (debug >= 4)
log("Creating MBean for Realm " + cRealm);
MBeanUtils.createMBean(cRealm);
}
// Create the MBeans for the associated Valves
if (context instanceof StandardContext) {
Valve cValves[] = ((StandardContext)context).getValves();
for (int l = 0; l < cValves.length; l++) {
if (debug >= 4)
log("Creating MBean for Valve " + cValves[l]);
MBeanUtils.createMBean(cValves[l]);
}
}
// Create the MBeans for the NamingResources (if any)
NamingResources resources = context.getNamingResources();
createMBeans(resources);
}
示例12: destroyMBeans
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Deregister the MBeans for the specified Context and its nested
* components.
*
* @param context Context for which to deregister MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Context context) throws Exception {
// Deregister ourselves as a ContainerListener
context.removeContainerListener(this);
// destroy the MBeans for the associated Valves
if (context instanceof StandardContext) {
Valve cValves[] = ((StandardContext)context).getValves();
for (int l = 0; l < cValves.length; l++) {
if (debug >= 4)
log("Destroying MBean for Valve " + cValves[l]);
MBeanUtils.destroyMBean(cValves[l], context);
}
}
// Destroy the MBeans for the associated nested components
Realm hRealm = context.getParent().getRealm();
Realm cRealm = context.getRealm();
if ((cRealm != null) && (cRealm != hRealm)) {
if (debug >= 4)
log("Destroying MBean for Realm " + cRealm);
MBeanUtils.destroyMBean(cRealm);
}
Manager cManager = context.getManager();
if (cManager != null) {
if (debug >= 4)
log("Destroying MBean for Manager " + cManager);
MBeanUtils.destroyMBean(cManager);
}
Logger hLogger = context.getParent().getLogger();
Logger cLogger = context.getLogger();
if ((cLogger != null) && (cLogger != hLogger)) {
if (debug >= 4)
log("Destroying MBean for Logger " + cLogger);
MBeanUtils.destroyMBean(cLogger);
}
Loader cLoader = context.getLoader();
if (cLoader != null) {
if (debug >= 4)
log("Destroying MBean for Loader " + cLoader);
MBeanUtils.destroyMBean(cLoader);
}
// Destroy the MBeans for the NamingResources (if any)
NamingResources resources = context.getNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// deregister the MBean for the Context itself
if (debug >= 4)
log("Destroying MBean for Context " + context);
MBeanUtils.destroyMBean(context);
if (context instanceof StandardContext) {
((StandardContext) context).
removePropertyChangeListener(this);
}
}
示例13: invoke
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Select the appropriate child Context to process this request,
* based on the specified request URI. If no matching Context can
* be found, return an appropriate HTTP error.
*
* @param request Request to be processed
* @param response Response to be produced
* @param valveContext Valve context used to forward to the next Valve
*
* @exception IOException if an input/output error occurred
* @exception ServletException if a servlet error occurred
*/
public void invoke(Request request, Response response,
ValveContext valveContext)
throws IOException, ServletException {
// Validate the request and response object types
if (!(request.getRequest() instanceof HttpServletRequest) ||
!(response.getResponse() instanceof HttpServletResponse)) {
return; // NOTE - Not much else we can do generically
}
// Select the Context to be used for this Request
StandardHost host = (StandardHost) getContainer();
Context context = (Context) host.map(request, true);
if (context == null) {
((HttpServletResponse) response.getResponse()).sendError
(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
sm.getString("standardHost.noContext"));
return;
}
// Bind the context CL to the current thread
Thread.currentThread().setContextClassLoader
(context.getLoader().getClassLoader());
// Update the session last access time for our session (if any)
HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
String sessionId = hreq.getRequestedSessionId();
if (sessionId != null) {
Manager manager = context.getManager();
if (manager != null) {
Session session = manager.findSession(sessionId);
if ((session != null) && session.isValid())
session.access();
}
}
// Ask this Context to process this request
context.invoke(request, response);
}
示例14: checkUndeploy
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Check for old versions of applications using parallel deployment that are
* now unused (have no active sessions) and undeploy any that are found.
*/
public synchronized void checkUndeploy() {
// Need ordered set of names
SortedSet<String> sortedAppNames = new TreeSet<String>();
sortedAppNames.addAll(deployed.keySet());
if (sortedAppNames.size() < 2) {
return;
}
Iterator<String> iter = sortedAppNames.iterator();
ContextName previous = new ContextName(iter.next(), false);
do {
ContextName current = new ContextName(iter.next(), false);
if (current.getPath().equals(previous.getPath())) {
// Current and previous are same path - current will always
// be a later version
Context previousContext = (Context) host.findChild(previous.getName());
Context currentContext = (Context) host.findChild(current.getName());
if (previousContext != null && currentContext != null && currentContext.getState().isAvailable()
&& !isServiced(previous.getName())) {
Manager manager = previousContext.getManager();
if (manager != null) {
int sessionCount;
if (manager instanceof DistributedManager) {
sessionCount = ((DistributedManager) manager).getActiveSessionsFull();
} else {
sessionCount = manager.getActiveSessions();
}
if (sessionCount == 0) {
if (log.isInfoEnabled()) {
log.info(sm.getString("hostConfig.undeployVersion", previous.getName()));
}
DeployedApplication app = deployed.get(previous.getName());
String[] resources = app.redeployResources.keySet().toArray(new String[0]);
// Version is unused - undeploy it completely
// The -1 is a 'trick' to ensure all redeploy
// resources are removed
undeploy(app);
deleteRedeployResources(app, resources, -1, true);
}
}
}
}
previous = current;
} while (iter.hasNext());
}