use of org.apache.catalina.Manager in project geode by apache.
the class JvmRouteBinderValve method invoke.
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
// Get the Manager
Manager manager = request.getContext().getManager();
// If it is an AbstractManager, handle possible failover
if (manager instanceof DeltaSessionManager) {
DeltaSessionManager absMgr = (DeltaSessionManager) manager;
String localJvmRoute = absMgr.getJvmRoute();
if (localJvmRoute != null) {
handlePossibleFailover(request, absMgr, localJvmRoute);
}
}
// Invoke the next Valve
getNext().invoke(request, response);
}
use of org.apache.catalina.Manager in project geode by apache.
the class CommitSessionValve method invoke.
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
// Get the Manager
Manager manager = request.getContext().getManager();
DeltaSessionFacade session = null;
// Invoke the next Valve
try {
getNext().invoke(request, response);
} finally {
// Commit and if the correct Manager was found
if (manager instanceof DeltaSessionManager) {
session = (DeltaSessionFacade) request.getSession(false);
DeltaSessionManager dsm = ((DeltaSessionManager) manager);
if (session != null) {
if (session.isValid()) {
dsm.removeTouchedSession(session.getId());
session.commit();
if (dsm.getTheContext().getLogger().isDebugEnabled()) {
dsm.getTheContext().getLogger().debug(session + ": Committed.");
}
} else {
if (dsm.getTheContext().getLogger().isDebugEnabled()) {
dsm.getTheContext().getLogger().debug(session + ": Not valid so not committing.");
}
}
}
}
}
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class ContainerBase method setManager.
/**
* Set the Manager with which this Container is associated.
*
* @param manager The newly associated Manager
*/
@Override
public void setManager(Manager manager) {
Lock writeLock = managerLock.writeLock();
writeLock.lock();
Manager oldManager = null;
try {
// Change components if necessary
oldManager = this.manager;
if (oldManager == manager)
return;
this.manager = manager;
// Stop the old component if necessary
if (oldManager instanceof Lifecycle) {
try {
((Lifecycle) oldManager).stop();
((Lifecycle) oldManager).destroy();
} catch (LifecycleException e) {
log.error("ContainerBase.setManager: stop-destroy: ", e);
}
}
// Start the new component if necessary
if (manager != null)
manager.setContainer(this);
if (getState().isAvailable() && manager instanceof Lifecycle) {
try {
((Lifecycle) manager).start();
} catch (LifecycleException e) {
log.error("ContainerBase.setManager: start: ", e);
}
}
} finally {
writeLock.unlock();
}
// Report this property change to interested listeners
support.firePropertyChange("manager", oldManager, manager);
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class ContainerBase method destroyInternal.
@Override
protected void destroyInternal() throws LifecycleException {
Manager manager = getManagerInternal();
if ((manager != null) && (manager instanceof Lifecycle)) {
((Lifecycle) manager).destroy();
}
Realm realm = getRealmInternal();
if ((realm != null) && (realm instanceof Lifecycle)) {
((Lifecycle) realm).destroy();
}
Cluster cluster = getClusterInternal();
if ((cluster != null) && (cluster instanceof Lifecycle)) {
((Lifecycle) cluster).destroy();
}
Loader loader = getLoaderInternal();
if ((loader != null) && (loader instanceof Lifecycle)) {
((Lifecycle) loader).destroy();
}
// Stop the Valves in our pipeline (including the basic), if any
if (pipeline instanceof Lifecycle) {
((Lifecycle) pipeline).destroy();
}
// Remove children now this container is being destroyed
for (Container child : findChildren()) {
removeChild(child);
}
// Required if the child is destroyed directly.
if (parent != null) {
parent.removeChild(this);
}
// If init fails, this may be null
if (startStopExecutor != null) {
startStopExecutor.shutdownNow();
}
super.destroyInternal();
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class StandardContext method stopInternal.
/**
* Stop this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void stopInternal() throws LifecycleException {
// Send j2ee.state.stopping notification
if (this.getObjectName() != null) {
Notification notification = new Notification("j2ee.state.stopping", this.getObjectName(), sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
}
setState(LifecycleState.STOPPING);
// Binding thread
ClassLoader oldCCL = bindThread();
try {
// Stop our child containers, if any
final Container[] children = findChildren();
ClassLoader old = bindThread();
try {
// Stop ContainerBackgroundProcessor thread
threadStop();
for (int i = 0; i < children.length; i++) {
children[i].stop();
}
// Stop our filters
filterStop();
Manager manager = getManagerInternal();
if (manager != null && manager instanceof Lifecycle && ((Lifecycle) manager).getState().isAvailable()) {
((Lifecycle) manager).stop();
}
// Stop our application listeners
listenerStop();
} finally {
unbindThread(old);
}
// Finalize our character set mapper
setCharsetMapper(null);
// Normal container shutdown processing
if (log.isDebugEnabled())
log.debug("Processing standard container shutdown");
// after the application has finished with the resource
if (namingResources != null) {
namingResources.stop();
}
fireLifecycleEvent(Lifecycle.CONFIGURE_STOP_EVENT, null);
// Stop the Valves in our pipeline (including the basic), if any
if (pipeline instanceof Lifecycle && ((Lifecycle) pipeline).getState().isAvailable()) {
((Lifecycle) pipeline).stop();
}
// Clear all application-originated servlet context attributes
if (context != null)
context.clearAttributes();
// Stop resources
resourcesStop();
Realm realm = getRealmInternal();
if ((realm != null) && (realm instanceof Lifecycle)) {
((Lifecycle) realm).stop();
}
Cluster cluster = getClusterInternal();
if ((cluster != null) && (cluster instanceof Lifecycle)) {
((Lifecycle) cluster).stop();
}
Loader loader = getLoaderInternal();
if ((loader != null) && (loader instanceof Lifecycle)) {
((Lifecycle) loader).stop();
}
} finally {
// Unbinding thread
unbindThread(oldCCL);
}
// Send j2ee.state.stopped notification
if (this.getObjectName() != null) {
Notification notification = new Notification("j2ee.state.stopped", this.getObjectName(), sequenceNumber.getAndIncrement());
broadcaster.sendNotification(notification);
}
// Reset application context
context = null;
// This object will no longer be visible or used.
try {
resetContext();
} catch (Exception ex) {
log.error("Error resetting context " + this + " " + ex, ex);
}
// reset the instance manager
setInstanceManager(null);
if (log.isDebugEnabled())
log.debug("Stopping complete");
}
Aggregations