use of org.apache.catalina.Cluster in project tomcat by apache.
the class StandardHostSF method storeChildren.
/**
* Store the specified Host properties and children
* (Listener,Alias,Realm,Valve,Cluster, Context)
*
* @param aWriter
* PrintWriter to which we are storing
* @param indent
* Number of spaces to indent this element
* @param aHost
* Host whose properties are being stored
*
* @exception Exception
* if an exception occurs while storing
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aHost, StoreDescription parentDesc) throws Exception {
if (aHost instanceof StandardHost) {
StandardHost host = (StandardHost) aHost;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) host).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <Alias> elements
String[] aliases = host.findAliases();
getStoreAppender().printTagArray(aWriter, "Alias", indent + 2, aliases);
// Store nested <Realm> element
Realm realm = host.getRealm();
if (realm != null) {
Realm parentRealm = null;
if (host.getParent() != null) {
parentRealm = host.getParent().getRealm();
}
if (realm != parentRealm) {
storeElement(aWriter, indent, realm);
}
}
// Store nested <Valve> elements
Valve[] valves = host.getPipeline().getValves();
if (valves != null && valves.length > 0) {
List<Valve> hostValves = new ArrayList<>();
for (int i = 0; i < valves.length; i++) {
if (!(valves[i] instanceof ClusterValve))
hostValves.add(valves[i]);
}
storeElementArray(aWriter, indent, hostValves.toArray());
}
// store all <Cluster> elements
Cluster cluster = host.getCluster();
if (cluster != null) {
Cluster parentCluster = null;
if (host.getParent() != null) {
parentCluster = host.getParent().getCluster();
}
if (cluster != parentCluster) {
storeElement(aWriter, indent, cluster);
}
}
// store all <Context> elements
Container[] children = host.findChildren();
storeElementArray(aWriter, indent, children);
}
}
use of org.apache.catalina.Cluster in project tomcat 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);
}
}
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.Cluster in project tomcat by apache.
the class ContainerBase method destroyInternal.
@Override
protected void destroyInternal() throws LifecycleException {
Realm realm = getRealmInternal();
if (realm instanceof Lifecycle) {
((Lifecycle) realm).destroy();
}
Cluster cluster = getClusterInternal();
if (cluster instanceof Lifecycle) {
((Lifecycle) cluster).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.Cluster in project tomee by apache.
the class TomcatWebAppBuilder method manageCluster.
private void manageCluster(final Cluster cluster) {
if (cluster == null || cluster instanceof SimpleTomEETcpCluster) {
return;
}
Cluster current = cluster;
if (cluster instanceof SimpleTcpCluster) {
final Container container = cluster.getContainer();
current = new SimpleTomEETcpCluster((SimpleTcpCluster) cluster);
container.setCluster(current);
}
if (current instanceof CatalinaCluster) {
final CatalinaCluster haCluster = (CatalinaCluster) current;
TomEEClusterListener listener = SystemInstance.get().getComponent(TomEEClusterListener.class);
if (listener == null) {
listener = new TomEEClusterListener();
SystemInstance.get().setComponent(TomEEClusterListener.class, listener);
}
// better to be a singleton
haCluster.addClusterListener(listener);
clusters.add(haCluster);
}
}
use of org.apache.catalina.Cluster in project tomcat by apache.
the class StandardEngineSF method storeChildren.
/**
* Store the specified Engine properties.
*
* @param aWriter
* PrintWriter to which we are storing
* @param indent
* Number of spaces to indent this element
* @param aEngine
* Object whose properties are being stored
*
* @exception Exception
* if an exception occurs while storing
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aEngine, StoreDescription parentDesc) throws Exception {
if (aEngine instanceof StandardEngine) {
StandardEngine engine = (StandardEngine) aEngine;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) engine).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <Realm> element
Realm realm = engine.getRealm();
Realm parentRealm = null;
// TODO is this case possible? (see it a old Server 5.0 impl)
if (engine.getParent() != null) {
parentRealm = engine.getParent().getRealm();
}
if (realm != parentRealm) {
storeElement(aWriter, indent, realm);
}
// Store nested <Valve> elements
Valve[] valves = engine.getPipeline().getValves();
if (valves != null && valves.length > 0) {
List<Valve> engineValves = new ArrayList<>();
for (int i = 0; i < valves.length; i++) {
if (!(valves[i] instanceof ClusterValve))
engineValves.add(valves[i]);
}
storeElementArray(aWriter, indent, engineValves.toArray());
}
// store all <Cluster> elements
Cluster cluster = engine.getCluster();
if (cluster != null) {
storeElement(aWriter, indent, cluster);
}
// store all <Host> elements
Container[] children = engine.findChildren();
storeElementArray(aWriter, indent, children);
}
}
Aggregations