use of org.apache.catalina.Container 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.Container 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);
}
use of org.apache.catalina.Container in project tomcat by apache.
the class ContainerMBean method addChild.
/**
* Add a new child Container to those associated with this Container,
* if supported. Won't start the child yet. Has to be started with a call to
* Start method after necessary configurations are done.
*
* @param type ClassName of the child to be added
* @param name Name of the child to be added
*
* @exception MBeanException if the child cannot be added
*/
public void addChild(String type, String name) throws MBeanException {
Container contained = (Container) newInstance(type);
contained.setName(name);
if (contained instanceof StandardHost) {
HostConfig config = new HostConfig();
contained.addLifecycleListener(config);
} else if (contained instanceof StandardContext) {
ContextConfig config = new ContextConfig();
contained.addLifecycleListener(config);
}
boolean oldValue = true;
ContainerBase container = doGetManagedResource();
try {
oldValue = container.getStartChildren();
container.setStartChildren(false);
container.addChild(contained);
contained.init();
} catch (LifecycleException e) {
throw new MBeanException(e);
} finally {
if (container != null) {
container.setStartChildren(oldValue);
}
}
}
use of org.apache.catalina.Container in project tomcat by apache.
the class ManagerServlet method list.
/**
* Render a list of the currently active Contexts in our virtual host.
*
* @param writer Writer to render to
* @param smClient i18n support for current client's locale
*/
protected void list(PrintWriter writer, StringManager smClient) {
if (debug >= 1)
log("list: Listing contexts for virtual host '" + host.getName() + "'");
writer.println(smClient.getString("managerServlet.listed", host.getName()));
Container[] contexts = host.findChildren();
for (int i = 0; i < contexts.length; i++) {
Context context = (Context) contexts[i];
if (context != null) {
String displayPath = context.getPath();
if (displayPath.equals(""))
displayPath = "/";
if (context.getState().isAvailable()) {
writer.println(smClient.getString("managerServlet.listitem", displayPath, "running", "" + context.getManager().findSessions().length, context.getDocBase()));
} else {
writer.println(smClient.getString("managerServlet.listitem", displayPath, "stopped", "0", context.getDocBase()));
}
}
}
}
use of org.apache.catalina.Container in project tomcat by apache.
the class HostManagerServlet method list.
/**
* Render a list of the currently active Contexts in our virtual host.
*
* @param writer Writer to render to
* @param smClient StringManager for the client's locale
*/
protected void list(PrintWriter writer, StringManager smClient) {
if (debug >= 1) {
log(sm.getString("hostManagerServlet.list", engine.getName()));
}
writer.println(smClient.getString("hostManagerServlet.listed", engine.getName()));
Container[] hosts = engine.findChildren();
for (int i = 0; i < hosts.length; i++) {
Host host = (Host) hosts[i];
String name = host.getName();
String[] aliases = host.findAliases();
StringBuilder buf = new StringBuilder();
if (aliases.length > 0) {
buf.append(aliases[0]);
for (int j = 1; j < aliases.length; j++) {
buf.append(',').append(aliases[j]);
}
}
writer.println(smClient.getString("hostManagerServlet.listitem", name, buf.toString()));
}
}
Aggregations