📄 serverlifecyclelistener.java
字号:
log(message);
throwable.printStackTrace(System.out);
}
/**
* Process the addition of a new child Container to a parent Container.
*
* @param parent Parent container
* @param child Child container
*/
protected void processContainerAddChild(Container parent,
Container child) {
if (log.isDebugEnabled())
log.debug("Process addChild[parent=" + parent + ",child=" + child + "]");
try {
if (child instanceof Context) {
createMBeans((Context) child);
} else if (child instanceof Engine) {
createMBeans((Engine) child);
} else if (child instanceof Host) {
createMBeans((Host) child);
}
} catch (MBeanException t) {
Exception e = t.getTargetException();
if (e == null)
e = t;
log.error("processContainerAddChild: MBeanException", e);
} catch (Throwable t) {
log.error("processContainerAddChild: Throwable", t);
}
}
/**
* Process a property change event on a Container.
*
* @param container The container on which this event occurred
* @param propertyName The name of the property that changed
* @param oldValue The previous value (may be <code>null</code>)
* @param newValue The new value (may be <code>null</code>)
*
* @exception Exception if an exception is thrown
*/
protected void processContainerPropertyChange(Container container,
String propertyName,
Object oldValue,
Object newValue)
throws Exception {
if (log.isTraceEnabled()) {
log.trace("propertyChange[container=" + container +
",propertyName=" + propertyName +
",oldValue=" + oldValue +
",newValue=" + newValue + "]");
}
if ("defaultContext".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for DefaultContext " + oldValue);
}
destroyMBeans((DefaultContext) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for DefaultContext " + newValue);
}
createMBeans((DefaultContext) newValue);
}
} else if ("loader".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Loader " + oldValue);
}
MBeanUtils.destroyMBean((Loader) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Loader " + newValue);
}
MBeanUtils.createMBean((Loader) newValue);
}
} else if ("logger".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Logger " + oldValue);
}
// MBeanUtils.destroyMBean((Logger) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Logger " + newValue);
}
//MBeanUtils.createMBean((Logger) newValue);
}
} else if ("manager".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Manager " + oldValue);
}
//MBeanUtils.destroyMBean((Manager) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Manager " + newValue);
}
//MBeanUtils.createMBean((Manager) newValue);
}
} else if ("realm".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Realm " + oldValue);
}
MBeanUtils.destroyMBean((Realm) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Realm " + newValue);
}
//MBeanUtils.createMBean((Realm) newValue);
}
} else if ("service".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((Service) oldValue);
}
if (newValue != null) {
createMBeans((Service) newValue);
}
}
}
/**
* Process a property change event on a DefaultContext.
*
* @param defaultContext The DefaultContext on which this event occurred
* @param propertyName The name of the property that changed
* @param oldValue The previous value (may be <code>null</code>)
* @param newValue The new value (may be <code>null</code>)
*
* @exception Exception if an exception is thrown
*/
protected void processDefaultContextPropertyChange(DefaultContext defaultContext,
String propertyName,
Object oldValue,
Object newValue)
throws Exception {
if (log.isTraceEnabled()) {
log.trace("propertyChange[defaultContext=" + defaultContext +
",propertyName=" + propertyName +
",oldValue=" + oldValue +
",newValue=" + newValue + "]");
}
if ("loader".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Loader " + oldValue);
}
MBeanUtils.destroyMBean((Loader) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Loader " + newValue);
}
MBeanUtils.createMBean((Loader) newValue);
}
} else if ("logger".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Logger " + oldValue);
}
//MBeanUtils.destroyMBean((Logger) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Logger " + newValue);
}
//MBeanUtils.createMBean((Logger) newValue);
}
} else if ("manager".equals(propertyName)) {
if (oldValue != null) {
if (log.isDebugEnabled()) {
log.debug("Removing MBean for Manager " + oldValue);
}
MBeanUtils.destroyMBean((Manager) oldValue);
}
if (newValue != null) {
if (log.isDebugEnabled()) {
log.debug("Creating MBean for Manager " + newValue);
}
MBeanUtils.createMBean((Manager) newValue);
}
} else if ("realm".equals(propertyName)) {
if (oldValue != null) {
// if (log.isDebugEnabled()) {
// log.debug("Removing MBean for Realm " + oldValue);
// }
// //MBeanUtils.destroyMBean((Realm) oldValue);
}
if (newValue != null) {
// if (log.isDebugEnabled()) {
// log.debug("Creating MBean for Realm " + newValue);
// }
// //MBeanUtils.createMBean((Realm) newValue);
}
} else if ("service".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((Service) oldValue);
}
if (newValue != null) {
createMBeans((Service) newValue);
}
}
}
/**
* Process the removal of a child Container from a parent Container.
*
* @param parent Parent container
* @param child Child container
*/
protected void processContainerRemoveChild(Container parent,
Container child) {
if (log.isDebugEnabled())
log.debug("Process removeChild[parent=" + parent + ",child=" +
child + "]");
try {
if (child instanceof Context) {
Context context = (Context) child;
if (context.getPrivileged()) {
context.getServletContext().removeAttribute
(Globals.MBEAN_REGISTRY_ATTR);
context.getServletContext().removeAttribute
(Globals.MBEAN_SERVER_ATTR);
}
if (log.isDebugEnabled())
log.debug(" Removing MBean for Context " + context);
destroyMBeans(context);
if (context instanceof StandardContext) {
((StandardContext) context).
removePropertyChangeListener(this);
}
} else if (child instanceof Host) {
Host host = (Host) child;
destroyMBeans(host);
if (host instanceof StandardHost) {
((StandardHost) host).
removePropertyChangeListener(this);
}
}
} catch (MBeanException t) {
Exception e = t.getTargetException();
if (e == null)
e = t;
log.error("processContainerRemoveChild: MBeanException", e);
} catch (Throwable t) {
log.error("processContainerRemoveChild: Throwable", t);
}
}
/**
* Process a property change event on a NamingResources.
*
* @param resources The global naming resources on which this
* event occurred
* @param propertyName The name of the property that changed
* @param oldValue The previous value (may be <code>null</code>)
* @param newValue The new value (may be <code>null</code>)
*
* @exception Exception if an exception is thrown
*/
protected void processNamingResourcesPropertyChange
(NamingResources resources, String propertyName,
Object oldValue, Object newValue)
throws Exception {
if (log.isTraceEnabled()) {
log.trace("propertyChange[namingResources=" + resources +
",propertyName=" + propertyName +
",oldValue=" + oldValue +
",newValue=" + newValue + "]");
}
// FIXME - Add other resource types when supported by admin tool
if ("environment".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((ContextEnvironment) oldValue);
}
if (newValue != null) {
createMBeans((ContextEnvironment) newValue);
}
} else if ("resource".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((ContextResource) oldValue);
}
if (newValue != null) {
createMBeans((ContextResource) newValue);
}
} else if ("resourceLink".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((ContextResourceLink) oldValue);
}
if (newValue != null) {
createMBeans((ContextResourceLink) newValue);
}
}
}
/**
* Process a property change event on a Server.
*
* @param server The server on which this event occurred
* @param propertyName The name of the property that changed
* @param oldValue The previous value (may be <code>null</code>)
* @param newValue The new value (may be <code>null</code>)
*
* @exception Exception if an exception is thrown
*/
protected void processServerPropertyChange(Server server,
String propertyName,
Object oldValue,
Object newValue)
throws Exception {
if (log.isTraceEnabled()) {
log.trace("propertyChange[server=" + server +
",propertyName=" + propertyName +
",oldValue=" + oldValue +
",newValue=" + newValue + "]");
}
if ("globalNamingResources".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((NamingResources) oldValue);
}
if (newValue != null) {
createMBeans((NamingResources) newValue);
}
} else if ("service".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((Service) oldValue);
}
if (newValue != null) {
createMBeans((Service) newValue);
}
}
}
/**
* Process a property change event on a Service.
*
* @param service The service on which this event occurred
* @param propertyName The name of the property that changed
* @param oldValue The previous value (may be <code>null</code>)
* @param newValue The new value (may be <code>null</code>)
*
* @exception Exception if an exception is thrown
*/
protected void processServicePropertyChange(Service service,
String propertyName,
Object oldValue,
Object newValue)
throws Exception {
if (log.isTraceEnabled()) {
log.trace("propertyChange[service=" + service +
",propertyName=" + propertyName +
",oldValue=" + oldValue +
",newValue=" + newValue + "]");
}
if ("connector".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((Connector) oldValue, service);
}
if (newValue != null) {
createMBeans((Connector) newValue);
}
} else if ("container".equals(propertyName)) {
if (oldValue != null) {
destroyMBeans((Engine) oldValue);
}
if (newValue != null) {
createMBeans((Engine) newValue);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -