本文整理汇总了Java中org.apache.catalina.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于org.apache.catalina包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchRequest
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Does this request match the saved one (so that it must be the redirect
* we signalled after successful authentication?
*
* @param request The request to be verified
*/
protected boolean matchRequest(Request request) {
// Has a session been created?
Session session = request.getSessionInternal(false);
if (session == null)
return (false);
// Is there a saved request?
SavedRequest sreq = (SavedRequest)
session.getNote(Constants.FORM_REQUEST_NOTE);
if (sreq == null)
return (false);
// Is there a saved principal?
if (session.getNote(Constants.FORM_PRINCIPAL_NOTE) == null)
return (false);
// Does the request URI match?
String requestURI = request.getRequestURI();
if (requestURI == null)
return (false);
return (requestURI.equals(sreq.getRequestURI()));
}
示例2: sendSessionReplicationMessage
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Send Cluster Replication Request
* @param request current request
* @param manager session manager
* @param cluster replication cluster
*/
protected void sendSessionReplicationMessage(Request request,
ClusterManager manager, CatalinaCluster cluster) {
Session session = request.getSessionInternal(false);
if (session != null) {
String uri = request.getDecodedRequestURI();
// request without session change
if (!isRequestWithoutSessionChange(uri)) {
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.invoke.uri", uri));
sendMessage(session,manager,cluster);
} else
if(doStatistics())
nrOfFilterRequests++;
}
}
示例3: changeSessionID
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* change session id and send to all cluster nodes
*
* @param request current request
* @param sessionId
* original session id
* @param newSessionID
* new session id for node migration
* @param catalinaSession
* current session with original session id
*/
protected void changeSessionID(Request request, String sessionId,
String newSessionID, Session catalinaSession) {
fireLifecycleEvent("Before session migration", catalinaSession);
catalinaSession.setId(newSessionID, false);
// FIXME: Why we remove change data from other running request?
// setId also trigger resetDeltaRequest!!
if (catalinaSession instanceof DeltaSession)
((DeltaSession) catalinaSession).resetDeltaRequest();
changeRequestSessionID(request, sessionId, newSessionID);
// now sending the change to all other clusternodes!
sendSessionIDClusterBackup(request,sessionId, newSessionID);
fireLifecycleEvent("After session migration", catalinaSession);
if (log.isDebugEnabled()) {
log.debug(sm.getString("jvmRoute.changeSession", sessionId,
newSessionID));
}
}
示例4: sendCrossContextSession
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Send all changed cross context sessions to backups
*
* @param containerCluster
*/
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
List<DeltaSession> sessions = crossContextSessions.get();
if (sessions != null && sessions.size() > 0) {
for (Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext();) {
Session session = iter.next();
if (log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
session.getManager().getContainer().getName()));
sendMessage(session, (ClusterManager) session.getManager(), containerCluster);
if (doStatistics()) {
nrOfCrossContextSendRequests++;
}
}
}
}
示例5: sendCrossContextSession
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Send all changed cross context sessions to backups
* @param containerCluster
*/
protected void sendCrossContextSession(CatalinaCluster containerCluster) {
List<DeltaSession> sessions = crossContextSessions.get();
if(sessions != null && sessions.size() >0) {
for(Iterator<DeltaSession> iter = sessions.iterator(); iter.hasNext() ;) {
Session session = iter.next();
if(log.isDebugEnabled())
log.debug(sm.getString("ReplicationValve.crossContext.sendDelta",
session.getManager().getContainer().getName() ));
sendMessage(session,(ClusterManager)session.getManager(),containerCluster);
if(doStatistics()) {
nrOfCrossContextSendRequests++;
}
}
}
}
示例6: changeSessionID
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* change session id and send to all cluster nodes
*
* @param request
* current request
* @param sessionId
* original session id
* @param newSessionID
* new session id for node migration
* @param catalinaSession
* current session with original session id
*/
protected void changeSessionID(Request request, String sessionId, String newSessionID, Session catalinaSession) {
fireLifecycleEvent("Before session migration", catalinaSession);
catalinaSession.setId(newSessionID, false);
// FIXME: Why we remove change data from other running request?
// setId also trigger resetDeltaRequest!!
if (catalinaSession instanceof DeltaSession)
((DeltaSession) catalinaSession).resetDeltaRequest();
changeRequestSessionID(request, sessionId, newSessionID);
// now sending the change to all other clusternodes!
sendSessionIDClusterBackup(request, sessionId, newSessionID);
fireLifecycleEvent("After session migration", catalinaSession);
if (log.isDebugEnabled()) {
log.debug(sm.getString("jvmRoute.changeSession", sessionId, newSessionID));
}
}
示例7: unload
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Save all currently active sessions in the appropriate persistence
* mechanism, if any. If persistence is not supported, this method
* returns without doing anything.
* <p>
* Note that by default, this method is not called by the MiddleManager
* class. In order to use it, a subclass must specifically call it,
* for example in the stop() and/or processPersistenceChecks() methods.
*/
public void unload() {
if (store == null)
return;
Session sessions[] = findSessions();
int n = sessions.length;
if (n == 0)
return;
if (log.isDebugEnabled())
log.debug(sm.getString("persistentManager.unloading",
String.valueOf(n)));
for (int i = 0; i < n; i++)
try {
swapOut(sessions[i]);
} catch (IOException e) {
; // This is logged in writeSession()
}
}
示例8: removeSession
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Remove a single Session from a SingleSignOn. Called when
* a session is timed out and no longer active.
*
* @param ssoId Single sign on identifier from which to remove the session.
* @param session the session to be removed.
*/
protected void removeSession(String ssoId, Session session) {
if (containerLog.isDebugEnabled()) {
containerLog.debug(sm.getString("singleSignOn.debug.removeSession", session, ssoId));
}
// Get a reference to the SingleSignOn
SingleSignOnEntry entry = cache.get(ssoId);
if (entry == null) {
return;
}
// Remove the inactive session from SingleSignOnEntry
entry.removeSession(session);
// If there are not sessions left in the SingleSignOnEntry,
// deregister the entry.
if (entry.findSessions().size() == 0) {
deregister(ssoId);
}
}
示例9: unload
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Save all currently active sessions in the appropriate persistence
* mechanism, if any. If persistence is not supported, this method
* returns without doing anything.
* <p>
* Note that by default, this method is not called by the MiddleManager
* class. In order to use it, a subclass must specifically call it,
* for example in the stop() and/or processPersistenceChecks() methods.
*/
@Override
public void unload() {
if (store == null)
return;
Session sessions[] = findSessions();
int n = sessions.length;
if (n == 0)
return;
if (log.isDebugEnabled())
log.debug(sm.getString("persistentManager.unloading",
String.valueOf(n)));
for (int i = 0; i < n; i++)
try {
swapOut(sessions[i]);
} catch (IOException e) {
// This is logged in writeSession()
}
}
示例10: processExpires
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p>
* Direct call to processExpires and processPersistenceChecks
*/
@Override
public void processExpires() {
long timeNow = System.currentTimeMillis();
Session sessions[] = findSessions();
int expireHere = 0 ;
if(log.isDebugEnabled())
log.debug("Start expire sessions " + getName() + " at " + timeNow + " sessioncount " + sessions.length);
for (int i = 0; i < sessions.length; i++) {
if (!sessions[i].isValid()) {
expiredSessions.incrementAndGet();
expireHere++;
}
}
processPersistenceChecks();
if ((getStore() != null) && (getStore() instanceof StoreBase)) {
((StoreBase) getStore()).processExpires();
}
long timeEnd = System.currentTimeMillis();
if(log.isDebugEnabled())
log.debug("End expire sessions " + getName() + " processingTime " + (timeEnd - timeNow) + " expired sessions: " + expireHere);
processingTime += (timeEnd - timeNow);
}
示例11: expireAllLocalSessions
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Expire all find sessions.
*/
public void expireAllLocalSessions()
{
long timeNow = System.currentTimeMillis();
Session sessions[] = findSessions();
int expireDirect = 0 ;
int expireIndirect = 0 ;
if(log.isDebugEnabled()) log.debug("Start expire all sessions " + getName() + " at " + timeNow + " sessioncount " + sessions.length);
for (int i = 0; i < sessions.length; i++) {
if (sessions[i] instanceof DeltaSession) {
DeltaSession session = (DeltaSession) sessions[i];
if (session.isPrimarySession()) {
if (session.isValid()) {
session.expire();
expireDirect++;
} else {
expireIndirect++;
}//end if
}//end if
}//end if
}//for
long timeEnd = System.currentTimeMillis();
if(log.isDebugEnabled()) log.debug("End expire sessions " + getName() + " expire processingTime " + (timeEnd - timeNow) + " expired direct sessions: " + expireDirect + " expired direct sessions: " + expireIndirect);
}
示例12: stopInternal
import org.apache.catalina.Session; //导入依赖的package包/类
/**
* Stop this component and implement the requirements of
* {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
*
* This will disconnect the cluster communication channel and stop the
* listener thread.
*
* @exception LifecycleException
* if this component detects a fatal error that prevents this
* component from being used
*/
@Override
protected synchronized void stopInternal() throws LifecycleException {
if (log.isDebugEnabled())
log.debug(sm.getString("backupManager.stopped", getName()));
setState(LifecycleState.STOPPING);
if (sessions instanceof LazyReplicatedMap) {
LazyReplicatedMap<String, Session> map = (LazyReplicatedMap<String, Session>) sessions;
map.breakdown();
}
super.stopInternal();
}
示例13: remove
import org.apache.catalina.Session; //导入依赖的package包/类
@Override
public void remove(Session session, boolean update) {
// If the session has expired - as opposed to just being removed from
// the manager because it is being persisted - update the expired stats
if (update) {
long timeNow = System.currentTimeMillis();
int timeAlive =
(int) (timeNow - session.getCreationTimeInternal())/1000;
updateSessionMaxAliveTime(timeAlive);
expiredSessions.incrementAndGet();
SessionTiming timing = new SessionTiming(timeNow, timeAlive);
synchronized (sessionExpirationTiming) {
sessionExpirationTiming.add(timing);
sessionExpirationTiming.poll();
}
}
if (session.getIdInternal() != null) {
sessions.remove(session.getIdInternal());
}
}
示例14: sessionEvent
import org.apache.catalina.Session; //导入依赖的package包/类
@Override
public void sessionEvent(SessionEvent event) {
if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
return;
}
Session session = event.getSession();
Manager manager = session.getManager();
if (manager == null) {
return;
}
Context context = (Context) manager.getContainer();
Authenticator authenticator = context.getAuthenticator();
if (!(authenticator instanceof AuthenticatorBase)) {
return;
}
SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
if (sso == null) {
return;
}
sso.sessionDestroyed(ssoId, session);
}
示例15: sessionEvent
import org.apache.catalina.Session; //导入依赖的package包/类
@Override
public void sessionEvent(SessionEvent event) {
if (!Session.SESSION_DESTROYED_EVENT.equals(event.getType())) {
return;
}
Session session = event.getSession();
Manager manager = session.getManager();
if (manager == null) {
return;
}
Context context = (Context) manager.getContainer();
Authenticator authenticator = context.getAuthenticator();
if (!(authenticator instanceof AuthenticatorBase)) {
return;
}
SingleSignOn sso = ((AuthenticatorBase) authenticator).sso;
if (sso == null) {
return;
}
sso.sessionDestroyed(ssoId, session);
}