/** Mbeans loaded by the engine.
*/
- private List mbeans;
+ private List<ObjectName> mbeans;
/**
try {
for( int i=0; i<mbeans.size() ; i++ ) {
Registry.getRegistry(null, null)
- .unregisterComponent((ObjectName)mbeans.get(i));
+ .unregisterComponent(mbeans.get(i));
}
} catch (Exception e) {
log.error(sm.getString("standardEngine.unregister.mbeans.failed", mbeansFile), e);
* The set of attribute names that are accepted by this filter. If this
* list is empty, all attribute names are accepted.
*/
- private HashSet names = new HashSet();
+ private HashSet<String> names = new HashSet<String>();
// --------------------------------------------------------- Public Methods
public String[] getNames() {
synchronized (names) {
- return ((String[]) names.toArray(new String[names.size()]));
+ return names.toArray(new String[names.size()]);
}
}
// --------------------------------------------------- DynamicMBean Methods
// TODO: move to ManagedBean
- static final Object[] NO_ARGS_PARAM=new Object[0];
- static final Class[] NO_ARGS_PARAM_SIG=new Class[0];
+ static final Object[] NO_ARGS_PARAM = new Object[0];
+ static final Class<?>[] NO_ARGS_PARAM_SIG = new Class[0];
protected String resourceType = null;
Method m=managedBean.getGetter(name, this, resource);
Object result = null;
try {
- Class declaring=m.getDeclaringClass();
+ 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()) ) {
}
- static Class getAttributeClass(String signature)
+ static Class<?> getAttributeClass(String signature)
throws ReflectionException
{
if (signature.equals(Boolean.TYPE.getName()))
// Prepare and return our response, eating all exceptions
String names[] = new String[attributes.size()];
int n = 0;
- Iterator items = attributes.iterator();
+ Iterator<?> items = attributes.iterator();
while (items.hasNext()) {
Attribute item = (Attribute) items.next();
names[n++] = item.getName();
* The set of registered <code>BaseNotificationBroadcasterEntry</code>
* entries.
*/
- protected ArrayList entries = new ArrayList();
+ protected ArrayList<BaseNotificationBroadcasterEntry> entries =
+ new ArrayList<BaseNotificationBroadcasterEntry>();
// --------------------------------------------------------- Public Methods
// Optimization to coalesce attribute name filters
if (filter instanceof BaseAttributeFilter) {
BaseAttributeFilter newFilter = (BaseAttributeFilter) filter;
- Iterator items = entries.iterator();
+ Iterator<BaseNotificationBroadcasterEntry> items =
+ entries.iterator();
while (items.hasNext()) {
- BaseNotificationBroadcasterEntry item =
- (BaseNotificationBroadcasterEntry) items.next();
+ BaseNotificationBroadcasterEntry item = items.next();
if ((item.listener == listener) &&
(item.filter != null) &&
(item.filter instanceof BaseAttributeFilter) &&
throws ListenerNotFoundException {
synchronized (entries) {
- Iterator items = entries.iterator();
+ Iterator<BaseNotificationBroadcasterEntry> items =
+ entries.iterator();
while (items.hasNext()) {
- BaseNotificationBroadcasterEntry item =
- (BaseNotificationBroadcasterEntry) items.next();
+ BaseNotificationBroadcasterEntry item = items.next();
if (item.listener == listener)
items.remove();
}
public void sendNotification(Notification notification) {
synchronized (entries) {
- Iterator items = entries.iterator();
+ Iterator<BaseNotificationBroadcasterEntry> items =
+ entries.iterator();
while (items.hasNext()) {
- BaseNotificationBroadcasterEntry item =
- (BaseNotificationBroadcasterEntry) items.next();
+ BaseNotificationBroadcasterEntry item = items.next();
if ((item.filter != null) &&
(!item.filter.isNotificationEnabled(notification)))
continue;
* The set of attribute names that are accepted by this filter. If this
* list is empty, all attribute names are accepted.
*/
- private HashSet names = new HashSet();
+ private HashSet<String> names = new HashSet<String>();
String namesA[]=null;
/**
*/
public String[] getNames() {
synchronized (names) {
- return ((String[]) names.toArray(new String[names.size()]));
+ return names.toArray(new String[names.size()]);
}
}
{
private static final String BASE_MBEAN = "org.apache.tomcat.util.modeler.BaseModelMBean";
// ----------------------------------------------------- Instance Variables
- static final Object[] NO_ARGS_PARAM=new Object[0];
- static final Class[] NO_ARGS_PARAM_SIG=new Class[0];
+ static final Object[] NO_ARGS_PARAM = new Object[0];
+ static final Class<?>[] NO_ARGS_PARAM_SIG = new Class[0];
/**
* to this <code>ManagedBean</code> instance.
*/
transient MBeanInfo info = null;
- // Map<AttributeInfo>
- private Map attributes = new HashMap();
- //Map<OperationInfo>
- private Map operations = new HashMap();
+
+ private Map<String,AttributeInfo> attributes =
+ new HashMap<String,AttributeInfo>();
+
+ private Map<String,OperationInfo> operations =
+ new HashMap<String,OperationInfo>();
protected String className = BASE_MBEAN;
//protected ConstructorInfo constructors[] = new ConstructorInfo[0];
// Skip introspection
mbean = new BaseModelMBean();
} else {
- Class clazz = null;
+ Class<?> clazz = null;
Exception ex = null;
try {
clazz = Class.forName(getClassName());
Method m=null; // (Method)getAttMap.get( name );
if( m==null ) {
- AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
+ AttributeInfo attrInfo = attributes.get(aname);
// Look up the actual operation to be used
if (attrInfo == null)
throw new AttributeNotFoundException(" Cannot find attribute " + aname + " for " + resource);
Method m=null;//(Method)setAttMap.get( name );
if( m==null ) {
- AttributeInfo attrInfo = (AttributeInfo)attributes.get(aname);
+ AttributeInfo attrInfo = attributes.get(aname);
if (attrInfo == null)
throw new AttributeNotFoundException(" Cannot find attribute " + aname);
String argType=attrInfo.getType();
- Class signature[] = new Class[] { BaseModelMBean.getAttributeClass( argType ) };
+ Class<?> signature[] =
+ new Class[] { BaseModelMBean.getAttributeClass( argType ) };
Object object = null;
NoSuchMethodException exception = null;
// Acquire the ModelMBeanOperationInfo information for
// the requested operation
- OperationInfo opInfo = (OperationInfo)operations.get(aname);
+ OperationInfo opInfo = operations.get(aname);
if (opInfo == null)
throw new MBeanException(new ServiceNotFoundException(
"Cannot find operation " + aname),
// Prepare the signature required by Java reflection APIs
// FIXME - should we use the signature from opInfo?
- Class types[] = new Class[signature.length];
+ Class<?> types[] = new Class[signature.length];
for (int i = 0; i < signature.length; i++) {
types[i] = BaseModelMBean.getAttributeClass(signature[i]);
}
/** Will be used to isolate different apps and enhance security.
*/
- private static HashMap perLoaderRegistries=null;
+ private static HashMap<Object,Registry> perLoaderRegistries = null;
/**
* The registry instance created by our factory method the first time
* The set of ManagedBean instances for the beans this registry
* knows about, keyed by name.
*/
- private HashMap descriptors = new HashMap();
+ private HashMap<String,ManagedBean> descriptors =
+ new HashMap<String,ManagedBean>();
/** List of managed byeans, keyed by class name
*/
- private HashMap descriptorsByClass = new HashMap();
+ private HashMap<String,ManagedBean> descriptorsByClass =
+ new HashMap<String,ManagedBean>();
// map to avoid duplicated searching or loading descriptors
- private HashMap searchedPaths=new HashMap();
+ private HashMap<String,URL> searchedPaths=new HashMap<String,URL>();
private Object guard;
// Id - small ints to use array access. No reset on stop()
// Used for notifications
- private Hashtable idDomains=new Hashtable();
- private Hashtable ids=new Hashtable();
+ private Hashtable<String,Hashtable<String,Integer>> idDomains =
+ new Hashtable<String,Hashtable<String,Integer>>();
+ private Hashtable<String,int[]> ids = new Hashtable<String,int[]>();
// ----------------------------------------------------------- Constructors
if( key==null )
key=Thread.currentThread().getContextClassLoader();
if( key != null ) {
- localRegistry=(Registry)perLoaderRegistries.get(key);
+ localRegistry = perLoaderRegistries.get(key);
if( localRegistry == null ) {
localRegistry=new Registry();
// localRegistry.key=key;
*/
public static void setUseContextClassLoader( boolean enable ) {
if( enable ) {
- perLoaderRegistries=new HashMap();
+ perLoaderRegistries = new HashMap<Object,Registry>();
}
}
* @since 1.1
*/
public void stop() {
- descriptorsByClass = new HashMap();
- descriptors = new HashMap();
- searchedPaths=new HashMap();
+ descriptorsByClass = new HashMap<String,ManagedBean>();
+ descriptors = new HashMap<String,ManagedBean>();
+ searchedPaths=new HashMap<String,URL>();
}
/**
*
* @since 1.1
*/
- public List loadMBeans( Object source, ClassLoader cl )
+ public List<ObjectName> loadMBeans( Object source, ClassLoader cl )
throws Exception
{
return load("MbeansSource", source, null );
* @throws Exception
* @since 1.1
*/
- public void invoke( List mbeans, String operation, boolean failFirst )
- throws Exception
- {
+ public void invoke(List<ObjectName> mbeans, String operation,
+ boolean failFirst ) throws Exception {
if( mbeans==null ) {
return;
}
- Iterator itr=mbeans.iterator();
+ Iterator<ObjectName> itr = mbeans.iterator();
while(itr.hasNext()) {
- Object current=itr.next();
- ObjectName oN=null;
+ ObjectName current = itr.next();
try {
- if( current instanceof ObjectName) {
- oN=(ObjectName)current;
- }
- if( current instanceof String ) {
- oN=new ObjectName( (String)current );
- }
- if( oN==null ) {
+ if(current == null) {
continue;
}
- if( getMethodInfo(oN, operation) == null) {
+ if(getMethodInfo(current, operation) == null) {
continue;
}
- getMBeanServer().invoke(oN, operation,
+ getMBeanServer().invoke(current, operation,
new Object[] {}, new String[] {});
} catch( Exception t ) {
if( domain==null) {
domain="";
}
- Hashtable domainTable=(Hashtable)idDomains.get( domain );
+ Hashtable<String,Integer> domainTable = idDomains.get(domain);
if( domainTable == null ) {
- domainTable=new Hashtable();
+ domainTable = new Hashtable<String,Integer>();
idDomains.put( domain, domainTable);
}
if( name==null ) {
name="";
}
- Integer i=(Integer)domainTable.get(name);
+ Integer i = domainTable.get(name);
if( i!= null ) {
return i.intValue();
}
- int id[]=(int [])ids.get( domain );
+ int id[] = ids.get(domain);
if( id == null ) {
id=new int[1];
ids.put( domain, id);
*/
public ManagedBean findManagedBean(String name) {
// XXX Group ?? Use Group + Type
- ManagedBean mb=((ManagedBean) descriptors.get(name));
+ ManagedBean mb = descriptors.get(name);
if( mb==null )
- mb=(ManagedBean)descriptorsByClass.get(name);
+ mb = descriptorsByClass.get(name);
return mb;
}
* @since 1.0
*/
public String[] findManagedBeans() {
- return ((String[]) descriptors.keySet().toArray(new String[0]));
+ return descriptors.keySet().toArray(new String[0]);
}
*/
public String[] findManagedBeans(String group) {
- ArrayList results = new ArrayList();
- Iterator items = descriptors.values().iterator();
+ ArrayList<String> results = new ArrayList<String>();
+ Iterator<ManagedBean> items = descriptors.values().iterator();
while (items.hasNext()) {
- ManagedBean item = (ManagedBean) items.next();
+ ManagedBean item = items.next();
if ((group == null) && (item.getGroup() == null)) {
results.add(item.getName());
} else if (group.equals(item.getGroup())) {
}
}
String values[] = new String[results.size()];
- return ((String[]) results.toArray(values));
+ return results.toArray(values);
}
if (server == null) {
if( MBeanServerFactory.findMBeanServer(null).size() > 0 ) {
- server=(MBeanServer)MBeanServerFactory.findMBeanServer(null).get(0);
+ server = (MBeanServer) MBeanServerFactory.findMBeanServer(
+ null).get(0);
if( log.isDebugEnabled() ) {
log.debug("Using existing MBeanServer " + (System.currentTimeMillis() - t1 ));
}
/** Find or load metadata.
*/
- 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();
}
* @throws Exception
* @deprecated bad interface, mixing of metadata and mbeans
*/
- public List load( String sourceType, Object source, String param)
- throws Exception
- {
+ public List<ObjectName> load( String sourceType, Object source,
+ String param) throws Exception {
if( log.isTraceEnabled()) {
log.trace("load " + source );
}
type=param;
inputsource=source;
} else if( source instanceof Class ) {
- location=((Class)source).getName();
+ location=((Class<?>)source).getName();
type=param;
inputsource=source;
if( sourceType== null ) {
sourceType="MbeansDescriptorsDigesterSource";
}
ModelerSource ds=getModelerSource(sourceType);
- List mbeans=ds.loadDescriptors(this, location, type, inputsource);
+ List<ObjectName> mbeans =
+ ds.loadDescriptors(this, location, type, inputsource);
return mbeans;
}
return;
}
- /** Experimental. Will become private, some code may still use it
+ /**Experimental. Will become private, some code may still use it
*
* @param sourceType
* @param source
* @throws Exception
* @deprecated
*/
- public void loadDescriptors( String sourceType, Object source, String param)
- throws Exception
- {
- List mbeans=load( sourceType, source, param );
- if( mbeans == null) return;
-
- Iterator itr=mbeans.iterator();
- while( itr.hasNext() ) {
- Object mb=itr.next();
- if( mb instanceof ManagedBean) {
- addManagedBean((ManagedBean)mb);
- }
- }
+ public void loadDescriptors(String sourceType, Object source, String param)
+ throws Exception {
+ load(sourceType, source, param);
}
/** Lookup the component descriptor in the package and
* @param beanClass
* @param type
*/
- private void findDescriptor( Class beanClass, String type ) {
+ private void findDescriptor(Class<?> beanClass, String type) {
if( type==null ) {
type=beanClass.getName();
}
type="org.apache.tomcat.util.modeler.modules." + type;
}
- Class c=Class.forName( type );
+ Class<?> c = Class.forName(type);
ModelerSource ds=(ModelerSource)c.newInstance();
return ds;
}
perLoaderRegistries.remove(loader);
}
- public ManagedBean findManagedBean(Class beanClass, String type)
+ public ManagedBean findManagedBean(Class<?> beanClass, String type)
throws Exception
{
return findManagedBean(null, beanClass, type);
import java.util.List;
+import javax.management.ObjectName;
+
/**
* Interface for modeler MBeans.
*
*
* @since 1.1
*/
- public List loadMBeans( Object source, ClassLoader cl ) throws Exception;
+ public List<ObjectName> loadMBeans( Object source, ClassLoader cl )
+ throws Exception;
/** Invoke an operation on a set of mbeans.
*
* errors
* @throws Exception
*/
- public void invoke( List mbeans, String operation, boolean failFirst )
+ public void invoke( List<ObjectName> mbeans, String operation, boolean failFirst )
throws Exception;
/** Register a bean by creating a modeler mbean and adding it to the
import java.util.ArrayList;
import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.DomUtil;
String location;
String type;
Object source;
- List mbeans=new ArrayList();
+ List<ObjectName> mbeans=new ArrayList<ObjectName>();
public void setRegistry(Registry reg) {
this.registry=reg;
this.source=source;
}
- public List loadDescriptors( Registry registry, String location,
+ public List<ObjectName> loadDescriptors( Registry registry, String location,
String type, Object source)
throws Exception
{
}
// Add the completed managed bean info to the registry
- //registry.addManagedBean(managed);
- mbeans.add( managed );
-
+ registry.addManagedBean(managed);
}
long t2=System.currentTimeMillis();
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.tomcat.util.digester.Digester;
+import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.Registry;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
String location;
String type;
Object source;
- List mbeans=new ArrayList();
+ List<ObjectName> mbeans = new ArrayList<ObjectName>();
protected static Digester digester = null;
protected static Digester createDigester(Registry registry) {
this.source=source;
}
- public List loadDescriptors( Registry registry, String location,
- String type, Object source)
- throws Exception
- {
+ public List<ObjectName> loadDescriptors( Registry registry, String location,
+ String type, Object source) throws Exception {
setRegistry(registry);
setLocation(location);
setType(type);
if (digester == null) {
digester = createDigester(registry);
}
+ ArrayList<ManagedBean> loadedMbeans = new ArrayList<ManagedBean>();
synchronized (digester) {
-
+
// Process the input file to configure our registry
try {
// Push our registry object onto the stack
- digester.push(mbeans);
+ digester.push(loadedMbeans);
digester.parse(stream);
} catch (Exception e) {
log.error("Error digesting Registry data", e);
}
}
-
+ Iterator<ManagedBean> iter = loadedMbeans.iterator();
+ while (iter.hasNext()) {
+ registry.addManagedBean(iter.next());
+ }
}
}
String location;
String type;
Object source;
- List mbeans=new ArrayList();
+ List<ObjectName> mbeans = new ArrayList<ObjectName>();
public void setRegistry(Registry reg) {
this.registry=reg;
this.source=source;
}
- public List loadDescriptors( Registry registry, String location,
- String type, Object source)
- throws Exception
- {
+ public List<ObjectName> loadDescriptors( Registry registry, String location,
+ String type, Object source) throws Exception {
setRegistry(registry);
setLocation(location);
setType(type);
public void execute() throws Exception {
if( registry==null ) registry=Registry.getRegistry();
try {
- ManagedBean managed=createManagedBean(registry, null, (Class)source, type);
+ ManagedBean managed = createManagedBean(registry, null,
+ (Class<?>)source, type);
if( managed==null ) return;
managed.setName( type );
- mbeans.add(managed);
+ registry.addManagedBean(managed);
} catch( Exception ex ) {
log.error( "Error reading descriptors ", ex);
// ------------ Implementation for non-declared introspection classes
- static Hashtable specialMethods=new Hashtable();
+ static Hashtable<String,String> specialMethods =
+ new Hashtable<String,String>();
static {
specialMethods.put( "preDeregister", "");
specialMethods.put( "postDeregister", "");
private static ObjectName objNameArray[]=new ObjectName[0];
// createMBean == registerClass + registerMBean
- private static Class[] supportedTypes = new Class[] {
+ private static Class<?>[] supportedTypes = new Class[] {
Boolean.class,
Boolean.TYPE,
Byte.class,
* @param ret The class to check
* @return boolean True if class is supported
*/
- private boolean supportedType(Class ret) {
+ private boolean supportedType(Class<?> ret) {
for (int i = 0; i < supportedTypes.length; i++) {
if (ret == supportedTypes[i]) {
return true;
* @param javaType The class to check
* @return boolean True if the class is compatible.
*/
- protected boolean isBeanCompatible(Class javaType) {
+ protected boolean isBeanCompatible(Class<?> javaType) {
// Must be a non-primitive and non array
if (javaType.isArray() || javaType.isPrimitive()) {
return false;
}
// Make sure superclass is compatible
- Class superClass = javaType.getSuperclass();
+ Class<?> superClass = javaType.getSuperclass();
if (superClass != null &&
superClass != java.lang.Object.class &&
superClass != java.lang.Exception.class &&
* @param setAttMap The settable attributes map
* @param invokeAttMap The invokable attributes map
*/
- private void initMethods(Class realClass,
+ private void initMethods(Class<?> realClass,
Method methods[],
- Hashtable attMap, Hashtable getAttMap,
- Hashtable setAttMap, Hashtable invokeAttMap)
+ Hashtable<String,Method> attMap,
+ Hashtable<String,Method> getAttMap,
+ Hashtable<String,Method> setAttMap,
+ Hashtable<String,Method> invokeAttMap)
{
for (int j = 0; j < methods.length; ++j) {
String name=methods[j].getName();
}
if( methods[j].getDeclaringClass() == Object.class )
continue;
- Class params[]=methods[j].getParameterTypes();
+ Class<?> params[] = methods[j].getParameterTypes();
if( name.startsWith( "get" ) && params.length==0) {
- Class ret=methods[j].getReturnType();
+ Class<?> ret = methods[j].getReturnType();
if( ! supportedType( ret ) ) {
if( log.isDebugEnabled() )
log.debug("Unsupported type " + methods[j]);
// just a marker, we don't use the value
attMap.put( name, methods[j] );
} else if( name.startsWith( "is" ) && params.length==0) {
- Class ret=methods[j].getReturnType();
+ Class<?> ret = methods[j].getReturnType();
if( Boolean.TYPE != ret ) {
if( log.isDebugEnabled() )
log.debug("Unsupported type " + methods[j] + " " + ret );
* @return ManagedBean The create MBean
*/
public ManagedBean createManagedBean(Registry registry, String domain,
- Class realClass, String type)
+ Class<?> realClass, String type)
{
ManagedBean mbean= new ManagedBean();
Method methods[]=null;
- Hashtable attMap=new Hashtable();
+ Hashtable<String,Method> attMap = new Hashtable<String,Method>();
// key: attribute val: getter method
- Hashtable getAttMap=new Hashtable();
+ Hashtable<String,Method> getAttMap = new Hashtable<String,Method>();
// key: attribute val: setter method
- Hashtable setAttMap=new Hashtable();
+ Hashtable<String,Method> setAttMap = new Hashtable<String,Method>();
// key: operation val: invoke method
- Hashtable invokeAttMap=new Hashtable();
+ Hashtable<String,Method> invokeAttMap = new Hashtable<String,Method>();
methods = realClass.getMethods();
try {
- Enumeration en=attMap.keys();
+ Enumeration<String> en = attMap.keys();
while( en.hasMoreElements() ) {
- String name=(String)en.nextElement();
+ String name = en.nextElement();
AttributeInfo ai=new AttributeInfo();
ai.setName( name );
- Method gm=(Method)getAttMap.get(name);
+ Method gm = getAttMap.get(name);
if( gm!=null ) {
//ai.setGetMethodObj( gm );
ai.setGetMethod( gm.getName());
- Class t=gm.getReturnType();
+ Class<?> t=gm.getReturnType();
if( t!=null )
ai.setType( t.getName() );
}
- Method sm=(Method)setAttMap.get(name);
+ Method sm = setAttMap.get(name);
if( sm!=null ) {
//ai.setSetMethodObj(sm);
- Class t=sm.getParameterTypes()[0];
+ Class<?> t = sm.getParameterTypes()[0];
if( t!=null )
ai.setType( t.getName());
ai.setSetMethod( sm.getName());
en=invokeAttMap.keys();
while( en.hasMoreElements() ) {
- String name=(String)en.nextElement();
- Method m=(Method)invokeAttMap.get(name);
+ String name = en.nextElement();
+ Method m = invokeAttMap.get(name);
if( m!=null && name != null ) {
OperationInfo op=new OperationInfo();
op.setName(name);
op.setReturnType(m.getReturnType().getName());
op.setDescription("Introspected operation " + name);
- Class parms[]=m.getParameterTypes();
+ Class<?> parms[] = m.getParameterTypes();
for(int i=0; i<parms.length; i++ ) {
ParameterInfo pi=new ParameterInfo();
pi.setType(parms[i].getName());
import java.util.ArrayList;
import java.util.List;
+import javax.management.ObjectName;
+
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.modeler.ManagedBean;
String location;
String type;
Object source;
- List mbeans=new ArrayList();
+ List<ObjectName> mbeans=new ArrayList<ObjectName>();
public void setRegistry(Registry reg) {
this.registry=reg;
this.source=source;
}
- public List loadDescriptors( Registry registry, String location,
- String type, Object source)
- throws Exception
- {
+ public List<ObjectName> loadDescriptors( Registry registry, String location,
+ String type, Object source) throws Exception {
setRegistry(registry);
setLocation(location);
setType(type);
ManagedBean beans[]=(ManagedBean[])obj;
// after all are read without error
for( int i=0; i<beans.length; i++ ) {
- mbeans.add(beans[i]);
+ registry.addManagedBean(beans[i]);
}
} catch( Exception ex ) {
// true if we are during the original loading
boolean loading=true;
- List mbeans=new ArrayList();
+ List<ObjectName> mbeans = new ArrayList<ObjectName>();
static boolean loaderLoaded=false;
private Document document;
- private HashMap object2Node = new HashMap();
+ private HashMap<ObjectName,Node> object2Node =
+ new HashMap<ObjectName,Node>();
long lastUpdate;
long updateInterval=10000; // 10s
/** Return the list of mbeans created by this source.
* It can be used to implement runtime services.
*/
- public List getMBeans() {
+ public List<ObjectName> getMBeans() {
return mbeans;
}
- public List loadDescriptors( Registry registry, String location,
- String type, Object source)
- throws Exception
- {
+ public List<ObjectName> loadDescriptors(Registry registry, String location,
+ String type, Object source) throws Exception {
setRegistry(registry);
setLocation(location);
setType(type);
firstMbeanN=descriptorsN;
}
- MBeanServer server=(MBeanServer)Registry.getServer();
+ MBeanServer server = Registry.getServer();
// XXX Not very clean... Just a workaround
if( ! loaderLoaded ) {
if( loading ) return;
// nothing by default
//log.info( "XXX UpdateField " + oname + " " + name + " " + value);
- Node n=(Node)object2Node.get( oname );
+ Node n = object2Node.get(oname);
if( n == null ) {
log.info( "Node not found " + oname );
return;
import java.util.List;
+import javax.management.ObjectName;
+
/**
* This mbean will load an extended mlet file ( similar in syntax with jboss ).
*
* @return List of ObjectName
*/
- public List getMBeans();
+ public List<ObjectName> getMBeans();
/** Load the mbeans from the source. Called automatically on init()
*
* @param source Introspected object or some other source
* @throws Exception
*/
- public List loadDescriptors( Registry registry, String location,
- String type, Object source)
- throws Exception
- {
+ public List<ObjectName> loadDescriptors( Registry registry, String location,
+ String type, Object source) throws Exception {
// TODO
return null;
}