This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 43d429ed10 Code clean-up - formatting. No functional change.
43d429ed10 is described below
commit 43d429ed10ad64821203fe02815826de5928aae1
Author: Mark Thomas <[email protected]>
AuthorDate: Thu May 22 17:25:19 2025 +0100
Code clean-up - formatting. No functional change.
---
.../apache/tomcat/util/modeler/AttributeInfo.java | 33 +-
.../tomcat/util/modeler/BaseAttributeFilter.java | 42 +-
.../apache/tomcat/util/modeler/BaseModelMBean.java | 457 +++++++++------------
.../util/modeler/BaseNotificationBroadcaster.java | 51 +--
.../apache/tomcat/util/modeler/FeatureInfo.java | 10 +-
.../apache/tomcat/util/modeler/ManagedBean.java | 111 +++--
.../tomcat/util/modeler/NoDescriptorRegistry.java | 84 ++--
.../tomcat/util/modeler/NotificationInfo.java | 23 +-
.../apache/tomcat/util/modeler/OperationInfo.java | 33 +-
.../apache/tomcat/util/modeler/ParameterInfo.java | 15 +-
java/org/apache/tomcat/util/modeler/Registry.java | 168 ++++----
.../apache/tomcat/util/modeler/RegistryMBean.java | 79 ++--
.../modules/MbeansDescriptorsDigesterSource.java | 137 +++---
.../MbeansDescriptorsIntrospectionSource.java | 122 ++----
.../tomcat/util/modeler/modules/ModelerSource.java | 9 +-
15 files changed, 589 insertions(+), 785 deletions(-)
diff --git a/java/org/apache/tomcat/util/modeler/AttributeInfo.java
b/java/org/apache/tomcat/util/modeler/AttributeInfo.java
index 0ecf077ff2..15f83e59c3 100644
--- a/java/org/apache/tomcat/util/modeler/AttributeInfo.java
+++ b/java/org/apache/tomcat/util/modeler/AttributeInfo.java
@@ -21,8 +21,9 @@ import java.io.Serial;
import javax.management.MBeanAttributeInfo;
/**
- * <p>Internal configuration information for an <code>Attribute</code>
- * descriptor.</p>
+ * <p>
+ * Internal configuration information for an <code>Attribute</code> descriptor.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -57,7 +58,7 @@ public class AttributeInfo extends FeatureInfo {
* @return the name of the property getter method, if non-standard.
*/
public String getGetMethod() {
- if(getMethod == null) {
+ if (getMethod == null) {
getMethod = getMethodName(getName(), true, isIs());
}
return this.getMethod;
@@ -69,8 +70,8 @@ public class AttributeInfo extends FeatureInfo {
/**
* Is this a boolean attribute with an "is" getter?
- * @return <code>true</code> if this is a boolean attribute
- * with an "is" getter
+ *
+ * @return <code>true</code> if this is a boolean attribute with an "is"
getter
*/
public boolean isIs() {
return this.is;
@@ -83,6 +84,7 @@ public class AttributeInfo extends FeatureInfo {
/**
* Is this attribute readable by management applications?
+ *
* @return <code>true</code> if readable
*/
public boolean isReadable() {
@@ -98,7 +100,7 @@ public class AttributeInfo extends FeatureInfo {
* @return the name of the property setter method, if non-standard.
*/
public String getSetMethod() {
- if( setMethod == null ) {
+ if (setMethod == null) {
setMethod = getMethodName(getName(), false, false);
}
return this.setMethod;
@@ -110,6 +112,7 @@ public class AttributeInfo extends FeatureInfo {
/**
* Is this attribute writable by management applications?
+ *
* @return <code>true</code> if writable
*/
public boolean isWriteable() {
@@ -124,29 +127,29 @@ public class AttributeInfo extends FeatureInfo {
/**
- * Create and return a <code>ModelMBeanAttributeInfo</code> object that
- * corresponds to the attribute described by this instance.
+ * Create and return a <code>ModelMBeanAttributeInfo</code> object that
corresponds to the attribute described by
+ * this instance.
+ *
* @return the attribute info
*/
MBeanAttributeInfo createAttributeInfo() {
// Return our cached information (if any)
if (info == null) {
- info = new MBeanAttributeInfo(getName(), getType(),
getDescription(),
- isReadable(), isWriteable(), false);
+ info = new MBeanAttributeInfo(getName(), getType(),
getDescription(), isReadable(), isWriteable(), false);
}
- return (MBeanAttributeInfo)info;
+ return (MBeanAttributeInfo) info;
}
// -------------------------------------------------------- Private Methods
/**
- * Create and return the name of a default property getter or setter
- * method, according to the specified values.
+ * Create and return the name of a default property getter or setter
method, according to the specified values.
*
- * @param name Name of the property itself
+ * @param name Name of the property itself
* @param getter Do we want a get method (versus a set method)?
- * @param is If returning a getter, do we want the "is" form?
+ * @param is If returning a getter, do we want the "is" form?
+ *
* @return the method name
*/
private String getMethodName(String name, boolean getter, boolean is) {
diff --git a/java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java
b/java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java
index 597893a110..9dfde130a2 100644
--- a/java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java
+++ b/java/org/apache/tomcat/util/modeler/BaseAttributeFilter.java
@@ -27,10 +27,11 @@ import javax.management.NotificationFilter;
/**
- * <p>Implementation of <code>NotificationFilter</code> for attribute change
- * notifications. This class is used by <code>BaseModelMBean</code> to
- * construct attribute change notification event filters when a filter is not
- * supplied by the application.</p>
+ * <p>
+ * Implementation of <code>NotificationFilter</code> for attribute change
notifications. This class is used by
+ * <code>BaseModelMBean</code> to construct attribute change notification
event filters when a filter is not supplied by
+ * the application.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -42,11 +43,10 @@ public class BaseAttributeFilter implements
NotificationFilter {
// ----------------------------------------------------------- Constructors
/**
- * Construct a new filter that accepts only the specified attribute
- * name.
+ * Construct a new filter that accepts only the specified attribute name.
*
- * @param name Name of the attribute to be accepted by this filter, or
- * <code>null</code> to accept all attribute names
+ * @param name Name of the attribute to be accepted by this filter, or
<code>null</code> to accept all attribute
+ * names
*/
public BaseAttributeFilter(String name) {
@@ -62,8 +62,8 @@ public class BaseAttributeFilter implements
NotificationFilter {
/**
- * The set of attribute names that are accepted by this filter. If this
- * list is empty, all attribute names are accepted.
+ * The set of attribute names that are accepted by this filter. If this
list is empty, all attribute names are
+ * accepted.
*/
private final Set<String> names = new HashSet<>();
@@ -86,8 +86,7 @@ public class BaseAttributeFilter implements
NotificationFilter {
/**
- * Clear all accepted names from this filter, so that it will accept
- * all attribute names.
+ * Clear all accepted names from this filter, so that it will accept all
attribute names.
*/
public void clear() {
@@ -99,9 +98,9 @@ public class BaseAttributeFilter implements
NotificationFilter {
/**
- * Return the set of names that are accepted by this filter. If this
- * filter accepts all attribute names, a zero length array will be
- * returned.
+ * Return the set of names that are accepted by this filter. If this
filter accepts all attribute names, a zero
+ * length array will be returned.
+ *
* @return the array of names
*/
public String[] getNames() {
@@ -114,13 +113,13 @@ public class BaseAttributeFilter implements
NotificationFilter {
/**
- * <p>Test whether notification enabled for this event.
- * Return true if:</p>
+ * <p>
+ * Test whether notification enabled for this event. Return true if:
+ * </p>
* <ul>
* <li>This is an attribute change notification</li>
- * <li>Either the set of accepted names is empty (implying that all
- * attribute names are of interest) or the set of accepted names
- * includes the name of the attribute in this notification</li>
+ * <li>Either the set of accepted names is empty (implying that all
attribute names are of interest) or the set of
+ * accepted names includes the name of the attribute in this
notification</li>
* </ul>
*/
@Override
@@ -147,8 +146,7 @@ public class BaseAttributeFilter implements
NotificationFilter {
/**
- * Remove an attribute name from the set of names accepted by this
- * filter.
+ * Remove an attribute name from the set of names accepted by this filter.
*
* @param name Name of the attribute to be removed
*/
diff --git a/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
b/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
index f0ebc5da18..f805264125 100644
--- a/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
+++ b/java/org/apache/tomcat/util/modeler/BaseModelMBean.java
@@ -70,43 +70,40 @@ import org.apache.tomcat.util.res.StringManager;
*/
/**
- * <p>Basic implementation of the <code>DynamicMBean</code> interface, which
- * supports the minimal requirements of the interface contract.</p>
- *
- * <p>This can be used directly to wrap an existing java bean, or inside
- * a mlet or anywhere an MBean would be used.
+ * <p>
+ * Basic implementation of the <code>DynamicMBean</code> interface, which
supports the minimal requirements of the
+ * interface contract.
+ * </p>
+ * <p>
+ * This can be used directly to wrap an existing java bean, or inside a mlet
or anywhere an MBean would be used.
* <p>
* Limitations:
* <ul>
- * <li>Only managed resources of type <code>objectReference</code> are
- * supported.</li>
- * <li>Caching of attribute values and operation results is not supported.
- * All calls to <code>invoke()</code> are immediately executed.</li>
+ * <li>Only managed resources of type <code>objectReference</code> are
supported.</li>
+ * <li>Caching of attribute values and operation results is not supported. All
calls to <code>invoke()</code> are
+ * immediately executed.</li>
* <li>Persistence of MBean attributes and operations is not supported.</li>
- * <li>All classes referenced as attribute types, operation parameters, or
- * operation return values must be one of the following:
- * <ul>
- * <li>One of the Java primitive types (boolean, byte, char, double,
- * float, integer, long, short). Corresponding value will be wrapped
- * in the appropriate wrapper class automatically.</li>
- * <li>Operations that return no value should declare a return type of
- * <code>void</code>.</li>
- * </ul>
+ * <li>All classes referenced as attribute types, operation parameters, or
operation return values must be one of the
+ * following:
+ * <ul>
+ * <li>One of the Java primitive types (boolean, byte, char, double, float,
integer, long, short). Corresponding value
+ * will be wrapped in the appropriate wrapper class automatically.</li>
+ * <li>Operations that return no value should declare a return type of
<code>void</code>.</li>
+ * </ul>
* <li>Attribute caching is not supported</li>
* </ul>
*
* @author Craig R. McClanahan
* @author Costin Manolache
*/
-public class BaseModelMBean implements DynamicMBean, MBeanRegistration,
- ModelMBeanNotificationBroadcaster {
+public class BaseModelMBean implements DynamicMBean, MBeanRegistration,
ModelMBeanNotificationBroadcaster {
private static final Log log = LogFactory.getLog(BaseModelMBean.class);
private static final StringManager sm =
StringManager.getManager(BaseModelMBean.class);
// ----------------------------------------------------- Instance Variables
- protected ObjectName oname=null;
+ protected ObjectName oname = null;
/**
* Notification broadcaster for attribute changes.
@@ -135,34 +132,31 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
protected String resourceType = null;
// key: operation val: invoke method
- //private Hashtable invokeAttMap=new Hashtable();
+ // private Hashtable invokeAttMap=new Hashtable();
@Override
- public Object getAttribute(String name)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
+ public Object getAttribute(String name) throws AttributeNotFoundException,
MBeanException, ReflectionException {
// Validate the input parameters
if (name == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeName")),
- sm.getString("baseModelMBean.nullAttributeName"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeName")),
+ sm.getString("baseModelMBean.nullAttributeName"));
}
- if( (resource instanceof DynamicMBean) &&
- ! ( resource instanceof BaseModelMBean )) {
- return ((DynamicMBean)resource).getAttribute(name);
+ if ((resource instanceof DynamicMBean) && !(resource instanceof
BaseModelMBean)) {
+ return ((DynamicMBean) resource).getAttribute(name);
}
- Method m=managedBean.getGetter(name, this, resource);
+ Method m = managedBean.getGetter(name, this, resource);
Object result;
try {
Class<?> declaring = m.getDeclaringClass();
// workaround for catalina weird mbeans - the declaring class is
BaseModelMBean.
// but this is the catalina class.
- if( declaring.isAssignableFrom(this.getClass()) ) {
- result = m.invoke(this, NO_ARGS_PARAM );
+ if (declaring.isAssignableFrom(this.getClass())) {
+ result = m.invoke(this, NO_ARGS_PARAM);
} else {
- result = m.invoke(resource, NO_ARGS_PARAM );
+ result = m.invoke(resource, NO_ARGS_PARAM);
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
@@ -170,18 +164,15 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
t = e;
}
if (t instanceof RuntimeException) {
- throw new RuntimeOperationsException
- ((RuntimeException) t,
sm.getString("baseModelMBean.invokeError", name));
+ throw new RuntimeOperationsException((RuntimeException) t,
+ sm.getString("baseModelMBean.invokeError", name));
} else if (t instanceof Error) {
- throw new RuntimeErrorException
- ((Error) t, sm.getString("baseModelMBean.invokeError",
name));
+ throw new RuntimeErrorException((Error) t,
sm.getString("baseModelMBean.invokeError", name));
} else {
- throw new MBeanException
- (e, sm.getString("baseModelMBean.invokeError", name));
+ throw new MBeanException(e,
sm.getString("baseModelMBean.invokeError", name));
}
} catch (Exception e) {
- throw new MBeanException
- (e, sm.getString("baseModelMBean.invokeError", name));
+ throw new MBeanException(e,
sm.getString("baseModelMBean.invokeError", name));
}
// Return the results of this method invocation
@@ -194,9 +185,9 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
// Validate the input parameters
if (names == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeNameList")),
- sm.getString("baseModelMBean.nullAttributeNameList"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeNameList")),
+ sm.getString("baseModelMBean.nullAttributeNameList"));
}
// Prepare our response, eating all exceptions
@@ -228,27 +219,25 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
/**
* {@inheritDoc}
- * <p><strong>IMPLEMENTATION NOTE</strong> - This implementation will
- * attempt to invoke this method on the MBean itself, or (if not
- * available) on the managed resource object associated with this
- * MBean.</p>
+ * <p>
+ * <strong>IMPLEMENTATION NOTE</strong> - This implementation will attempt
to invoke this method on the MBean
+ * itself, or (if not available) on the managed resource object associated
with this MBean.
+ * </p>
*/
@Override
- public Object invoke(String name, Object[] params, String[] signature)
- throws MBeanException, ReflectionException {
- if ((resource instanceof DynamicMBean) &&
- ! (resource instanceof BaseModelMBean)) {
- return ((DynamicMBean)resource).invoke(name, params, signature);
+ public Object invoke(String name, Object[] params, String[] signature)
throws MBeanException, ReflectionException {
+ if ((resource instanceof DynamicMBean) && !(resource instanceof
BaseModelMBean)) {
+ return ((DynamicMBean) resource).invoke(name, params, signature);
}
// Validate the input parameters
if (name == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullMethodName")),
- sm.getString("baseModelMBean.nullMethodName"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullMethodName")),
+ sm.getString("baseModelMBean.nullMethodName"));
}
- if( log.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
log.trace("Invoke " + name);
}
@@ -257,31 +246,28 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
// Invoke the selected method on the appropriate object
Object result;
try {
- if (method.getDeclaringClass().isAssignableFrom( this.getClass()))
{
+ if (method.getDeclaringClass().isAssignableFrom(this.getClass())) {
result = method.invoke(this, params);
} else {
result = method.invoke(resource, params);
}
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
- log.error(sm.getString("baseModelMBean.invokeError", name), t );
+ log.error(sm.getString("baseModelMBean.invokeError", name), t);
if (t == null) {
t = e;
}
if (t instanceof RuntimeException) {
- throw new RuntimeOperationsException
- ((RuntimeException) t,
sm.getString("baseModelMBean.invokeError", name));
+ throw new RuntimeOperationsException((RuntimeException) t,
+ sm.getString("baseModelMBean.invokeError", name));
} else if (t instanceof Error) {
- throw new RuntimeErrorException
- ((Error) t, sm.getString("baseModelMBean.invokeError",
name));
+ throw new RuntimeErrorException((Error) t,
sm.getString("baseModelMBean.invokeError", name));
} else {
- throw new MBeanException
- ((Exception)t, sm.getString("baseModelMBean.invokeError",
name));
+ throw new MBeanException((Exception) t,
sm.getString("baseModelMBean.invokeError", name));
}
} catch (Exception e) {
- log.error(sm.getString("baseModelMBean.invokeError", name), e );
- throw new MBeanException
- (e, sm.getString("baseModelMBean.invokeError", name));
+ log.error(sm.getString("baseModelMBean.invokeError", name), e);
+ throw new MBeanException(e,
sm.getString("baseModelMBean.invokeError", name));
}
// Return the results of this method invocation
@@ -289,8 +275,7 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
}
- static Class<?> getAttributeClass(String signature)
- throws ReflectionException {
+ static Class<?> getAttributeClass(String signature) throws
ReflectionException {
if (signature.equals(Boolean.TYPE.getName())) {
return Boolean.TYPE;
} else if (signature.equals(Byte.TYPE.getName())) {
@@ -310,10 +295,10 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
} else {
try {
ClassLoader cl =
Thread.currentThread().getContextClassLoader();
- if (cl!=null) {
+ if (cl != null) {
return cl.loadClass(signature);
}
- } catch(ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
// Ignore
}
try {
@@ -326,16 +311,14 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
public void setAttribute(Attribute attribute)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
- if( log.isTraceEnabled() ) {
- log.trace("Setting attribute " + this + " " + attribute );
+ throws AttributeNotFoundException, MBeanException,
ReflectionException {
+ if (log.isTraceEnabled()) {
+ log.trace("Setting attribute " + this + " " + attribute);
}
- if( (resource instanceof DynamicMBean) &&
- ! ( resource instanceof BaseModelMBean )) {
+ if ((resource instanceof DynamicMBean) && !(resource instanceof
BaseModelMBean)) {
try {
- ((DynamicMBean)resource).setAttribute(attribute);
+ ((DynamicMBean) resource).setAttribute(attribute);
} catch (InvalidAttributeValueException e) {
throw new MBeanException(e);
}
@@ -344,28 +327,28 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
// Validate the input parameters
if (attribute == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttribute")),
- sm.getString("baseModelMBean.nullAttribute"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttribute")),
+ sm.getString("baseModelMBean.nullAttribute"));
}
String name = attribute.getName();
Object value = attribute.getValue();
if (name == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeName")),
- sm.getString("baseModelMBean.nullAttributeName"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullAttributeName")),
+ sm.getString("baseModelMBean.nullAttributeName"));
}
- Object oldValue=null;
- //if( getAttMap.get(name) != null )
- // oldValue=getAttribute( name );
+ Object oldValue = null;
+ // if( getAttMap.get(name) != null )
+ // oldValue=getAttribute( name );
- Method m=managedBean.getSetter(name,this,resource);
+ Method m = managedBean.getSetter(name, this, resource);
try {
- if( m.getDeclaringClass().isAssignableFrom( this.getClass()) ) {
+ if (m.getDeclaringClass().isAssignableFrom(this.getClass())) {
m.invoke(this, value);
} else {
m.invoke(resource, value);
@@ -376,36 +359,32 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
t = e;
}
if (t instanceof RuntimeException) {
- throw new RuntimeOperationsException
- ((RuntimeException) t,
sm.getString("baseModelMBean.invokeError", name));
+ throw new RuntimeOperationsException((RuntimeException) t,
+ sm.getString("baseModelMBean.invokeError", name));
} else if (t instanceof Error) {
- throw new RuntimeErrorException
- ((Error) t, sm.getString("baseModelMBean.invokeError",
name));
+ throw new RuntimeErrorException((Error) t,
sm.getString("baseModelMBean.invokeError", name));
} else {
- throw new MBeanException
- (e, sm.getString("baseModelMBean.invokeError", name));
+ throw new MBeanException(e,
sm.getString("baseModelMBean.invokeError", name));
}
} catch (Exception e) {
- log.error(sm.getString("baseModelMBean.invokeError", name) , e );
- throw new MBeanException
- (e, sm.getString("baseModelMBean.invokeError", name));
+ log.error(sm.getString("baseModelMBean.invokeError", name), e);
+ throw new MBeanException(e,
sm.getString("baseModelMBean.invokeError", name));
}
try {
- sendAttributeChangeNotification(new Attribute( name, oldValue),
- attribute);
- } catch(Exception ex) {
+ sendAttributeChangeNotification(new Attribute(name, oldValue),
attribute);
+ } catch (Exception ex) {
log.error(sm.getString("baseModelMBean.notificationError", name),
ex);
}
- //attributes.put( name, value );
-// if( source != null ) {
-// // this mbean is associated with a source - maybe we want to
persist
-// source.updateField(oname, name, value);
-// }
+ // attributes.put( name, value );
+ // if( source != null ) {
+ // // this mbean is associated with a source - maybe we want to persist
+ // source.updateField(oname, name, value);
+ // }
}
@Override
public String toString() {
- if( resource==null ) {
+ if (resource == null) {
return "BaseModelMbean[" + resourceType + "]";
}
return resource.toString();
@@ -442,27 +421,24 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
/**
- * Get the instance handle of the object against which we execute
- * all methods in this ModelMBean management interface.
+ * Get the instance handle of the object against which we execute all
methods in this ModelMBean management
+ * interface.
*
* @return the backend managed object
- * @exception InstanceNotFoundException if the managed resource object
- * cannot be found
- * @exception InvalidTargetObjectTypeException if the managed resource
- * object is of the wrong type
- * @exception MBeanException if the initializer of the object throws
- * an exception
- * @exception RuntimeOperationsException if the managed resource or the
- * resource type is <code>null</code> or invalid
+ *
+ * @exception InstanceNotFoundException if the managed resource
object cannot be found
+ * @exception InvalidTargetObjectTypeException if the managed resource
object is of the wrong type
+ * @exception MBeanException if the initializer of the
object throws an exception
+ * @exception RuntimeOperationsException if the managed resource or
the resource type is <code>null</code> or
+ * invalid
*/
- public Object getManagedResource()
- throws InstanceNotFoundException, InvalidTargetObjectTypeException,
- MBeanException, RuntimeOperationsException {
+ public Object getManagedResource() throws InstanceNotFoundException,
InvalidTargetObjectTypeException,
+ MBeanException, RuntimeOperationsException {
if (resource == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullResource")),
- sm.getString("baseModelMBean.nullResource"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullResource")),
+ sm.getString("baseModelMBean.nullResource"));
}
return resource;
@@ -471,51 +447,44 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
/**
- * Set the instance handle of the object against which we will execute
- * all methods in this ModelMBean management interface.
- * The caller can provide the mbean instance or the object name to
- * the resource, if needed.
+ * Set the instance handle of the object against which we will execute all
methods in this ModelMBean management
+ * interface. The caller can provide the mbean instance or the object name
to the resource, if needed.
*
* @param resource The resource object to be managed
- * @param type The type of reference for the managed resource
- * ("ObjectReference", "Handle", "IOR", "EJBHandle", or
- * "RMIReference")
+ * @param type The type of reference for the managed resource
("ObjectReference", "Handle", "IOR", "EJBHandle",
+ * or "RMIReference")
*
- * @exception InstanceNotFoundException if the managed resource object
- * cannot be found
- * @exception MBeanException if the initializer of the object throws
- * an exception
- * @exception RuntimeOperationsException if the managed resource or the
- * resource type is <code>null</code> or invalid
+ * @exception InstanceNotFoundException if the managed resource object
cannot be found
+ * @exception MBeanException if the initializer of the object
throws an exception
+ * @exception RuntimeOperationsException if the managed resource or the
resource type is <code>null</code> or
+ * invalid
*/
public void setManagedResource(Object resource, String type)
- throws InstanceNotFoundException,
- MBeanException, RuntimeOperationsException
- {
+ throws InstanceNotFoundException, MBeanException,
RuntimeOperationsException {
if (resource == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullResource")),
- sm.getString("baseModelMBean.nullResource"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullResource")),
+ sm.getString("baseModelMBean.nullResource"));
}
-// if (!"objectreference".equalsIgnoreCase(type))
-// throw new InvalidTargetObjectTypeException(type);
+ // if (!"objectreference".equalsIgnoreCase(type))
+ // throw new InvalidTargetObjectTypeException(type);
this.resource = resource;
this.resourceType = resource.getClass().getName();
-// // Make the resource aware of the model mbean.
-// try {
-// Method m=resource.getClass().getMethod("setModelMBean",
-// new Class[] {ModelMBean.class});
-// if( m!= null ) {
-// m.invoke(resource, new Object[] {this});
-// }
-// } catch( NoSuchMethodException t ) {
-// // ignore
-// } catch( Throwable t ) {
-// log.error( "Can't set model mbean ", t );
-// }
+ // // Make the resource aware of the model mbean.
+ // try {
+ // Method m=resource.getClass().getMethod("setModelMBean",
+ // new Class[] {ModelMBean.class});
+ // if( m!= null ) {
+ // m.invoke(resource, new Object[] {this});
+ // }
+ // } catch( NoSuchMethodException t ) {
+ // // ignore
+ // } catch( Throwable t ) {
+ // log.error( "Can't set model mbean ", t );
+ // }
}
@@ -523,9 +492,8 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void addAttributeChangeNotificationListener
- (NotificationListener listener, String name, Object handback)
- throws IllegalArgumentException {
+ public void addAttributeChangeNotificationListener(NotificationListener
listener, String name, Object handback)
+ throws IllegalArgumentException {
if (listener == null) {
throw new
IllegalArgumentException(sm.getString("baseModelMBean.nullListener"));
@@ -534,21 +502,19 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
attributeBroadcaster = new BaseNotificationBroadcaster();
}
- if( log.isTraceEnabled() ) {
+ if (log.isTraceEnabled()) {
log.trace("addAttributeNotificationListener " + listener);
}
BaseAttributeFilter filter = new BaseAttributeFilter(name);
- attributeBroadcaster.addNotificationListener
- (listener, filter, handback);
+ attributeBroadcaster.addNotificationListener(listener, filter,
handback);
}
@Override
- public void removeAttributeChangeNotificationListener
- (NotificationListener listener, String name)
- throws ListenerNotFoundException {
+ public void removeAttributeChangeNotificationListener(NotificationListener
listener, String name)
+ throws ListenerNotFoundException {
if (listener == null) {
throw new
IllegalArgumentException(sm.getString("baseModelMBean.nullListener"));
@@ -563,21 +529,19 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void sendAttributeChangeNotification
- (AttributeChangeNotification notification)
- throws MBeanException, RuntimeOperationsException {
+ public void sendAttributeChangeNotification(AttributeChangeNotification
notification)
+ throws MBeanException, RuntimeOperationsException {
if (notification == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullNotification")),
- sm.getString("baseModelMBean.nullNotification"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullNotification")),
+ sm.getString("baseModelMBean.nullNotification"));
}
- if (attributeBroadcaster == null)
- {
+ if (attributeBroadcaster == null) {
return; // This means there are no registered listeners
}
- if( log.isTraceEnabled() ) {
- log.trace( "AttributeChangeNotification " + notification );
+ if (log.isTraceEnabled()) {
+ log.trace("AttributeChangeNotification " + notification);
}
attributeBroadcaster.sendNotification(notification);
@@ -585,9 +549,8 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void sendAttributeChangeNotification
- (Attribute oldValue, Attribute newValue)
- throws MBeanException, RuntimeOperationsException {
+ public void sendAttributeChangeNotification(Attribute oldValue, Attribute
newValue)
+ throws MBeanException, RuntimeOperationsException {
// Calculate the class name for the change notification
String type;
@@ -595,33 +558,26 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
type = newValue.getValue().getClass().getName();
} else if (oldValue.getValue() != null) {
type = oldValue.getValue().getClass().getName();
- }
- else {
- return; // Old and new are both null == no change
+ } else {
+ return; // Old and new are both null == no change
}
- AttributeChangeNotification notification =
- new AttributeChangeNotification
- (this, 1, System.currentTimeMillis(),
- "Attribute value has changed",
- oldValue.getName(), type,
- oldValue.getValue(), newValue.getValue());
+ AttributeChangeNotification notification = new
AttributeChangeNotification(this, 1, System.currentTimeMillis(),
+ "Attribute value has changed", oldValue.getName(), type,
oldValue.getValue(), newValue.getValue());
sendAttributeChangeNotification(notification);
}
@Override
- public void sendNotification(Notification notification)
- throws MBeanException, RuntimeOperationsException {
+ public void sendNotification(Notification notification) throws
MBeanException, RuntimeOperationsException {
if (notification == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullNotification")),
- sm.getString("baseModelMBean.nullNotification"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullNotification")),
+ sm.getString("baseModelMBean.nullNotification"));
}
- if (generalBroadcaster == null)
- {
+ if (generalBroadcaster == null) {
return; // This means there are no registered listeners
}
generalBroadcaster.sendNotification(notification);
@@ -630,16 +586,14 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void sendNotification(String message)
- throws MBeanException, RuntimeOperationsException {
+ public void sendNotification(String message) throws MBeanException,
RuntimeOperationsException {
if (message == null) {
- throw new RuntimeOperationsException
- (new
IllegalArgumentException(sm.getString("baseModelMBean.nullMessage")),
- sm.getString("baseModelMBean.nullMessage"));
+ throw new RuntimeOperationsException(
+ new
IllegalArgumentException(sm.getString("baseModelMBean.nullMessage")),
+ sm.getString("baseModelMBean.nullMessage"));
}
- Notification notification = new Notification
- ("jmx.modelmbean.generic", this, 1, message);
+ Notification notification = new Notification("jmx.modelmbean.generic",
this, 1, message);
sendNotification(notification);
}
@@ -649,24 +603,21 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void addNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- throws IllegalArgumentException {
+ public void addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object handback)
+ throws IllegalArgumentException {
if (listener == null) {
throw new
IllegalArgumentException(sm.getString("baseModelMBean.nullListener"));
}
- if( log.isTraceEnabled() ) {
+ if (log.isTraceEnabled()) {
log.trace("addNotificationListener " + listener);
}
if (generalBroadcaster == null) {
generalBroadcaster = new BaseNotificationBroadcaster();
}
- generalBroadcaster.addNotificationListener
- (listener, filter, handback);
+ generalBroadcaster.addNotificationListener(listener, filter, handback);
// We'll send the attribute change notifications to all listeners (
who care )
// The normal filtering can be used.
@@ -676,12 +627,11 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
attributeBroadcaster = new BaseNotificationBroadcaster();
}
- if( log.isTraceEnabled() ) {
+ if (log.isTraceEnabled()) {
log.trace("addAttributeNotificationListener " + listener);
}
- attributeBroadcaster.addNotificationListener
- (listener, filter, handback);
+ attributeBroadcaster.addNotificationListener(listener, filter,
handback);
}
@@ -690,35 +640,30 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
// Acquire the set of application notifications
MBeanNotificationInfo[] current = getMBeanInfo().getNotifications();
- MBeanNotificationInfo[] response =
- new MBeanNotificationInfo[current.length + 2];
- // Descriptor descriptor = null;
+ MBeanNotificationInfo[] response = new
MBeanNotificationInfo[current.length + 2];
+ // Descriptor descriptor = null;
// Fill in entry for general notifications
-// descriptor = new DescriptorSupport
-// (new String[] { "name=GENERIC",
-// "descriptorType=notification",
-// "log=T",
-// "severity=5",
-// "displayName=jmx.modelmbean.generic" });
- response[0] = new MBeanNotificationInfo
- (new String[] { "jmx.modelmbean.generic" },
- "GENERIC",
- "Text message notification from the managed resource");
- //descriptor);
+ // descriptor = new DescriptorSupport
+ // (new String[] { "name=GENERIC",
+ // "descriptorType=notification",
+ // "log=T",
+ // "severity=5",
+ // "displayName=jmx.modelmbean.generic" });
+ response[0] = new MBeanNotificationInfo(new String[] {
"jmx.modelmbean.generic" }, "GENERIC",
+ "Text message notification from the managed resource");
+ // descriptor);
// Fill in entry for attribute change notifications
-// descriptor = new DescriptorSupport
-// (new String[] { "name=ATTRIBUTE_CHANGE",
-// "descriptorType=notification",
-// "log=T",
-// "severity=5",
-// "displayName=jmx.attribute.change" });
- response[1] = new MBeanNotificationInfo
- (new String[] { "jmx.attribute.change" },
- "ATTRIBUTE_CHANGE",
- "Observed MBean attribute value has changed");
- //descriptor);
+ // descriptor = new DescriptorSupport
+ // (new String[] { "name=ATTRIBUTE_CHANGE",
+ // "descriptorType=notification",
+ // "log=T",
+ // "severity=5",
+ // "displayName=jmx.attribute.change" });
+ response[1] = new MBeanNotificationInfo(new String[] {
"jmx.attribute.change" }, "ATTRIBUTE_CHANGE",
+ "Observed MBean attribute value has changed");
+ // descriptor);
// Copy remaining notifications as reported by the application
System.arraycopy(current, 0, response, 2, current.length);
@@ -728,8 +673,7 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
@Override
- public void removeNotificationListener(NotificationListener listener)
- throws ListenerNotFoundException {
+ public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
if (listener == null) {
throw new
IllegalArgumentException(sm.getString("baseModelMBean.nullListener"));
@@ -742,7 +686,7 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
if (attributeBroadcaster != null) {
attributeBroadcaster.removeNotificationListener(listener);
}
- }
+ }
public String getModelerType() {
@@ -769,43 +713,40 @@ public class BaseModelMBean implements DynamicMBean,
MBeanRegistration,
}
- // -------------------- Registration --------------------
+ // -------------------- Registration --------------------
// XXX We can add some method patterns here- like setName() and
// setDomain() for code that doesn't implement the Registration
@Override
- public ObjectName preRegister(MBeanServer server,
- ObjectName name)
- throws Exception
- {
- if( log.isTraceEnabled()) {
- log.trace("preRegister " + resource + " " + name );
+ public ObjectName preRegister(MBeanServer server, ObjectName name) throws
Exception {
+ if (log.isTraceEnabled()) {
+ log.trace("preRegister " + resource + " " + name);
}
- oname=name;
- if( resource instanceof MBeanRegistration ) {
- oname = ((MBeanRegistration)resource).preRegister(server, name );
+ oname = name;
+ if (resource instanceof MBeanRegistration) {
+ oname = ((MBeanRegistration) resource).preRegister(server, name);
}
return oname;
}
@Override
public void postRegister(Boolean registrationDone) {
- if( resource instanceof MBeanRegistration ) {
- ((MBeanRegistration)resource).postRegister(registrationDone);
+ if (resource instanceof MBeanRegistration) {
+ ((MBeanRegistration) resource).postRegister(registrationDone);
}
}
@Override
public void preDeregister() throws Exception {
- if( resource instanceof MBeanRegistration ) {
- ((MBeanRegistration)resource).preDeregister();
+ if (resource instanceof MBeanRegistration) {
+ ((MBeanRegistration) resource).preDeregister();
}
}
@Override
public void postDeregister() {
- if( resource instanceof MBeanRegistration ) {
- ((MBeanRegistration)resource).postDeregister();
+ if (resource instanceof MBeanRegistration) {
+ ((MBeanRegistration) resource).postDeregister();
}
}
}
diff --git
a/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
b/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
index 98bbfb2137..53289517b4 100644
--- a/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
+++ b/java/org/apache/tomcat/util/modeler/BaseNotificationBroadcaster.java
@@ -28,9 +28,8 @@ import javax.management.NotificationListener;
/**
- * Implementation of <code>NotificationBroadcaster</code> for attribute
- * change notifications. This class is used by <code>BaseModelMBean</code> to
- * handle notifications of attribute change events to interested listeners.
+ * Implementation of <code>NotificationBroadcaster</code> for attribute change
notifications. This class is used by
+ * <code>BaseModelMBean</code> to handle notifications of attribute change
events to interested listeners.
*
* @author Craig R. McClanahan
* @author Costin Manolache
@@ -46,11 +45,9 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
/**
- * The set of registered <code>BaseNotificationBroadcasterEntry</code>
- * entries.
+ * The set of registered <code>BaseNotificationBroadcasterEntry</code>
entries.
*/
- final ArrayList<BaseNotificationBroadcasterEntry> entries =
- new ArrayList<>();
+ final ArrayList<BaseNotificationBroadcasterEntry> entries = new
ArrayList<>();
// --------------------------------------------------------- Public Methods
@@ -60,27 +57,23 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
* Add a notification event listener to this MBean.
*
* @param listener Listener that will receive event notifications
- * @param filter Filter object used to filter event notifications
- * actually delivered, or <code>null</code> for no filtering
- * @param handback object to be sent along with event
- * notifications
+ * @param filter Filter object used to filter event notifications
actually delivered, or <code>null</code> for no
+ * filtering
+ * @param handback object to be sent along with event notifications
*
* @exception IllegalArgumentException if the listener parameter is null
*/
@Override
- public void addNotificationListener(NotificationListener listener,
- NotificationFilter filter,
- Object handback)
- throws IllegalArgumentException {
+ public void addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object handback)
+ throws IllegalArgumentException {
synchronized (entries) {
// Optimization to coalesce attribute name filters
if (filter instanceof BaseAttributeFilter newFilter) {
for (BaseNotificationBroadcasterEntry item : entries) {
- if ((item.listener == listener) &&
- (item.filter instanceof BaseAttributeFilter oldFilter)
&&
- (item.handback == handback)) {
+ if ((item.listener == listener) && (item.filter instanceof
BaseAttributeFilter oldFilter) &&
+ (item.handback == handback)) {
String[] newNames = newFilter.getNames();
String[] oldNames = oldFilter.getNames();
if (newNames.length == 0) {
@@ -98,16 +91,14 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
}
// General purpose addition of a new entry
- entries.add(new BaseNotificationBroadcasterEntry
- (listener, filter, handback));
+ entries.add(new BaseNotificationBroadcasterEntry(listener, filter,
handback));
}
}
/**
- * Return an <code>MBeanNotificationInfo</code> object describing the
- * notifications sent by this MBean.
+ * Return an <code>MBeanNotificationInfo</code> object describing the
notifications sent by this MBean.
*/
@Override
public MBeanNotificationInfo[] getNotificationInfo() {
@@ -118,15 +109,12 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
/**
* Remove a notification event listener from this MBean.
*
- * @param listener The listener to be removed (any and all registrations
- * for this listener will be eliminated)
+ * @param listener The listener to be removed (any and all registrations
for this listener will be eliminated)
*
- * @exception ListenerNotFoundException if this listener is not
- * registered in the MBean
+ * @exception ListenerNotFoundException if this listener is not registered
in the MBean
*/
@Override
- public void removeNotificationListener(NotificationListener listener)
- throws ListenerNotFoundException {
+ public void removeNotificationListener(NotificationListener listener)
throws ListenerNotFoundException {
synchronized (entries) {
entries.removeIf(item -> item.listener == listener);
@@ -144,8 +132,7 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
synchronized (entries) {
for (BaseNotificationBroadcasterEntry item : entries) {
- if ((item.filter != null) &&
- (!item.filter.isNotificationEnabled(notification))) {
+ if ((item.filter != null) &&
(!item.filter.isNotificationEnabled(notification))) {
continue;
}
item.listener.handleNotification(notification, item.handback);
@@ -163,9 +150,7 @@ public class BaseNotificationBroadcaster implements
NotificationBroadcaster {
class BaseNotificationBroadcasterEntry {
- BaseNotificationBroadcasterEntry(NotificationListener listener,
- NotificationFilter filter,
- Object handback) {
+ BaseNotificationBroadcasterEntry(NotificationListener listener,
NotificationFilter filter, Object handback) {
this.listener = listener;
this.filter = filter;
this.handback = handback;
diff --git a/java/org/apache/tomcat/util/modeler/FeatureInfo.java
b/java/org/apache/tomcat/util/modeler/FeatureInfo.java
index fc010488c0..8baf549192 100644
--- a/java/org/apache/tomcat/util/modeler/FeatureInfo.java
+++ b/java/org/apache/tomcat/util/modeler/FeatureInfo.java
@@ -24,9 +24,10 @@ import javax.management.MBeanFeatureInfo;
/**
- * <p>Convenience base class for <code>AttributeInfo</code> and
- * <code>OperationInfo</code> classes that will be used to collect
configuration
- * information for the <code>ModelMBean</code> beans exposed for
management.</p>
+ * <p>
+ * Convenience base class for <code>AttributeInfo</code> and
<code>OperationInfo</code> classes that will be used to
+ * collect configuration information for the <code>ModelMBean</code> beans
exposed for management.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -57,8 +58,7 @@ public class FeatureInfo implements Serializable {
/**
- * @return the name of this feature, which must be unique among features
- * in the same collection.
+ * @return the name of this feature, which must be unique among features
in the same collection.
*/
public String getName() {
return this.name;
diff --git a/java/org/apache/tomcat/util/modeler/ManagedBean.java
b/java/org/apache/tomcat/util/modeler/ManagedBean.java
index 23c15fd922..35987e847a 100644
--- a/java/org/apache/tomcat/util/modeler/ManagedBean.java
+++ b/java/org/apache/tomcat/util/modeler/ManagedBean.java
@@ -42,8 +42,9 @@ import org.apache.tomcat.util.res.StringManager;
/**
- * <p>Internal configuration information for a managed bean (MBean)
- * descriptor.</p>
+ * <p>
+ * Internal configuration information for a managed bean (MBean) descriptor.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -60,8 +61,7 @@ public class ManagedBean implements java.io.Serializable {
private final ReadWriteLock mBeanInfoLock = new ReentrantReadWriteLock();
/**
- * The <code>ModelMBeanInfo</code> object that corresponds
- * to this <code>ManagedBean</code> instance.
+ * The <code>ModelMBeanInfo</code> object that corresponds to this
<code>ManagedBean</code> instance.
*/
private transient volatile MBeanInfo info = null;
@@ -82,7 +82,7 @@ public class ManagedBean implements java.io.Serializable {
* Constructor. Will add default attributes.
*/
public ManagedBean() {
- AttributeInfo ai=new AttributeInfo();
+ AttributeInfo ai = new AttributeInfo();
ai.setName("modelerType");
ai.setDescription("Type of the modeled resource. Can be set only
once");
ai.setType("java.lang.String");
@@ -102,10 +102,9 @@ public class ManagedBean implements java.io.Serializable {
/**
- * The fully qualified name of the Java class of the MBean
- * described by this descriptor. If not specified, the standard JMX
- * class (<code>javax.management.modelmbean.RequiredModeLMBean</code>)
- * will be utilized.
+ * The fully qualified name of the Java class of the MBean described by
this descriptor. If not specified, the
+ * standard JMX class
(<code>javax.management.modelmbean.RequiredModeLMBean</code>) will be utilized.
+ *
* @return the class name
*/
public String getClassName() {
@@ -142,8 +141,8 @@ public class ManagedBean implements java.io.Serializable {
/**
- * @return the (optional) <code>ObjectName</code> domain in which
- * this MBean should be registered in the MBeanServer.
+ * @return the (optional) <code>ObjectName</code> domain in which this
MBean should be registered in the
+ * MBeanServer.
*/
public String getDomain() {
return this.domain;
@@ -167,8 +166,8 @@ public class ManagedBean implements java.io.Serializable {
/**
- * @return the name of this managed bean, which must be unique
- * among all MBeans managed by a particular MBeans server.
+ * @return the name of this managed bean, which must be unique among all
MBeans managed by a particular MBeans
+ * server.
*/
public String getName() {
return this.name;
@@ -202,9 +201,8 @@ public class ManagedBean implements java.io.Serializable {
/**
- * @return the fully qualified name of the Java class of the resource
- * implementation class described by the managed bean described
- * by this descriptor.
+ * @return the fully qualified name of the Java class of the resource
implementation class described by the managed
+ * bean described by this descriptor.
*/
public String getType() {
return this.type;
@@ -242,10 +240,8 @@ public class ManagedBean implements java.io.Serializable {
public void addNotification(NotificationInfo notification) {
mBeanInfoLock.writeLock().lock();
try {
- NotificationInfo[] results =
- new NotificationInfo[notifications.length + 1];
- System.arraycopy(notifications, 0, results, 0,
- notifications.length);
+ NotificationInfo[] results = new
NotificationInfo[notifications.length + 1];
+ System.arraycopy(notifications, 0, results, 0,
notifications.length);
results[notifications.length] = notification;
notifications = results;
this.info = null;
@@ -266,30 +262,25 @@ public class ManagedBean implements java.io.Serializable {
/**
- * Create and return a <code>ModelMBean</code> that has been
- * preconfigured with the <code>ModelMBeanInfo</code> information
- * for this managed bean, and is associated with the specified
- * managed object instance. The returned <code>ModelMBean</code>
- * will <strong>NOT</strong> have been registered with our
- * <code>MBeanServer</code>.
+ * Create and return a <code>ModelMBean</code> that has been preconfigured
with the <code>ModelMBeanInfo</code>
+ * information for this managed bean, and is associated with the specified
managed object instance. The returned
+ * <code>ModelMBean</code> will <strong>NOT</strong> have been registered
with our <code>MBeanServer</code>.
+ *
+ * @param instance Instanced of the managed object, or <code>null</code>
for no associated instance
*
- * @param instance Instanced of the managed object, or <code>null</code>
- * for no associated instance
* @return the MBean
- * @exception InstanceNotFoundException if the managed resource
- * object cannot be found
- * @exception MBeanException if a problem occurs instantiating the
- * <code>ModelMBean</code> instance
+ *
+ * @exception InstanceNotFoundException if the managed resource object
cannot be found
+ * @exception MBeanException if a problem occurs instantiating
the <code>ModelMBean</code> instance
* @exception RuntimeOperationsException if a JMX runtime error occurs
*/
public DynamicMBean createMBean(Object instance)
- throws InstanceNotFoundException,
- MBeanException, RuntimeOperationsException {
+ throws InstanceNotFoundException, MBeanException,
RuntimeOperationsException {
BaseModelMBean mbean;
// Load the ModelMBean implementation class
- if(getClassName().equals(BASE_MBEAN)) {
+ if (getClassName().equals(BASE_MBEAN)) {
// Skip introspection
mbean = new BaseModelMBean();
} else {
@@ -301,20 +292,19 @@ public class ManagedBean implements java.io.Serializable {
// Ignore
}
- if( clazz==null ) {
+ if (clazz == null) {
try {
- ClassLoader cl=
Thread.currentThread().getContextClassLoader();
- if ( cl != null) {
- clazz= cl.loadClass(getClassName());
+ ClassLoader cl =
Thread.currentThread().getContextClassLoader();
+ if (cl != null) {
+ clazz = cl.loadClass(getClassName());
}
} catch (Exception e) {
- ex=e;
+ ex = e;
}
}
- if( clazz==null) {
- throw new MBeanException
- (ex, sm.getString("managedMBean.cannotLoadClass",
getClassName()));
+ if (clazz == null) {
+ throw new MBeanException(ex,
sm.getString("managedMBean.cannotLoadClass", getClassName()));
}
try {
// Stupid - this will set the default minfo first....
@@ -322,8 +312,7 @@ public class ManagedBean implements java.io.Serializable {
} catch (RuntimeOperationsException e) {
throw e;
} catch (Exception e) {
- throw new MBeanException
- (e, sm.getString("managedMBean.cannotInstantiateClass",
getClassName()));
+ throw new MBeanException(e,
sm.getString("managedMBean.cannotInstantiateClass", getClassName()));
}
}
@@ -339,8 +328,8 @@ public class ManagedBean implements java.io.Serializable {
/**
- * Create and return a <code>ModelMBeanInfo</code> object that
- * describes this entire managed bean.
+ * Create and return a <code>ModelMBeanInfo</code> object that describes
this entire managed bean.
+ *
* @return the MBean info
*/
MBeanInfo getMBeanInfo() {
@@ -360,35 +349,28 @@ public class ManagedBean implements java.io.Serializable {
if (info == null) {
// Create subordinate information descriptors as required
AttributeInfo[] attrs = getAttributes();
- MBeanAttributeInfo[] attributes =
- new MBeanAttributeInfo[attrs.length];
+ MBeanAttributeInfo[] attributes = new
MBeanAttributeInfo[attrs.length];
for (int i = 0; i < attrs.length; i++) {
attributes[i] = attrs[i].createAttributeInfo();
}
OperationInfo[] opers = getOperations();
- MBeanOperationInfo[] operations =
- new MBeanOperationInfo[opers.length];
+ MBeanOperationInfo[] operations = new
MBeanOperationInfo[opers.length];
for (int i = 0; i < opers.length; i++) {
operations[i] = opers[i].createOperationInfo();
}
NotificationInfo[] notifs = getNotifications();
- MBeanNotificationInfo[] notifications =
- new MBeanNotificationInfo[notifs.length];
+ MBeanNotificationInfo[] notifications = new
MBeanNotificationInfo[notifs.length];
for (int i = 0; i < notifs.length; i++) {
notifications[i] = notifs[i].createNotificationInfo();
}
// Construct and return a new ModelMBeanInfo object
- info = new MBeanInfo(getClassName(),
- getDescription(),
- attributes,
- new MBeanConstructorInfo[] {},
- operations,
- notifications);
+ info = new MBeanInfo(getClassName(), getDescription(),
attributes, new MBeanConstructorInfo[] {},
+ operations, notifications);
}
return info;
@@ -447,7 +429,7 @@ public class ManagedBean implements java.io.Serializable {
try {
object = resource;
m = object.getClass().getMethod(getMethod, NO_ARGS_PARAM_SIG);
- exception=null;
+ exception = null;
} catch (NoSuchMethodException e) {
exception = e;
}
@@ -471,9 +453,9 @@ public class ManagedBean implements java.io.Serializable {
// Look up the actual operation to be used
String setMethod = attrInfo.getSetMethod();
- String argType=attrInfo.getType();
+ String argType = attrInfo.getType();
- Class<?>[] signature = new Class[] { BaseModelMBean.getAttributeClass(
argType ) };
+ Class<?>[] signature = new Class[] {
BaseModelMBean.getAttributeClass(argType) };
Object object;
NoSuchMethodException exception = null;
@@ -487,7 +469,7 @@ public class ManagedBean implements java.io.Serializable {
try {
object = resource;
m = object.getClass().getMethod(setMethod, signature);
- exception=null;
+ exception = null;
} catch (NoSuchMethodException e) {
exception = e;
}
@@ -518,8 +500,7 @@ public class ManagedBean implements java.io.Serializable {
// Acquire the ModelMBeanOperationInfo information for
// the requested operation
- OperationInfo opInfo =
- operations.get(createOperationKey(aname, signature));
+ OperationInfo opInfo = operations.get(createOperationKey(aname,
signature));
if (opInfo == null) {
throw new MBeanException(new
ServiceNotFoundException(sm.getString("managedMBean.noOperation", aname)),
sm.getString("managedMBean.noOperation", aname));
diff --git a/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java
b/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java
index 24829dc8fe..fc53493e7e 100644
--- a/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java
+++ b/java/org/apache/tomcat/util/modeler/NoDescriptorRegistry.java
@@ -46,9 +46,8 @@ import javax.management.ReflectionException;
import javax.management.loading.ClassLoaderRepository;
/**
- * An implementation of the MBean registry that effectively disables MBean
- * registration. This is typically used when low memory footprint is a primary
- * concern.
+ * An implementation of the MBean registry that effectively disables MBean
registration. This is typically used when low
+ * memory footprint is a primary concern.
*/
public class NoDescriptorRegistry extends Registry {
@@ -57,8 +56,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void registerComponent(final Object bean, final String oname, final
String type)
- throws Exception {
+ public void registerComponent(final Object bean, final String oname, final
String type) throws Exception {
// no-op
}
@@ -70,8 +68,8 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void invoke(final List<ObjectName> mbeans, final String operation,
- final boolean failFirst) throws Exception {
+ public void invoke(final List<ObjectName> mbeans, final String operation,
final boolean failFirst)
+ throws Exception {
// no-op
}
@@ -108,15 +106,14 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public ManagedBean findManagedBean(final Object bean, final Class<?>
beanClass,
- final String type) throws Exception {
+ public ManagedBean findManagedBean(final Object bean, final Class<?>
beanClass, final String type)
+ throws Exception {
return null;
}
@Override
- public List<ObjectName> load(final String sourceType, final Object source,
final String param)
- throws Exception {
+ public List<ObjectName> load(final String sourceType, final Object source,
final String param) throws Exception {
return Collections.emptyList();
}
@@ -128,8 +125,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void registerComponent(final Object bean, final ObjectName oname,
final String type)
- throws Exception {
+ public void registerComponent(final Object bean, final ObjectName oname,
final String type) throws Exception {
// no-op
}
@@ -148,49 +144,45 @@ public class NoDescriptorRegistry extends Registry {
private static class NoJmxMBeanServer implements MBeanServer {
@Override
- public ObjectInstance createMBean(String className, ObjectName name)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, NotCompliantMBeanException {
+ public ObjectInstance createMBean(String className, ObjectName name)
throws ReflectionException,
+ InstanceAlreadyExistsException, MBeanRegistrationException,
NotCompliantMBeanException {
return null;
}
@Override
public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName)
- throws ReflectionException, InstanceAlreadyExistsException,
- MBeanRegistrationException, NotCompliantMBeanException,
InstanceNotFoundException {
+ throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException,
+ NotCompliantMBeanException, InstanceNotFoundException {
return null;
}
@Override
- public ObjectInstance createMBean(String className, ObjectName name,
Object[] params,
- String[] signature) throws ReflectionException,
InstanceAlreadyExistsException,
- MBeanRegistrationException, NotCompliantMBeanException {
+ public ObjectInstance createMBean(String className, ObjectName name,
Object[] params, String[] signature)
+ throws ReflectionException, InstanceAlreadyExistsException,
MBeanRegistrationException,
+ NotCompliantMBeanException {
return null;
}
@Override
- public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName,
- Object[] params, String[] signature) throws
ReflectionException,
- InstanceAlreadyExistsException, MBeanRegistrationException,
- NotCompliantMBeanException, InstanceNotFoundException {
+ public ObjectInstance createMBean(String className, ObjectName name,
ObjectName loaderName, Object[] params,
+ String[] signature) throws ReflectionException,
InstanceAlreadyExistsException,
+ MBeanRegistrationException, NotCompliantMBeanException,
InstanceNotFoundException {
return null;
}
@Override
public ObjectInstance registerMBean(Object object, ObjectName name)
- throws InstanceAlreadyExistsException,
MBeanRegistrationException,
- NotCompliantMBeanException {
+ throws InstanceAlreadyExistsException,
MBeanRegistrationException, NotCompliantMBeanException {
return null;
}
@Override
- public void unregisterMBean(ObjectName name)
- throws InstanceNotFoundException, MBeanRegistrationException {
+ public void unregisterMBean(ObjectName name) throws
InstanceNotFoundException, MBeanRegistrationException {
}
@@ -226,8 +218,8 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public Object getAttribute(ObjectName name, String attribute) throws
MBeanException,
- AttributeNotFoundException, InstanceNotFoundException,
ReflectionException {
+ public Object getAttribute(ObjectName name, String attribute)
+ throws MBeanException, AttributeNotFoundException,
InstanceNotFoundException, ReflectionException {
return null;
}
@@ -240,9 +232,8 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void setAttribute(ObjectName name, Attribute attribute)
- throws InstanceNotFoundException, AttributeNotFoundException,
- InvalidAttributeValueException, MBeanException,
ReflectionException {
+ public void setAttribute(ObjectName name, Attribute attribute) throws
InstanceNotFoundException,
+ AttributeNotFoundException, InvalidAttributeValueException,
MBeanException, ReflectionException {
}
@@ -255,8 +246,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public Object invoke(ObjectName name, String operationName, Object[]
params,
- String[] signature)
+ public Object invoke(ObjectName name, String operationName, Object[]
params, String[] signature)
throws InstanceNotFoundException, MBeanException,
ReflectionException {
return null;
}
@@ -275,15 +265,15 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void addNotificationListener(ObjectName name,
NotificationListener listener,
- NotificationFilter filter, Object handback) throws
InstanceNotFoundException {
+ public void addNotificationListener(ObjectName name,
NotificationListener listener, NotificationFilter filter,
+ Object handback) throws InstanceNotFoundException {
}
@Override
- public void addNotificationListener(ObjectName name, ObjectName
listener,
- NotificationFilter filter, Object handback) throws
InstanceNotFoundException {
+ public void addNotificationListener(ObjectName name, ObjectName
listener, NotificationFilter filter,
+ Object handback) throws InstanceNotFoundException {
}
@@ -296,9 +286,8 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public void removeNotificationListener(ObjectName name, ObjectName
listener,
- NotificationFilter filter, Object handback)
- throws InstanceNotFoundException, ListenerNotFoundException {
+ public void removeNotificationListener(ObjectName name, ObjectName
listener, NotificationFilter filter,
+ Object handback) throws InstanceNotFoundException,
ListenerNotFoundException {
}
@@ -326,8 +315,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public boolean isInstanceOf(ObjectName name, String className)
- throws InstanceNotFoundException {
+ public boolean isInstanceOf(ObjectName name, String className) throws
InstanceNotFoundException {
return false;
}
@@ -353,8 +341,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public Object instantiate(String className, ObjectName loaderName,
Object[] params,
- String[] signature)
+ public Object instantiate(String className, ObjectName loaderName,
Object[] params, String[] signature)
throws ReflectionException, MBeanException,
InstanceNotFoundException {
return null;
}
@@ -382,8 +369,7 @@ public class NoDescriptorRegistry extends Registry {
@Override
- public ClassLoader getClassLoaderFor(ObjectName mbeanName)
- throws InstanceNotFoundException {
+ public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws
InstanceNotFoundException {
return null;
}
diff --git a/java/org/apache/tomcat/util/modeler/NotificationInfo.java
b/java/org/apache/tomcat/util/modeler/NotificationInfo.java
index 4885d6c9c3..f1f24eccd1 100644
--- a/java/org/apache/tomcat/util/modeler/NotificationInfo.java
+++ b/java/org/apache/tomcat/util/modeler/NotificationInfo.java
@@ -24,8 +24,9 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.management.MBeanNotificationInfo;
/**
- * <p>Internal configuration information for a <code>Notification</code>
- * descriptor.</p>
+ * <p>
+ * Internal configuration information for a <code>Notification</code>
descriptor.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -38,8 +39,8 @@ public class NotificationInfo extends FeatureInfo {
/**
- * The <code>ModelMBeanNotificationInfo</code> object that corresponds
- * to this <code>NotificationInfo</code> instance.
+ * The <code>ModelMBeanNotificationInfo</code> object that corresponds to
this <code>NotificationInfo</code>
+ * instance.
*/
transient MBeanNotificationInfo info = null;
protected String[] notifTypes = new String[0];
@@ -112,8 +113,9 @@ public class NotificationInfo extends FeatureInfo {
/**
- * Create and return a <code>ModelMBeanNotificationInfo</code> object that
- * corresponds to the attribute described by this instance.
+ * Create and return a <code>ModelMBeanNotificationInfo</code> object that
corresponds to the attribute described by
+ * this instance.
+ *
* @return the notification info
*/
public MBeanNotificationInfo createNotificationInfo() {
@@ -124,11 +126,10 @@ public class NotificationInfo extends FeatureInfo {
}
// Create and return a new information object
- info = new MBeanNotificationInfo
- (getNotifTypes(), getName(), getDescription());
- //Descriptor descriptor = info.getDescriptor();
- //addFields(descriptor);
- //info.setDescriptor(descriptor);
+ info = new MBeanNotificationInfo(getNotifTypes(), getName(),
getDescription());
+ // Descriptor descriptor = info.getDescriptor();
+ // addFields(descriptor);
+ // info.setDescriptor(descriptor);
return info;
}
diff --git a/java/org/apache/tomcat/util/modeler/OperationInfo.java
b/java/org/apache/tomcat/util/modeler/OperationInfo.java
index 003b506e02..a76fc0623c 100644
--- a/java/org/apache/tomcat/util/modeler/OperationInfo.java
+++ b/java/org/apache/tomcat/util/modeler/OperationInfo.java
@@ -26,8 +26,9 @@ import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
/**
- * <p>Internal configuration information for an <code>Operation</code>
- * descriptor.</p>
+ * <p>
+ * Internal configuration information for an <code>Operation</code> descriptor.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -57,9 +58,8 @@ public class OperationInfo extends FeatureInfo {
// ------------------------------------------------------------- Properties
/**
- * @return the "impact" of this operation, which should be
- * a (case-insensitive) string value "ACTION", "ACTION_INFO",
- * "INFO", or "UNKNOWN".
+ * @return the "impact" of this operation, which should be a
(case-insensitive) string value "ACTION",
+ * "ACTION_INFO", "INFO", or "UNKNOWN".
*/
public String getImpact() {
return this.impact;
@@ -75,8 +75,7 @@ public class OperationInfo extends FeatureInfo {
/**
- * @return the role of this operation ("getter", "setter", "operation", or
- * "constructor").
+ * @return the role of this operation ("getter", "setter", "operation", or
"constructor").
*/
public String getRole() {
return this.role;
@@ -88,11 +87,10 @@ public class OperationInfo extends FeatureInfo {
/**
- * @return the fully qualified Java class name of the return type for this
- * operation.
+ * @return the fully qualified Java class name of the return type for this
operation.
*/
public String getReturnType() {
- if(type == null) {
+ if (type == null) {
type = "void";
}
return type;
@@ -140,8 +138,9 @@ public class OperationInfo extends FeatureInfo {
/**
- * Create and return a <code>ModelMBeanOperationInfo</code> object that
- * corresponds to the attribute described by this instance.
+ * Create and return a <code>ModelMBeanOperationInfo</code> object that
corresponds to the attribute described by
+ * this instance.
+ *
* @return the operation info
*/
MBeanOperationInfo createOperationInfo() {
@@ -158,17 +157,15 @@ public class OperationInfo extends FeatureInfo {
impact = MBeanOperationInfo.INFO;
}
- info = new MBeanOperationInfo(getName(), getDescription(),
- getMBeanParameterInfo(),
- getReturnType(), impact);
+ info = new MBeanOperationInfo(getName(), getDescription(),
getMBeanParameterInfo(), getReturnType(),
+ impact);
}
- return (MBeanOperationInfo)info;
+ return (MBeanOperationInfo) info;
}
protected MBeanParameterInfo[] getMBeanParameterInfo() {
ParameterInfo[] params = getSignature();
- MBeanParameterInfo[] parameters =
- new MBeanParameterInfo[params.length];
+ MBeanParameterInfo[] parameters = new
MBeanParameterInfo[params.length];
for (int i = 0; i < params.length; i++) {
parameters[i] = params[i].createParameterInfo();
}
diff --git a/java/org/apache/tomcat/util/modeler/ParameterInfo.java
b/java/org/apache/tomcat/util/modeler/ParameterInfo.java
index 0d2454d790..730a85fdf1 100644
--- a/java/org/apache/tomcat/util/modeler/ParameterInfo.java
+++ b/java/org/apache/tomcat/util/modeler/ParameterInfo.java
@@ -22,8 +22,9 @@ import java.io.Serial;
import javax.management.MBeanParameterInfo;
/**
- * <p>Internal configuration information for a <code>Parameter</code>
- * descriptor.</p>
+ * <p>
+ * Internal configuration information for a <code>Parameter</code> descriptor.
+ * </p>
*
* @author Craig R. McClanahan
*/
@@ -41,17 +42,17 @@ public class ParameterInfo extends FeatureInfo {
}
/**
- * Create and return a <code>MBeanParameterInfo</code> object that
- * corresponds to the parameter described by this instance.
+ * Create and return a <code>MBeanParameterInfo</code> object that
corresponds to the parameter described by this
+ * instance.
+ *
* @return a parameter info
*/
public MBeanParameterInfo createParameterInfo() {
// Return our cached information (if any)
if (info == null) {
- info = new MBeanParameterInfo
- (getName(), getType(), getDescription());
+ info = new MBeanParameterInfo(getName(), getType(),
getDescription());
}
- return (MBeanParameterInfo)info;
+ return (MBeanParameterInfo) info;
}
}
diff --git a/java/org/apache/tomcat/util/modeler/Registry.java
b/java/org/apache/tomcat/util/modeler/Registry.java
index d04af64a49..53d8f3eeb6 100644
--- a/java/org/apache/tomcat/util/modeler/Registry.java
+++ b/java/org/apache/tomcat/util/modeler/Registry.java
@@ -43,10 +43,8 @@ import org.apache.tomcat.util.modeler.modules.ModelerSource;
import org.apache.tomcat.util.res.StringManager;
/**
- * Registry for modeler MBeans.
- * This is the main entry point into modeler. It provides methods to create and
- * manipulate model mbeans and simplify their use.
- * This class is itself a mbean.
+ * Registry for modeler MBeans. This is the main entry point into modeler. It
provides methods to create and manipulate
+ * model mbeans and simplify their use. This class is itself a mbean.
*
* @author Craig R. McClanahan
* @author Costin Manolache
@@ -62,40 +60,37 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
// Support for the factory methods
/**
- * The registry instance created by our factory method the first time it is
- * called.
+ * The registry instance created by our factory method the first time it
is called.
*/
private static Registry registry = null;
// Per registry fields
/**
- * The <code>MBeanServer</code> instance that we will use to register
- * management beans.
+ * The <code>MBeanServer</code> instance that we will use to register
management beans.
*/
private volatile MBeanServer server = null;
private final Object serverLock = new Object();
/**
- * The set of ManagedBean instances for the beans this registry knows
about,
- * keyed by name.
+ * The set of ManagedBean instances for the beans this registry knows
about, keyed by name.
*/
- private Map<String, ManagedBean> descriptors = new HashMap<>();
+ private Map<String,ManagedBean> descriptors = new HashMap<>();
/**
* List of managed beans, keyed by class name
*/
- private Map<String, ManagedBean> descriptorsByClass = new HashMap<>();
+ private Map<String,ManagedBean> descriptorsByClass = new HashMap<>();
// map to avoid duplicated searching or loading descriptors
- private Map<String, URL> searchedPaths = new HashMap<>();
+ private Map<String,URL> searchedPaths = new HashMap<>();
private Object guard;
// Id - small ints to use array access. No reset on stop()
// Used for notifications
- private final Hashtable<String, Hashtable<String, Integer>> idDomains =
new Hashtable<>();
- private final Hashtable<String, int[]> ids = new Hashtable<>();
+ private final Hashtable<String,Hashtable<String,Integer>> idDomains = new
Hashtable<>();
+ private final Hashtable<String,int[]> ids = new Hashtable<>();
// ----------------------------------------------------------- Constructors
@@ -109,13 +104,13 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
// Factories
/**
- * Factory method to create (if necessary) and return our
- * <code>Registry</code> instance.
+ * Factory method to create (if necessary) and return our
<code>Registry</code> instance.
*
- * @param key Unused
+ * @param key Unused
* @param guard Prevent access to the registry by untrusted components
*
* @return the registry
+ *
* @since 1.1
*/
public static synchronized Registry getRegistry(Object key, Object guard) {
@@ -131,11 +126,12 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Factory method to create (if necessary) and return our
- * <code>Registry</code> instance.
+ * Factory method to create (if necessary) and return our
<code>Registry</code> instance.
*
* @param guard Prevent access to the registry by untrusted components
+ *
* @return the registry
+ *
* @throws IllegalArgumentException if the guard object does not allow
access
*/
public static synchronized Registry getRegistry(Object guard) {
@@ -162,8 +158,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
// -------------------- Generic methods --------------------
/**
- * Lifecycle method - clean up the registry metadata. Called from
- * resetMetadata().
+ * Lifecycle method - clean up the registry metadata. Called from
resetMetadata().
*
* @since 1.1
*/
@@ -176,28 +171,21 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Register a bean by creating a modeler mbean and adding it to the
- * MBeanServer.
- * If metadata is not loaded, we'll look up and read a file named
- * "mbeans-descriptors.ser" or "mbeans-descriptors.xml" in the same package
- * or parent.
- * If the bean is an instance of DynamicMBean. its metadata will be
- * converted to a model mbean, and we'll wrap it so modeler services are
- * supported.
- * If the metadata is still not found, introspection will be used to
extract
- * it automatically.
- * If a mbean is already registered under this name, it'll be first
- * unregistered.
- * If the component implements MBeanRegistration, the methods will be
- * called. If the method has a method "setRegistry" that takes a
+ * Register a bean by creating a modeler mbean and adding it to the
MBeanServer. If metadata is not loaded, we'll
+ * look up and read a file named "mbeans-descriptors.ser" or
"mbeans-descriptors.xml" in the same package or parent.
+ * If the bean is an instance of DynamicMBean. its metadata will be
converted to a model mbean, and we'll wrap it so
+ * modeler services are supported. If the metadata is still not found,
introspection will be used to extract it
+ * automatically. If a mbean is already registered under this name, it'll
be first unregistered. If the component
+ * implements MBeanRegistration, the methods will be called. If the method
has a method "setRegistry" that takes a
* RegistryMBean as parameter, it'll be called with the current registry.
*
- * @param bean Object to be registered
+ * @param bean Object to be registered
* @param oname Name used for registration
- * @param type The type of the mbean, as declared in mbeans-descriptors. If
- * null, the name of the class will be used. This can be used as
- * a hint or by subclasses.
+ * @param type The type of the mbean, as declared in mbeans-descriptors.
If null, the name of the class will be
+ * used. This can be used as a hint or by subclasses.
+ *
* @throws Exception if a registration error occurred
+ *
* @since 1.1
*/
@Override
@@ -207,8 +195,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Unregister a component. We'll first check if it is registered, and mask
- * all errors. This is mostly a helper.
+ * Unregister a component. We'll first check if it is registered, and mask
all errors. This is mostly a helper.
*
* @param oname Name used for unregistration
*
@@ -225,18 +212,18 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Invoke an operation on a list of mbeans. Can be used to implement
- * lifecycle operations.
+ * Invoke an operation on a list of mbeans. Can be used to implement
lifecycle operations.
+ *
+ * @param mbeans list of ObjectName on which we'll invoke the operations
+ * @param operation Name of the operation ( init, start, stop, etc)
+ * @param failFirst If false, exceptions will be ignored
*
- * @param mbeans list of ObjectName on which we'll invoke the operations
- * @param operation Name of the operation ( init, start, stop, etc)
- * @param failFirst If false, exceptions will be ignored
* @throws Exception Error invoking operation
+ *
* @since 1.1
*/
@Override
- public void invoke(List<ObjectName> mbeans, String operation, boolean
failFirst)
- throws Exception {
+ public void invoke(List<ObjectName> mbeans, String operation, boolean
failFirst) throws Exception {
if (mbeans == null) {
return;
@@ -263,12 +250,13 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
// -------------------- ID registry --------------------
/**
- * Return an int ID for faster access. Will be used for notifications and
- * for other operations we want to optimize.
+ * Return an int ID for faster access. Will be used for notifications and
for other operations we want to optimize.
*
* @param domain Namespace
- * @param name Type of the notification
+ * @param name Type of the notification
+ *
* @return A unique id for the domain:name combination
+ *
* @since 1.1
*/
@Override
@@ -276,7 +264,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
if (domain == null) {
domain = "";
}
- Hashtable<String, Integer> domainTable =
idDomains.computeIfAbsent(domain, k -> new Hashtable<>());
+ Hashtable<String,Integer> domainTable =
idDomains.computeIfAbsent(domain, k -> new Hashtable<>());
if (name == null) {
name = "";
}
@@ -297,10 +285,10 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
// methods from 1.0
/**
- * Add a new bean metadata to the set of beans known to this registry. This
- * is used by internal components.
+ * Add a new bean metadata to the set of beans known to this registry.
This is used by internal components.
*
* @param bean The managed bean to be added
+ *
* @since 1.0
*/
public void addManagedBean(ManagedBean bean) {
@@ -313,12 +301,14 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Find and return the managed bean definition for the specified bean name,
- * if any; otherwise return <code>null</code>.
+ * Find and return the managed bean definition for the specified bean
name, if any; otherwise return
+ * <code>null</code>.
+ *
+ * @param name Name of the managed bean to be returned. Since 1.1, both
short names or the full name of the class
+ * can be used.
*
- * @param name Name of the managed bean to be returned. Since 1.1, both
- * short names or the full name of the class can be used.
* @return the managed bean
+ *
* @since 1.0
*/
public ManagedBean findManagedBean(String name) {
@@ -336,9 +326,11 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
* Get the type of an attribute of the object, from the metadata.
*
- * @param oname The bean name
+ * @param oname The bean name
* @param attName The attribute name
+ *
* @return null if metadata about the attribute is not found
+ *
* @since 1.1
*/
public String getType(ObjectName oname, String attName) {
@@ -365,8 +357,9 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
* Find the operation info for a method
*
- * @param oname The bean name
+ * @param oname The bean name
* @param opName The operation name
+ *
* @return the operation info for the specified operation
*/
public MBeanOperationInfo getMethodInfo(ObjectName oname, String opName) {
@@ -389,15 +382,16 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
* Find the operation info for a method.
*
- * @param oname The bean name
- * @param opName The operation name
+ * @param oname The bean name
+ * @param opName The operation name
* @param argCount The number of arguments to the method
+ *
* @return the operation info for the specified operation
+ *
* @throws InstanceNotFoundException If the object name is not bound to an
MBean
*/
public MBeanOperationInfo getMethodInfo(ObjectName oname, String opName,
int argCount)
- throws InstanceNotFoundException
- {
+ throws InstanceNotFoundException {
MBeanInfo info;
try {
info = getMBeanServer().getMBeanInfo(oname);
@@ -409,8 +403,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
}
MBeanOperationInfo[] attInfo = info.getOperations();
for (MBeanOperationInfo mBeanOperationInfo : attInfo) {
- if (opName.equals(mBeanOperationInfo.getName())
- && argCount == mBeanOperationInfo.getSignature().length) {
+ if (opName.equals(mBeanOperationInfo.getName()) && argCount ==
mBeanOperationInfo.getSignature().length) {
return mBeanOperationInfo;
}
}
@@ -418,8 +411,8 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
}
/**
- * Unregister a component. This is just a helper that avoids exceptions by
- * checking if the mbean is already registered
+ * Unregister a component. This is just a helper that avoids exceptions by
checking if the mbean is already
+ * registered
*
* @param oname The bean name
*/
@@ -435,8 +428,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Factory method to create (if necessary) and return our
- * <code>MBeanServer</code> instance.
+ * Factory method to create (if necessary) and return our
<code>MBeanServer</code> instance.
*
* @return the MBean server
*/
@@ -465,14 +457,15 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
* Find or load metadata.
*
- * @param bean The bean
+ * @param bean The bean
* @param beanClass The bean class
- * @param type The registry type
+ * @param type The registry type
+ *
* @return the managed bean
+ *
* @throws Exception An error occurred
*/
- public ManagedBean findManagedBean(Object bean, Class<?> beanClass, String
type)
- throws Exception {
+ public ManagedBean findManagedBean(Object bean, Class<?> beanClass, String
type) throws Exception {
if (bean != null && beanClass == null) {
beanClass = bean.getClass();
@@ -518,12 +511,12 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Convert a string to object, based on type. Used by several
- * components. We could provide some pluggability. It is here to keep
things
- * consistent and avoid duplication in other tasks
+ * Convert a string to object, based on type. Used by several components.
We could provide some pluggability. It is
+ * here to keep things consistent and avoid duplication in other tasks
*
- * @param type Fully qualified class name of the resulting value
+ * @param type Fully qualified class name of the resulting value
* @param value String value to be converted
+ *
* @return Converted value
*/
public Object convertValue(String type, String value) {
@@ -552,9 +545,11 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
* Load descriptors.
*
* @param sourceType The source type
- * @param source The bean
- * @param param A type to load
+ * @param source The bean
+ * @param param A type to load
+ *
* @return List of descriptors
+ *
* @throws Exception Error loading descriptors
*/
public List<ObjectName> load(String sourceType, Object source, String
param) throws Exception {
@@ -606,9 +601,10 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
* Register a component
*
- * @param bean The bean
+ * @param bean The bean
* @param oname The object name
- * @param type The registry type
+ * @param type The registry type
+ *
* @throws Exception Error registering component
*/
public void registerComponent(Object bean, ObjectName oname, String type)
throws Exception {
@@ -647,8 +643,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Lookup the component descriptor in the package and in the parent
- * packages.
+ * Lookup the component descriptor in the package and in the parent
packages.
*
* @param packageName The package name
* @param classLoader The class loader
@@ -684,8 +679,7 @@ public class Registry implements RegistryMBean,
MBeanRegistration {
/**
- * Lookup the component descriptor in the package and in the parent
- * packages.
+ * Lookup the component descriptor in the package and in the parent
packages.
*/
private void findDescriptor(Class<?> beanClass, String type) {
if (type == null) {
diff --git a/java/org/apache/tomcat/util/modeler/RegistryMBean.java
b/java/org/apache/tomcat/util/modeler/RegistryMBean.java
index 36351f906a..9e82cafb91 100644
--- a/java/org/apache/tomcat/util/modeler/RegistryMBean.java
+++ b/java/org/apache/tomcat/util/modeler/RegistryMBean.java
@@ -22,12 +22,9 @@ import java.util.List;
import javax.management.ObjectName;
/**
- * Interface for modeler MBeans.
- * This is the main entry point into modeler. It provides methods to create
- * and manipulate model mbeans and simplify their use.
- * Starting with version 1.1, this is no longer a singleton and the static
- * methods are strongly deprecated. In a container environment we can expect
- * different applications to use different registries.
+ * Interface for modeler MBeans. This is the main entry point into modeler. It
provides methods to create and manipulate
+ * model mbeans and simplify their use. Starting with version 1.1, this is no
longer a singleton and the static methods
+ * are strongly deprecated. In a container environment we can expect different
applications to use different registries.
*
* @author Craig R. McClanahan
* @author Costin Manolache
@@ -39,47 +36,36 @@ public interface RegistryMBean {
/**
* Invoke an operation on a set of mbeans.
*
- * @param mbeans List of ObjectNames
+ * @param mbeans List of ObjectNames
* @param operation Operation to perform. Typically "init" "start" "stop"
or "destroy"
- * @param failFirst Behavior in case of exceptions - if false we'll ignore
- * errors
+ * @param failFirst Behavior in case of exceptions - if false we'll ignore
errors
+ *
* @throws Exception Error invoking operation
*/
- void invoke(List<ObjectName> mbeans, String operation, boolean failFirst)
- throws Exception;
+ void invoke(List<ObjectName> mbeans, String operation, boolean failFirst)
throws Exception;
/**
- * Register a bean by creating a modeler mbean and adding it to the
- * MBeanServer.
- * If metadata is not loaded, we'll look up and read a file named
- * "mbeans-descriptors.ser" or "mbeans-descriptors.xml" in the same package
- * or parent.
- * If the bean is an instance of DynamicMBean. it's metadata will be
converted
- * to a model mbean, and we'll wrap it - so modeler services will be
supported
- * If the metadata is still not found, introspection will be used to
extract
- * it automatically.
- * If a mbean is already registered under this name, it'll be first
- * unregistered.
- * If the component implements MBeanRegistration, the methods will be
called.
- * If the method has a method "setRegistry" that takes a RegistryMBean as
- * parameter, it'll be called with the current registry.
- *
+ * Register a bean by creating a modeler mbean and adding it to the
MBeanServer. If metadata is not loaded, we'll
+ * look up and read a file named "mbeans-descriptors.ser" or
"mbeans-descriptors.xml" in the same package or parent.
+ * If the bean is an instance of DynamicMBean. it's metadata will be
converted to a model mbean, and we'll wrap it -
+ * so modeler services will be supported If the metadata is still not
found, introspection will be used to extract
+ * it automatically. If a mbean is already registered under this name,
it'll be first unregistered. If the component
+ * implements MBeanRegistration, the methods will be called. If the method
has a method "setRegistry" that takes a
+ * RegistryMBean as parameter, it'll be called with the current registry.
*
- * @param bean Object to be registered
+ * @param bean Object to be registered
* @param oname Name used for registration
- * @param type The type of the mbean, as declared in mbeans-descriptors. If
- * null, the name of the class will be used. This can be used as a hint or
- * by subclasses.
+ * @param type The type of the mbean, as declared in mbeans-descriptors.
If null, the name of the class will be
+ * used. This can be used as a hint or by subclasses.
+ *
* @throws Exception Error registering MBean
*
* @since 1.1
*/
- void registerComponent(Object bean, String oname, String type)
- throws Exception;
+ void registerComponent(Object bean, String oname, String type) throws
Exception;
/**
- * Unregister a component. We'll first check if it is registered,
- * and mask all errors. This is mostly a helper.
+ * Unregister a component. We'll first check if it is registered, and mask
all errors. This is mostly a helper.
*
* @param oname The name used by the bean
*
@@ -88,22 +74,23 @@ public interface RegistryMBean {
void unregisterComponent(String oname);
- /**
- * Return an int ID for faster access. Will be used for notifications
- * and for other operations we want to optimize.
- *
- * @param domain Namespace
- * @param name Type of the notification
- * @return A unique id for the domain:name combination
- * @since 1.1
- */
+ /**
+ * Return an int ID for faster access. Will be used for notifications and
for other operations we want to optimize.
+ *
+ * @param domain Namespace
+ * @param name Type of the notification
+ *
+ * @return A unique id for the domain:name combination
+ *
+ * @since 1.1
+ */
int getId(String domain, String name);
/**
- * Reset all metadata cached by this registry. Should be called
- * to support reloading. Existing mbeans will not be affected or modified.
- * It will be called automatically if the Registry is unregistered.
+ * Reset all metadata cached by this registry. Should be called to support
reloading. Existing mbeans will not be
+ * affected or modified. It will be called automatically if the Registry
is unregistered.
+ *
* @since 1.1
*/
void stop();
diff --git
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
index 2c67f88d71..59bd76df49 100644
---
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
+++
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
@@ -29,10 +29,8 @@ import org.apache.tomcat.util.digester.Digester;
import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.Registry;
-public class MbeansDescriptorsDigesterSource extends ModelerSource
-{
- private static final Log log =
- LogFactory.getLog(MbeansDescriptorsDigesterSource.class);
+public class MbeansDescriptorsDigesterSource extends ModelerSource {
+ private static final Log log =
LogFactory.getLog(MbeansDescriptorsDigesterSource.class);
private static final Object dLock = new Object();
private Registry registry;
@@ -44,105 +42,68 @@ public class MbeansDescriptorsDigesterSource extends
ModelerSource
Digester digester = new Digester();
digester.setNamespaceAware(false);
digester.setValidating(false);
- URL url = Registry.getRegistry(null).getClass().getResource
- ("/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd");
+ URL url = Registry.getRegistry(null).getClass()
+
.getResource("/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd");
if (url != null) {
- digester.register
- ("-//Apache Software Foundation//DTD Model MBeans Configuration
File",
- url.toString());
+ digester.register("-//Apache Software Foundation//DTD Model MBeans
Configuration File", url.toString());
}
// Configure the parsing rules
- digester.addObjectCreate
- ("mbeans-descriptors/mbean",
- "org.apache.tomcat.util.modeler.ManagedBean");
- digester.addSetProperties
- ("mbeans-descriptors/mbean");
- digester.addSetNext
- ("mbeans-descriptors/mbean",
- "add",
- "java.lang.Object");
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/attribute",
- "org.apache.tomcat.util.modeler.AttributeInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/attribute");
- digester.addSetNext
- ("mbeans-descriptors/mbean/attribute",
- "addAttribute",
- "org.apache.tomcat.util.modeler.AttributeInfo");
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/notification",
- "org.apache.tomcat.util.modeler.NotificationInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/notification");
- digester.addSetNext
- ("mbeans-descriptors/mbean/notification",
- "addNotification",
- "org.apache.tomcat.util.modeler.NotificationInfo");
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/notification/descriptor/field",
- "org.apache.tomcat.util.modeler.FieldInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/notification/descriptor/field");
- digester.addSetNext
- ("mbeans-descriptors/mbean/notification/descriptor/field",
- "addField",
- "org.apache.tomcat.util.modeler.FieldInfo");
-
- digester.addCallMethod
- ("mbeans-descriptors/mbean/notification/notification-type",
- "addNotifType", 0);
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/operation",
- "org.apache.tomcat.util.modeler.OperationInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/operation");
- digester.addSetNext
- ("mbeans-descriptors/mbean/operation",
- "addOperation",
- "org.apache.tomcat.util.modeler.OperationInfo");
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/operation/descriptor/field",
- "org.apache.tomcat.util.modeler.FieldInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/operation/descriptor/field");
- digester.addSetNext
- ("mbeans-descriptors/mbean/operation/descriptor/field",
- "addField",
- "org.apache.tomcat.util.modeler.FieldInfo");
-
- digester.addObjectCreate
- ("mbeans-descriptors/mbean/operation/parameter",
- "org.apache.tomcat.util.modeler.ParameterInfo");
- digester.addSetProperties
- ("mbeans-descriptors/mbean/operation/parameter");
- digester.addSetNext
- ("mbeans-descriptors/mbean/operation/parameter",
- "addParameter",
- "org.apache.tomcat.util.modeler.ParameterInfo");
+ digester.addObjectCreate("mbeans-descriptors/mbean",
"org.apache.tomcat.util.modeler.ManagedBean");
+ digester.addSetProperties("mbeans-descriptors/mbean");
+ digester.addSetNext("mbeans-descriptors/mbean", "add",
"java.lang.Object");
+
+ digester.addObjectCreate("mbeans-descriptors/mbean/attribute",
"org.apache.tomcat.util.modeler.AttributeInfo");
+ digester.addSetProperties("mbeans-descriptors/mbean/attribute");
+ digester.addSetNext("mbeans-descriptors/mbean/attribute",
"addAttribute",
+ "org.apache.tomcat.util.modeler.AttributeInfo");
+
+ digester.addObjectCreate("mbeans-descriptors/mbean/notification",
+ "org.apache.tomcat.util.modeler.NotificationInfo");
+ digester.addSetProperties("mbeans-descriptors/mbean/notification");
+ digester.addSetNext("mbeans-descriptors/mbean/notification",
"addNotification",
+ "org.apache.tomcat.util.modeler.NotificationInfo");
+
+
digester.addObjectCreate("mbeans-descriptors/mbean/notification/descriptor/field",
+ "org.apache.tomcat.util.modeler.FieldInfo");
+
digester.addSetProperties("mbeans-descriptors/mbean/notification/descriptor/field");
+
digester.addSetNext("mbeans-descriptors/mbean/notification/descriptor/field",
"addField",
+ "org.apache.tomcat.util.modeler.FieldInfo");
+
+
digester.addCallMethod("mbeans-descriptors/mbean/notification/notification-type",
"addNotifType", 0);
+
+ digester.addObjectCreate("mbeans-descriptors/mbean/operation",
"org.apache.tomcat.util.modeler.OperationInfo");
+ digester.addSetProperties("mbeans-descriptors/mbean/operation");
+ digester.addSetNext("mbeans-descriptors/mbean/operation",
"addOperation",
+ "org.apache.tomcat.util.modeler.OperationInfo");
+
+
digester.addObjectCreate("mbeans-descriptors/mbean/operation/descriptor/field",
+ "org.apache.tomcat.util.modeler.FieldInfo");
+
digester.addSetProperties("mbeans-descriptors/mbean/operation/descriptor/field");
+
digester.addSetNext("mbeans-descriptors/mbean/operation/descriptor/field",
"addField",
+ "org.apache.tomcat.util.modeler.FieldInfo");
+
+
digester.addObjectCreate("mbeans-descriptors/mbean/operation/parameter",
+ "org.apache.tomcat.util.modeler.ParameterInfo");
+
digester.addSetProperties("mbeans-descriptors/mbean/operation/parameter");
+ digester.addSetNext("mbeans-descriptors/mbean/operation/parameter",
"addParameter",
+ "org.apache.tomcat.util.modeler.ParameterInfo");
return digester;
}
public void setRegistry(Registry reg) {
- this.registry=reg;
+ this.registry = reg;
}
- public void setSource( Object source ) {
- this.source=source;
+ public void setSource(Object source) {
+ this.source = source;
}
@Override
- public List<ObjectName> loadDescriptors( Registry registry, String type,
- Object source) throws Exception {
+ public List<ObjectName> loadDescriptors(Registry registry, String type,
Object source) throws Exception {
setRegistry(registry);
setSource(source);
execute();
@@ -157,7 +118,7 @@ public class MbeansDescriptorsDigesterSource extends
ModelerSource
InputStream stream = (InputStream) source;
List<ManagedBean> loadedMbeans = new ArrayList<>();
- synchronized(dLock) {
+ synchronized (dLock) {
if (digester == null) {
digester = createDigester();
}
diff --git
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
index 2132f05a96..9e959a092c 100644
---
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
+++
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
@@ -38,8 +38,7 @@ import org.apache.tomcat.util.modeler.ParameterInfo;
import org.apache.tomcat.util.modeler.Registry;
import org.apache.tomcat.util.res.StringManager;
-public class MbeansDescriptorsIntrospectionSource extends ModelerSource
-{
+public class MbeansDescriptorsIntrospectionSource extends ModelerSource {
private static final Log log =
LogFactory.getLog(MbeansDescriptorsIntrospectionSource.class);
private static final StringManager sm =
StringManager.getManager(MbeansDescriptorsIntrospectionSource.class);
@@ -48,7 +47,7 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
private final List<ObjectName> mbeans = new ArrayList<>();
public void setRegistry(Registry reg) {
- this.registry=reg;
+ this.registry = reg;
}
/**
@@ -56,17 +55,16 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
*
* @param type The type
*/
- public void setType( String type ) {
- this.type=type;
+ public void setType(String type) {
+ this.type = type;
}
- public void setSource( Object source ) {
- this.source=source;
+ public void setSource(Object source) {
+ this.source = source;
}
@Override
- public List<ObjectName> loadDescriptors(Registry registry, String type,
- Object source) throws Exception {
+ public List<ObjectName> loadDescriptors(Registry registry, String type,
Object source) throws Exception {
setRegistry(registry);
setType(type);
setSource(source);
@@ -75,65 +73,43 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
}
public void execute() throws Exception {
- if( registry==null ) {
- registry=Registry.getRegistry(null);
+ if (registry == null) {
+ registry = Registry.getRegistry(null);
}
try {
- ManagedBean managed = createManagedBean(registry, null,
- (Class<?>)source, type);
- if( managed==null ) {
+ ManagedBean managed = createManagedBean(registry, null, (Class<?>)
source, type);
+ if (managed == null) {
return;
}
- managed.setName( type );
+ managed.setName(type);
registry.addManagedBean(managed);
- } catch( Exception ex ) {
+ } catch (Exception ex) {
log.error(sm.getString("modules.readDescriptorsError"), ex);
}
}
-
// ------------ Implementation for non-declared introspection classes
private static final Map<String,String> specialMethods = new HashMap<>();
static {
- specialMethods.put( "preDeregister", "");
- specialMethods.put( "postDeregister", "");
+ specialMethods.put("preDeregister", "");
+ specialMethods.put("postDeregister", "");
}
- private static final Class<?>[] supportedTypes = new Class[] {
- Boolean.class,
- Boolean.TYPE,
- Byte.class,
- Byte.TYPE,
- Character.class,
- Character.TYPE,
- Short.class,
- Short.TYPE,
- Integer.class,
- Integer.TYPE,
- Long.class,
- Long.TYPE,
- Float.class,
- Float.TYPE,
- Double.class,
- Double.TYPE,
- String.class,
- String[].class,
- BigDecimal.class,
- BigInteger.class,
- ObjectName.class,
- Object[].class,
- java.io.File.class,
- };
+ private static final Class<?>[] supportedTypes = new Class[] {
Boolean.class, Boolean.TYPE, Byte.class, Byte.TYPE,
+ Character.class, Character.TYPE, Short.class, Short.TYPE,
Integer.class, Integer.TYPE, Long.class,
+ Long.TYPE, Float.class, Float.TYPE, Double.class, Double.TYPE,
String.class, String[].class,
+ BigDecimal.class, BigInteger.class, ObjectName.class,
Object[].class, java.io.File.class, };
/**
- * Check if this class is one of the supported types.
- * If the class is supported, returns true. Otherwise,
- * returns false.
+ * Check if this class is one of the supported types. If the class is
supported, returns true. Otherwise, returns
+ * false.
+ *
* @param ret The class to check
+ *
* @return boolean True if class is supported
*/
private boolean supportedType(Class<?> ret) {
@@ -146,10 +122,10 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
}
/**
- * Check if this class conforms to JavaBeans specifications.
- * If the class is conformant, returns true.
+ * Check if this class conforms to JavaBeans specifications. If the class
is conformant, returns true.
*
* @param javaType The class to check
+ *
* @return boolean True if the class is compatible.
*/
private boolean isBeanCompatible(Class<?> javaType) {
@@ -160,8 +136,7 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
// Anything in the java or javax package that
// does not have a defined mapping is excluded.
- if (javaType.getName().startsWith("java.") ||
- javaType.getName().startsWith("javax.")) {
+ if (javaType.getName().startsWith("java.") ||
javaType.getName().startsWith("javax.")) {
return false;
}
@@ -173,10 +148,8 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
// Make sure superclass is compatible
Class<?> superClass = javaType.getSuperclass();
- if (superClass != null &&
- superClass != Object.class &&
- superClass != Exception.class &&
- superClass != Throwable.class) {
+ if (superClass != null && superClass != Object.class && superClass !=
Exception.class &&
+ superClass != Throwable.class) {
return isBeanCompatible(superClass);
}
return true;
@@ -185,15 +158,14 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
/**
* Process the methods and extract 'attributes', methods, etc.
*
- * @param realClass The class to process
- * @param attNames The attribute name (complete)
- * @param getAttMap The readable attributes map
- * @param setAttMap The settable attributes map
+ * @param realClass The class to process
+ * @param attNames The attribute name (complete)
+ * @param getAttMap The readable attributes map
+ * @param setAttMap The settable attributes map
* @param invokeAttList The invokable attributes list
*/
- private void initMethods(Class<?> realClass, Set<String> attNames,
- Map<String,Method> getAttMap, Map<String,Method> setAttMap,
- List<Method> invokeAttList) {
+ private void initMethods(Class<?> realClass, Set<String> attNames,
Map<String,Method> getAttMap,
+ Map<String,Method> setAttMap, List<Method> invokeAttList) {
Method[] methods = realClass.getMethods();
for (Method method : methods) {
@@ -271,29 +243,25 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
}
/**
- * XXX Find if the 'className' is the name of the MBean or
- * the real class ( I suppose first )
- * XXX Read (optional) descriptions from a .properties, generated
- * from source
- * XXX Deal with constructors
+ * XXX Find if the 'className' is the name of the MBean or the real class
( I suppose first ) XXX Read (optional)
+ * descriptions from a .properties, generated from source XXX Deal with
constructors
*
- * @param registry The Bean registry (not used)
- * @param domain The bean domain (not used)
+ * @param registry The Bean registry (not used)
+ * @param domain The bean domain (not used)
* @param realClass The class to analyze
- * @param type The bean type
+ * @param type The bean type
+ *
* @return ManagedBean The create MBean
*/
- public ManagedBean createManagedBean(Registry registry, String domain,
- Class<?> realClass, String type)
- {
+ public ManagedBean createManagedBean(Registry registry, String domain,
Class<?> realClass, String type) {
ManagedBean mbean = new ManagedBean();
Set<String> attrNames = new HashSet<>();
// key: attribute val: getter method
- Map<String, Method> getAttMap = new HashMap<>();
+ Map<String,Method> getAttMap = new HashMap<>();
// key: attribute val: setter method
- Map<String, Method> setAttMap = new HashMap<>();
+ Map<String,Method> setAttMap = new HashMap<>();
// key: operation val: invoke method
List<Method> invokeAttList = new ArrayList<>();
@@ -362,10 +330,10 @@ public class MbeansDescriptorsIntrospectionSource extends
ModelerSource
// -------------------- Utils --------------------
/**
- * Converts the first character of the given
- * String into lower-case.
+ * Converts the first character of the given String into lower-case.
*
* @param name The string to convert
+ *
* @return String
*/
private static String unCapitalize(String name) {
diff --git a/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
b/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
index 6506b0c980..9d158feac7 100644
--- a/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
+++ b/java/org/apache/tomcat/util/modeler/modules/ModelerSource.java
@@ -34,11 +34,12 @@ public abstract class ModelerSource {
* Load data, returns a list of items.
*
* @param registry The registry
- * @param type The bean registry type
- * @param source Introspected object or some other source
+ * @param type The bean registry type
+ * @param source Introspected object or some other source
+ *
* @return a list of object names
+ *
* @throws Exception Error loading descriptors
*/
- public abstract List<ObjectName> loadDescriptors(Registry registry,
- String type, Object source) throws Exception;
+ public abstract List<ObjectName> loadDescriptors(Registry registry, String
type, Object source) throws Exception;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]