📄 serverlifecyclelistener.java
字号:
for (int j = 0; j < connectors.length; j++) {
createMBeans(connectors[j]);
}
// Create the MBean for the associated Engine and friends
Engine engine = (Engine) service.getContainer();
if (engine != null) {
createMBeans(engine);
}
}
/**
* Deregister the MBeans for the specified Connector and its nested
* components.
*
* @param connector Connector for which to deregister MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Connector connector, Service service)
throws Exception {
// // deregister the MBean for the Connector itself
// if (log.isDebugEnabled())
// log.debug("Destroying MBean for Connector " + connector);
// MBeanUtils.destroyMBean(connector, service);
}
/**
* Deregister the MBeans for the specified Context and its nested
* components.
*
* @param context Context for which to deregister MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Context context) throws Exception {
// Deregister ourselves as a ContainerListener
context.removeContainerListener(this);
// Destroy the MBeans for the associated nested components
Realm hRealm = context.getParent().getRealm();
Realm cRealm = context.getRealm();
if ((cRealm != null) && (cRealm != hRealm)) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Realm " + cRealm);
//MBeanUtils.destroyMBean(cRealm);
}
Manager cManager = context.getManager();
if (cManager != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Manager " + cManager);
//MBeanUtils.destroyMBean(cManager);
}
Logger hLogger = context.getParent().getLogger();
Logger cLogger = context.getLogger();
if ((cLogger != null) && (cLogger != hLogger)) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Logger " + cLogger);
//MBeanUtils.destroyMBean(cLogger);
}
Loader cLoader = context.getLoader();
if (cLoader != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Loader " + cLoader);
//MBeanUtils.destroyMBean(cLoader);
}
// Destroy the MBeans for the NamingResources (if any)
NamingResources resources = context.getNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// deregister the MBean for the Context itself
if (log.isDebugEnabled())
log.debug("Destroying MBean for Context " + context);
//MBeanUtils.destroyMBean(context);
if (context instanceof StandardContext) {
((StandardContext) context).
removePropertyChangeListener(this);
}
}
/**
* Deregister the MBeans for the specified ContextEnvironment entry.
*
* @param environment ContextEnvironment for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(ContextEnvironment environment)
throws Exception {
// Destroy the MBean for the ContextEnvironment itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for ContextEnvironment " + environment);
}
MBeanUtils.destroyMBean(environment);
}
/**
* Deregister the MBeans for the specified ContextResource entry.
*
* @param resource ContextResource for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(ContextResource resource)
throws Exception {
// Destroy the MBean for the ContextResource itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for ContextResource " + resource);
}
MBeanUtils.destroyMBean(resource);
}
/**
* Deregister the MBeans for the specified ContextResourceLink entry.
*
* @param resourceLink ContextResourceLink for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(ContextResourceLink resourceLink)
throws Exception {
// Destroy the MBean for the ContextResourceLink itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for ContextResourceLink " + resourceLink);
}
MBeanUtils.destroyMBean(resourceLink);
}
/**
* Deregister the MBeans for the specified DefaultContext and its nested
* components.
*
* @param dcontext DefaultContext for which to deregister MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(DefaultContext dcontext) throws Exception {
Manager dManager = dcontext.getManager();
if (dManager != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Manager " + dManager);
//MBeanUtils.destroyMBean(dManager);
}
Loader dLoader = dcontext.getLoader();
if (dLoader != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Loader " + dLoader);
//MBeanUtils.destroyMBean(dLoader);
}
// Destroy the MBeans for the NamingResources (if any)
NamingResources resources = dcontext.getNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// deregister the MBean for the DefaultContext itself
if (log.isDebugEnabled())
log.debug("Destroying MBean for Context " + dcontext);
MBeanUtils.destroyMBean(dcontext);
dcontext.removePropertyChangeListener(this);
}
/**
* Deregister the MBeans for the specified Engine and its nested
* components.
*
* @param engine Engine for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Engine engine) throws Exception {
// Deregister ourselves as a ContainerListener
engine.removeContainerListener(this);
// Deregister the MBeans for each child Host
Container hosts[] = engine.findChildren();
for (int k = 0; k < hosts.length; k++) {
destroyMBeans((Host) hosts[k]);
}
// Deregister the MBeans for the associated nested components
Realm eRealm = engine.getRealm();
if (eRealm != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Realm " + eRealm);
//MBeanUtils.destroyMBean(eRealm);
}
Logger eLogger = engine.getLogger();
if (eLogger != null) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Logger " + eLogger);
//MBeanUtils.destroyMBean(eLogger);
}
// Deregister the MBean for the Engine itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Engine " + engine);
}
//MBeanUtils.destroyMBean(engine);
}
/**
* Deregister the MBeans for the specified Host and its nested components.
*
* @param host Host for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Host host) throws Exception {
// Deregister ourselves as a ContainerListener
host.removeContainerListener(this);
// Deregister the MBeans for each child Context
Container contexts[] = host.findChildren();
for (int k = 0; k < contexts.length; k++) {
destroyMBeans((Context) contexts[k]);
}
// Deregister the MBeans for the associated nested components
Realm eRealm = host.getParent().getRealm();
Realm hRealm = host.getRealm();
if ((hRealm != null) && (hRealm != eRealm)) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Realm " + hRealm);
//MBeanUtils.destroyMBean(hRealm);
}
Logger eLogger = host.getParent().getLogger();
Logger hLogger = host.getLogger();
if ((hLogger != null) && (hLogger != eLogger)) {
if (log.isDebugEnabled())
log.debug("Destroying MBean for Logger " + hLogger);
//MBeanUtils.destroyMBean(hLogger);
}
// Deregister the MBean for the Host itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Host " + host);
}
//MBeanUtils.destroyMBean(host);
}
/**
* Deregister the MBeans for the specified NamingResources and its
* nested components.
*
* @param resources NamingResources for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(NamingResources resources) throws Exception {
// Destroy the MBeans for each child resource entry
ContextResource cresources[] = resources.findResources();
for (int i = 0; i < cresources.length; i++) {
destroyMBeans(cresources[i]);
}
// Destroy the MBeans for each child resource link entry
ContextResourceLink cresourcelinks[] = resources.findResourceLinks();
for (int i = 0; i < cresourcelinks.length; i++) {
destroyMBeans(cresourcelinks[i]);
}
// Destroy the MBeans for each child environment entry
ContextEnvironment environments[] = resources.findEnvironments();
for (int i = 0; i < environments.length; i++) {
destroyMBeans(environments[i]);
}
// Destroy the MBean for the NamingResources itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for NamingResources " + resources);
}
MBeanUtils.destroyMBean(resources);
resources.removePropertyChangeListener(this);
}
/**
* Deregister the MBeans for the specified Server and its related
* components.
*
* @param server Server for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Server server) throws Exception {
// Destroy the MBeans for the global NamingResources (if any)
NamingResources resources = server.getGlobalNamingResources();
if (resources != null) {
destroyMBeans(resources);
}
// Destroy the MBeans for each child Service
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
// FIXME - Warp object hierarchy not currently supported
if (services[i].getContainer().getClass().getName().equals
("org.apache.catalina.connector.warp.WarpEngine")) {
if (log.isDebugEnabled()) {
log.debug("Skipping MBean for Service " + services[i]);
}
continue;
}
destroyMBeans(services[i]);
}
// Destroy the MBean for the Server itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Server " + server);
}
//MBeanUtils.destroyMBean(server);
if (server instanceof StandardServer) {
((StandardServer) server).removePropertyChangeListener(this);
}
}
/**
* Deregister the MBeans for the specified Service and its nested
* components.
*
* @param service Service for which to destroy MBeans
*
* @exception Exception if an exception is thrown during MBean destruction
*/
protected void destroyMBeans(Service service) throws Exception {
// Deregister the MBeans for the associated Engine
Engine engine = (Engine) service.getContainer();
if (engine != null) {
//destroyMBeans(engine);
}
// // Deregister the MBeans for the corresponding Connectors
// Connector connectors[] = service.findConnectors();
// for (int j = 0; j < connectors.length; j++) {
// destroyMBeans(connectors[j], service);
// }
// Deregister the MBean for the Service itself
if (log.isDebugEnabled()) {
log.debug("Destroying MBean for Service " + service);
}
//MBeanUtils.destroyMBean(service);
if (service instanceof StandardService) {
((StandardService) service).removePropertyChangeListener(this);
}
}
/**
* Log a message.
*
* @param message The message to be logged
*/
protected void log(String message) {
System.out.print("ServerLifecycleListener: ");
System.out.println(message);
}
/**
* Log a message and associated exception.
*
* @param message The message to be logged
* @param throwable The exception to be logged
*/
protected void log(String message, Throwable throwable) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -