use of org.apache.catalina.Manager in project tomcat70 by apache.
the class SingleSignOnListener method sessionEvent.
@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);
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class ContainerBase method backgroundProcess.
/**
* Execute a periodic task, such as reloading, etc. This method will be
* invoked inside the classloading context of this container. Unexpected
* throwables will be caught and logged.
*/
@Override
public void backgroundProcess() {
if (!getState().isAvailable())
return;
Cluster cluster = getClusterInternal();
if (cluster != null) {
try {
cluster.backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("containerBase.backgroundProcess.cluster", cluster), e);
}
}
Loader loader = getLoaderInternal();
if (loader != null) {
try {
loader.backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("containerBase.backgroundProcess.loader", loader), e);
}
}
Manager manager = getManagerInternal();
if (manager != null) {
try {
manager.backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("containerBase.backgroundProcess.manager", manager), e);
}
}
Realm realm = getRealmInternal();
if (realm != null) {
try {
realm.backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("containerBase.backgroundProcess.realm", realm), e);
}
}
Valve current = pipeline.getFirst();
while (current != null) {
try {
current.backgroundProcess();
} catch (Exception e) {
log.warn(sm.getString("containerBase.backgroundProcess.valve", current), e);
}
current = current.getNext();
}
fireLifecycleEvent(Lifecycle.PERIODIC_EVENT, null);
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class ContainerBase method startInternal.
/**
* Start this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
// Start our subordinate components, if any
Loader loader = getLoaderInternal();
if ((loader != null) && (loader instanceof Lifecycle))
((Lifecycle) loader).start();
logger = null;
getLogger();
Manager manager = getManagerInternal();
if ((manager != null) && (manager instanceof Lifecycle))
((Lifecycle) manager).start();
Cluster cluster = getClusterInternal();
if ((cluster != null) && (cluster instanceof Lifecycle))
((Lifecycle) cluster).start();
Realm realm = getRealmInternal();
if ((realm != null) && (realm instanceof Lifecycle))
((Lifecycle) realm).start();
DirContext resources = getResourcesInternal();
if ((resources != null) && (resources instanceof Lifecycle))
((Lifecycle) resources).start();
// Start our child containers, if any
Container[] children = findChildren();
List<Future<Void>> results = new ArrayList<Future<Void>>();
for (int i = 0; i < children.length; i++) {
results.add(startStopExecutor.submit(new StartChild(children[i])));
}
boolean fail = false;
for (Future<Void> result : results) {
try {
result.get();
} catch (Exception e) {
log.error(sm.getString("containerBase.threadedStartFailed"), e);
fail = true;
}
}
if (fail) {
throw new LifecycleException(sm.getString("containerBase.threadedStartFailed"));
}
// Start the Valves in our pipeline (including the basic), if any
if (pipeline instanceof Lifecycle)
((Lifecycle) pipeline).start();
setState(LifecycleState.STARTING);
// Start our thread
threadStart();
}
use of org.apache.catalina.Manager in project tomcat70 by apache.
the class ContainerBase 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 {
// Stop our thread
threadStop();
setState(LifecycleState.STOPPING);
// Stop the Valves in our pipeline (including the basic), if any
if (pipeline instanceof Lifecycle && ((Lifecycle) pipeline).getState().isAvailable()) {
((Lifecycle) pipeline).stop();
}
// Stop our child containers, if any
Container[] children = findChildren();
List<Future<Void>> results = new ArrayList<Future<Void>>();
for (int i = 0; i < children.length; i++) {
results.add(startStopExecutor.submit(new StopChild(children[i])));
}
boolean fail = false;
for (Future<Void> result : results) {
try {
result.get();
} catch (Exception e) {
log.error(sm.getString("containerBase.threadedStopFailed"), e);
fail = true;
}
}
if (fail) {
throw new LifecycleException(sm.getString("containerBase.threadedStopFailed"));
}
// Stop our subordinate components, if any
DirContext resources = getResourcesInternal();
if ((resources != null) && (resources instanceof Lifecycle)) {
((Lifecycle) resources).stop();
}
Realm realm = getRealmInternal();
if ((realm != null) && (realm instanceof Lifecycle)) {
((Lifecycle) realm).stop();
}
Cluster cluster = getClusterInternal();
if ((cluster != null) && (cluster instanceof Lifecycle)) {
((Lifecycle) cluster).stop();
}
Manager manager = getManagerInternal();
if ((manager != null) && (manager instanceof Lifecycle) && ((Lifecycle) manager).getState().isAvailable()) {
((Lifecycle) manager).stop();
}
Loader loader = getLoaderInternal();
if ((loader != null) && (loader instanceof Lifecycle)) {
((Lifecycle) loader).stop();
}
}
use of org.apache.catalina.Manager in project jaggery by wso2.
the class TomcatJaggeryWebappsDeployer method handleWebappDeployment.
/**
* Deployment procedure of Jaggery apps
*
* @param webappFile The Jaggery app file to be deployed
* @param contextStr jaggery app context string
* @param webContextParams context-params for this Jaggery app
* @param applicationEventListeners Application event listeners
* @throws CarbonException If a deployment error occurs
*/
protected void handleWebappDeployment(File webappFile, String contextStr, List<WebContextParameter> webContextParams, List<Object> applicationEventListeners) throws CarbonException {
String filename = webappFile.getName();
ArrayList<Object> listeners = new ArrayList<Object>(1);
// listeners.add(new CarbonServletRequestListener());
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setAuthConstraint(true);
SecurityCollection securityCollection = new SecurityCollection();
securityCollection.setName("ConfigDir");
securityCollection.setDescription("Jaggery Configuration Dir");
securityCollection.addPattern("/" + JaggeryCoreConstants.JAGGERY_CONF_FILE);
securityConstraint.addCollection(securityCollection);
WebApplicationsHolder webApplicationsHolder = WebAppUtils.getWebappHolder(webappFile.getAbsolutePath(), configurationContext);
try {
JSONObject jaggeryConfigObj = readJaggeryConfig(webappFile);
Tomcat tomcat = DataHolder.getCarbonTomcatService().getTomcat();
Context context = DataHolder.getCarbonTomcatService().addWebApp(contextStr, webappFile.getAbsolutePath(), new JaggeryDeployerManager.JaggeryConfListener(jaggeryConfigObj, securityConstraint));
// deploying web app for url mapping inside virtual host
if (DataHolder.getHotUpdateService() != null) {
List<String> hostNames = DataHolder.getHotUpdateService().getMappigsPerWebapp(contextStr);
for (String hostName : hostNames) {
Host host = DataHolder.getHotUpdateService().addHost(hostName);
/* ApplicationContext.getCurrentApplicationContext().putUrlMappingForApplication(hostName, contextStr);
*/
Context contextForHost = DataHolder.getCarbonTomcatService().addWebApp(host, "/", webappFile.getAbsolutePath(), new JaggeryDeployerManager.JaggeryConfListener(jaggeryConfigObj, securityConstraint));
log.info("Deployed JaggeryApp on host: " + contextForHost);
}
}
Manager manager = context.getManager();
if (isDistributable(context, jaggeryConfigObj)) {
// Clusterable manager implementation as DeltaManager
context.setDistributable(true);
// Using clusterable manager
CarbonTomcatClusterableSessionManager sessionManager;
if (manager instanceof CarbonTomcatClusterableSessionManager) {
sessionManager = (CarbonTomcatClusterableSessionManager) manager;
sessionManager.setOwnerTenantId(tenantId);
} else {
sessionManager = new CarbonTomcatClusterableSessionManager(tenantId);
context.setManager(sessionManager);
}
Object alreadyinsertedSMMap = configurationContext.getProperty(CarbonConstants.TOMCAT_SESSION_MANAGER_MAP);
if (alreadyinsertedSMMap != null) {
((Map<String, CarbonTomcatClusterableSessionManager>) alreadyinsertedSMMap).put(context.getName(), sessionManager);
} else {
sessionManagerMap.put(context.getName(), sessionManager);
configurationContext.setProperty(CarbonConstants.TOMCAT_SESSION_MANAGER_MAP, sessionManagerMap);
}
} else {
if (manager instanceof CarbonTomcatSessionManager) {
((CarbonTomcatSessionManager) manager).setOwnerTenantId(tenantId);
} else if (manager instanceof CarbonTomcatSessionPersistentManager) {
((CarbonTomcatSessionPersistentManager) manager).setOwnerTenantId(tenantId);
log.debug(manager.getInfo() + " enabled Tomcat HTTP Session Persistent mode using " + ((CarbonTomcatSessionPersistentManager) manager).getStore().getInfo());
} else {
context.setManager(new CarbonTomcatSessionManager(tenantId));
}
}
context.setReloadable(false);
JaggeryApplication webapp = new JaggeryApplication(this, context, webappFile);
webapp.setServletContextParameters(webContextParams);
webapp.setState("Started");
webApplicationsHolder.getStartedWebapps().put(filename, webapp);
webApplicationsHolder.getFaultyWebapps().remove(filename);
registerApplicationEventListeners(applicationEventListeners, context);
log.info("Deployed webapp: " + webapp);
} catch (Throwable e) {
// catching a Throwable here to avoid web-apps crashing the server during startup
StandardContext context = new StandardContext();
context.setName(webappFile.getName());
context.addParameter(WebappsConstants.FAULTY_WEBAPP, "true");
JaggeryApplication webapp = new JaggeryApplication(this, context, webappFile);
webapp.setProperty(WebappsConstants.WEBAPP_FILTER, JaggeryConstants.JAGGERY_WEBAPP_FILTER_PROP);
String msg = "Error while deploying webapp: " + webapp;
log.error(msg, e);
webapp.setFaultReason(new Exception(msg, e));
webApplicationsHolder.getFaultyWebapps().put(filename, webapp);
webApplicationsHolder.getStartedWebapps().remove(filename);
throw new CarbonException(msg, e);
}
}
Aggregations