本文整理汇总了Java中org.apache.catalina.Session.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Session.setId方法的具体用法?Java Session.setId怎么用?Java Session.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Session
的用法示例。
在下文中一共展示了Session.setId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
示例2: 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));
}
}
示例3: createSession
import org.apache.catalina.Session; //导入方法依赖的package包/类
@Override
public Session createSession(String sessionId) {
if ((maxActiveSessions >= 0) &&
(getActiveSessions() >= maxActiveSessions)) {
rejectedSessions++;
throw new TooManyActiveSessionsException(
sm.getString("managerBase.createSession.ise"),
maxActiveSessions);
}
// Recycle or create a Session instance
Session session = createEmptySession();
// Initialize the properties of the new session and return it
session.setNew(true);
session.setValid(true);
session.setCreationTime(System.currentTimeMillis());
session.setMaxInactiveInterval(((Context) getContainer()).getSessionTimeout() * 60);
String id = sessionId;
if (id == null) {
id = generateSessionId();
}
session.setId(id);
sessionCounter++;
SessionTiming timing = new SessionTiming(session.getCreationTime(), 0);
synchronized (sessionCreationTiming) {
sessionCreationTiming.add(timing);
sessionCreationTiming.poll();
}
return (session);
}
示例4: changeSessionId
import org.apache.catalina.Session; //导入方法依赖的package包/类
@Override
public void changeSessionId(Session session) {
String oldId = session.getIdInternal();
session.setId(generateSessionId(), false);
String newId = session.getIdInternal();
container.fireContainerEvent(Context.CHANGE_SESSION_ID_EVENT,
new String[] {oldId, newId});
}
示例5: messageReceived
import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
* Callback from the cluster, when a message is received, The cluster will
* broadcast it invoking the messageReceived on the receiver.
*
* @param msg
* ClusterMessage - the message received from the cluster
*/
@Override
public void messageReceived(ClusterMessage msg) {
if (msg instanceof SessionIDMessage) {
SessionIDMessage sessionmsg = (SessionIDMessage) msg;
if (log.isDebugEnabled())
log.debug(sm.getString("jvmRoute.receiveMessage.sessionIDChanged", sessionmsg.getOrignalSessionID(),
sessionmsg.getBackupSessionID(), sessionmsg.getContextName()));
Container container = getCluster().getContainer();
Container host = null;
if (container instanceof Engine) {
host = container.findChild(sessionmsg.getHost());
} else {
host = container;
}
if (host != null) {
Context context = (Context) host.findChild(sessionmsg.getContextName());
if (context != null) {
try {
Session session = context.getManager().findSession(sessionmsg.getOrignalSessionID());
if (session != null) {
session.setId(sessionmsg.getBackupSessionID());
} else if (log.isInfoEnabled())
log.info(sm.getString("jvmRoute.lostSession", sessionmsg.getOrignalSessionID(),
sessionmsg.getContextName()));
} catch (IOException e) {
log.error(e);
}
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.contextNotFound", sessionmsg.getContextName(),
((StandardEngine) host.getParent()).getJvmRoute()));
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.hostNotFound", sessionmsg.getContextName()));
}
return;
}
示例6: createSession
import org.apache.catalina.Session; //导入方法依赖的package包/类
@Override
public Session createSession(String sessionId) {
if ((maxActiveSessions >= 0) && (getActiveSessions() >= maxActiveSessions)) {
rejectedSessions++;
throw new TooManyActiveSessionsException(sm.getString("managerBase.createSession.ise"), maxActiveSessions);
}
// Recycle or create a Session instance
Session session = createEmptySession();
// Initialize the properties of the new session and return it
session.setNew(true);
session.setValid(true);
session.setCreationTime(System.currentTimeMillis());
session.setMaxInactiveInterval(((Context) getContainer()).getSessionTimeout() * 60);
String id = sessionId;
if (id == null) {
id = generateSessionId();
}
session.setId(id);
sessionCounter++;
SessionTiming timing = new SessionTiming(session.getCreationTime(), 0);
synchronized (sessionCreationTiming) {
sessionCreationTiming.add(timing);
sessionCreationTiming.poll();
}
return (session);
}
示例7: changeSessionId
import org.apache.catalina.Session; //导入方法依赖的package包/类
@Override
public void changeSessionId(Session session) {
String oldId = session.getIdInternal();
session.setId(generateSessionId(), false);
String newId = session.getIdInternal();
container.fireContainerEvent(Context.CHANGE_SESSION_ID_EVENT, new String[] { oldId, newId });
}
示例8: messageReceived
import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
* Callback from the cluster, when a message is received, The cluster will
* broadcast it invoking the messageReceived on the receiver.
*
* @param msg
* ClusterMessage - the message received from the cluster
*/
@Override
public void messageReceived(ClusterMessage msg) {
if (msg instanceof SessionIDMessage) {
SessionIDMessage sessionmsg = (SessionIDMessage) msg;
if (log.isDebugEnabled())
log.debug(sm.getString(
"jvmRoute.receiveMessage.sessionIDChanged", sessionmsg
.getOrignalSessionID(), sessionmsg
.getBackupSessionID(), sessionmsg
.getContextName()));
Container container = getCluster().getContainer();
Container host = null ;
if(container instanceof Engine) {
host = container.findChild(sessionmsg.getHost());
} else {
host = container ;
}
if (host != null) {
Context context = (Context) host.findChild(sessionmsg
.getContextName());
if (context != null) {
try {
Session session = context.getManager().findSession(
sessionmsg.getOrignalSessionID());
if (session != null) {
session.setId(sessionmsg.getBackupSessionID());
} else if (log.isInfoEnabled())
log.info(sm.getString("jvmRoute.lostSession",
sessionmsg.getOrignalSessionID(),
sessionmsg.getContextName()));
} catch (IOException e) {
log.error(e);
}
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.contextNotFound",
sessionmsg.getContextName(), ((StandardEngine) host
.getParent()).getJvmRoute()));
} else if (log.isErrorEnabled())
log.error(sm.getString("jvmRoute.hostNotFound", sessionmsg.getContextName()));
}
return;
}
示例9: createSession
import org.apache.catalina.Session; //导入方法依赖的package包/类
/**
* Construct and return a new session object, based on the default
* settings specified by this Manager's properties. The session
* id specified will be used as the session id.
* If a new session cannot be created for any reason, return
* <code>null</code>.
*
* @param sessionId The session id which should be used to create the
* new session; if <code>null</code>, a new session id will be
* generated
* @exception IllegalStateException if a new session cannot be
* instantiated for any reason
*/
public Session createSession(String sessionId) {
// Recycle or create a Session instance
Session session = createEmptySession();
// Initialize the properties of the new session and return it
session.setNew(true);
session.setValid(true);
session.setCreationTime(System.currentTimeMillis());
session.setMaxInactiveInterval(this.maxInactiveInterval);
if (sessionId == null) {
sessionId = generateSessionId();
// FIXME WHy we need no duplication check?
/*
synchronized (sessions) {
while (sessions.get(sessionId) != null) { // Guarantee
// uniqueness
duplicates++;
sessionId = generateSessionId();
}
}
*/
// FIXME: Code to be used in case route replacement is needed
/*
} else {
String jvmRoute = getJvmRoute();
if (getJvmRoute() != null) {
String requestJvmRoute = null;
int index = sessionId.indexOf(".");
if (index > 0) {
requestJvmRoute = sessionId
.substring(index + 1, sessionId.length());
}
if (requestJvmRoute != null && !requestJvmRoute.equals(jvmRoute)) {
sessionId = sessionId.substring(0, index) + "." + jvmRoute;
}
}
*/
}
session.setId(sessionId);
sessionCounter++;
return (session);
}