use of org.apache.catalina.Manager in project tomcat by apache.
the class ReplicationValve method createPrimaryIndicator.
/**
* Mark Request that processed at primary node with attribute
* primaryIndicatorName
*
* @param request The Servlet request
* @throws IOException IO error finding session
*/
protected void createPrimaryIndicator(Request request) throws IOException {
String id = request.getRequestedSessionId();
if ((id != null) && (id.length() > 0)) {
Manager manager = request.getContext().getManager();
Session session = manager.findSession(id);
if (session instanceof ClusterSession) {
ClusterSession cses = (ClusterSession) session;
if (log.isDebugEnabled()) {
log.debug(sm.getString("ReplicationValve.session.indicator", request.getContext().getName(), id, primaryIndicatorName, Boolean.valueOf(cses.isPrimarySession())));
}
request.setAttribute(primaryIndicatorName, cses.isPrimarySession() ? Boolean.TRUE : Boolean.FALSE);
} else {
if (log.isDebugEnabled()) {
if (session != null) {
log.debug(sm.getString("ReplicationValve.session.found", request.getContext().getName(), id));
} else {
log.debug(sm.getString("ReplicationValve.session.invalid", request.getContext().getName(), id));
}
}
}
}
}
use of org.apache.catalina.Manager in project tomcat by apache.
the class HostConfig method checkUndeploy.
/**
* 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() {
if (deployed.size() < 2) {
return;
}
// Need ordered set of names
SortedSet<String> sortedAppNames = new TreeSet<>(deployed.keySet());
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() && tryAddServiced(previous.getName())) {
try {
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);
}
}
} finally {
removeServiced(previous.getName());
}
}
}
previous = current;
} while (iter.hasNext());
}
use of org.apache.catalina.Manager in project tomcat by apache.
the class ManagerSF method storeChildren.
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aManager, StoreDescription parentDesc) throws Exception {
if (aManager instanceof Manager) {
Manager manager = (Manager) aManager;
// Store nested <SessionIdGenerator> element;
SessionIdGenerator sessionIdGenerator = manager.getSessionIdGenerator();
if (sessionIdGenerator != null) {
storeElement(aWriter, indent, sessionIdGenerator);
}
}
}
use of org.apache.catalina.Manager in project tomcat by apache.
the class Request method isRequestedSessionIdValid.
/**
* @return <code>true</code> if the session identifier included in this
* request identifies a valid session.
*/
@Override
public boolean isRequestedSessionIdValid() {
if (requestedSessionId == null) {
return false;
}
Context context = getContext();
if (context == null) {
return false;
}
Manager manager = context.getManager();
if (manager == null) {
return false;
}
Session session = null;
try {
session = manager.findSession(requestedSessionId);
} catch (IOException e) {
// Can't find the session
}
if ((session == null) || !session.isValid()) {
// Check for parallel deployment contexts
if (getMappingData().contexts == null) {
return false;
} else {
for (int i = (getMappingData().contexts.length); i > 0; i--) {
Context ctxt = getMappingData().contexts[i - 1];
try {
if (ctxt.getManager().findSession(requestedSessionId) != null) {
return true;
}
} catch (IOException e) {
// Ignore
}
}
return false;
}
}
return true;
}
use of org.apache.catalina.Manager in project spring-boot by spring-projects.
the class TomcatServletWebServerFactory method configureSession.
private void configureSession(Context context) {
long sessionTimeout = getSessionTimeoutInMinutes();
context.setSessionTimeout((int) sessionTimeout);
Boolean httpOnly = getSession().getCookie().getHttpOnly();
if (httpOnly != null) {
context.setUseHttpOnly(httpOnly);
}
if (getSession().isPersistent()) {
Manager manager = context.getManager();
if (manager == null) {
manager = new StandardManager();
context.setManager(manager);
}
configurePersistSession(manager);
} else {
context.addLifecycleListener(new DisablePersistSessionListener());
}
}
Aggregations