use of org.apache.catalina.LifecycleListener 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.LifecycleListener in project tomcat by apache.
the class StandardServerSF method storeChildren.
/**
* Store the specified server element children.
*
* @param aWriter Current output writer
* @param indent Indentation level
* @param aObject Server to store
* @param parentDesc The element description
* @throws Exception Configuration storing error
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aObject, StoreDescription parentDesc) throws Exception {
if (aObject instanceof StandardServer) {
StandardServer server = (StandardServer) aObject;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) server).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
/*LifecycleListener listener = null;
for (int i = 0; listener == null && i < listeners.length; i++)
if (listeners[i] instanceof ServerLifecycleListener)
listener = listeners[i];
if (listener != null) {
StoreDescription elementDesc = getRegistry()
.findDescription(
StandardServer.class.getName()
+ ".[ServerLifecycleListener]");
if (elementDesc != null) {
elementDesc.getStoreFactory().store(aWriter, indent,
listener);
}
}*/
// Store nested <GlobalNamingResources> element
NamingResourcesImpl globalNamingResources = server.getGlobalNamingResources();
StoreDescription elementDesc = getRegistry().findDescription(NamingResourcesImpl.class.getName() + ".[GlobalNamingResources]");
if (elementDesc != null) {
elementDesc.getStoreFactory().store(aWriter, indent, globalNamingResources);
}
// Store nested <Service> elements
Service[] services = server.findServices();
storeElementArray(aWriter, indent, services);
}
}
use of org.apache.catalina.LifecycleListener in project tomcat by apache.
the class StandardServiceSF method storeChildren.
/**
* Store the specified service element children.
*
* @param aWriter Current output writer
* @param indent Indentation level
* @param aService Service to store
* @param parentDesc The element description
* @throws Exception Configuration storing error
*/
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aService, StoreDescription parentDesc) throws Exception {
if (aService instanceof StandardService) {
StandardService service = (StandardService) aService;
// Store nested <Listener> elements
LifecycleListener[] listeners = ((Lifecycle) service).findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <Executor> elements
Executor[] executors = service.findExecutors();
storeElementArray(aWriter, indent, executors);
Connector[] connectors = service.findConnectors();
storeElementArray(aWriter, indent, connectors);
// Store nested <Engine> element
Engine container = service.getContainer();
if (container != null) {
StoreDescription elementDesc = getRegistry().findDescription(container.getClass());
if (elementDesc != null) {
IStoreFactory factory = elementDesc.getStoreFactory();
factory.store(aWriter, indent, container);
}
}
}
}
use of org.apache.catalina.LifecycleListener in project tomcat by apache.
the class ContainerMBean method removeLifecycleListeners.
/**
* Remove a LifecycleEvent listeners from this component.
*
* @param type The ClassName of the listeners to be removed.
* Note that all the listeners having given ClassName will be removed.
* @throws MBeanException propagated from the managed resource access
*/
public void removeLifecycleListeners(String type) throws MBeanException {
Container container = doGetManagedResource();
LifecycleListener[] listeners = container.findLifecycleListeners();
for (LifecycleListener listener : listeners) {
if (listener.getClass().getName().equals(type)) {
container.removeLifecycleListener(listener);
}
}
}
use of org.apache.catalina.LifecycleListener in project tomcat by apache.
the class ContainerMBean method addLifecycleListener.
/**
* Add a LifecycleEvent listener to this component.
*
* @param type ClassName of the listener to add
* @throws MBeanException if adding the listener failed
*/
public void addLifecycleListener(String type) throws MBeanException {
LifecycleListener listener = (LifecycleListener) newInstance(type);
Container container = doGetManagedResource();
container.addLifecycleListener(listener);
}
Aggregations