costin 2003/02/03 14:13:16
Modified: modeler/src/java/org/apache/commons/modeler
BaseModelMBean.java
Log:
Few fixes for strange cases found testing reloading.
Also more debug.
Revision Changes Path
1.14 +23 -14 jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java
Index: BaseModelMBean.java
===================================================================
RCS file: /home/cvs/jakarta-commons/modeler/src/java/org/apache/commons/modeler/BaseModelMBean.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- BaseModelMBean.java 23 Jan 2003 19:42:04 -0000 1.13
+++ BaseModelMBean.java 3 Feb 2003 22:13:16 -0000 1.14
@@ -135,8 +135,8 @@
public BaseModelMBean() throws MBeanException, RuntimeOperationsException {
super();
- setModelMBeanInfo(createDefaultModelMBeanInfo());
if( log.isDebugEnabled()) log.debug("default constructor");
+ setModelMBeanInfo(createDefaultModelMBeanInfo());
}
@@ -172,8 +172,11 @@
public BaseModelMBean( String type )
throws MBeanException, RuntimeOperationsException
{
- super();
- setModeledType(type);
+ try {
+ setModeledType(type);
+ } catch( Throwable ex ) {
+ log.error( "Error creating mbean ", ex);
+ }
}
// ----------------------------------------------------- Instance Variables
@@ -339,6 +342,7 @@
*/
public MBeanInfo getMBeanInfo() {
// XXX Why do we have to clone ?
+ if( info== null ) return null;
return ((MBeanInfo) info.clone());
}
@@ -446,7 +450,7 @@
((Error) t, "Error invoking method " + name);
else
throw new MBeanException
- (e, "Exception invoking method " + name);
+ ((Exception)t, "Exception invoking method " + name);
} catch (Exception e) {
log.error("Exception invoking method " + name , e );
throw new MBeanException
@@ -573,12 +577,15 @@
m = object.getClass().getMethod(setMethod, signature);
exception=null;
} catch (NoSuchMethodException e) {
+ if( log.isDebugEnabled())
+ log.debug("Method not found in resource " +resource);
exception = e;
}
}
if( exception != null )
throw new ReflectionException(exception,
- "Cannot find setter method " + setMethod);
+ "Cannot find setter method " + setMethod
+
+ " " + resource);
setAttMap.put( name, m );
}
@@ -1164,26 +1171,28 @@
log.debug("setModeledType " + type);
Registry reg=Registry.getRegistry();
+ //Thread.currentThread().setContextClassLoader(BaseModelMBean.class.getClassLoader());
+ Class c=Class.forName( type);
+ resource = c.newInstance();
ManagedBean descriptor=reg.findManagedBean(type);
if( descriptor != null ) {
if( log.isDebugEnabled())
- log.debug("Using descriptor " + type);
+ log.debug("Using descriptor " + type + " " + descriptor);
this.setModelMBeanInfo( descriptor.createMBeanInfo());
return;
}
// Maybe it's a real class name. Use introspection
- Class c=Class.forName( type);
- resource = c.newInstance();
if( log.isDebugEnabled())
log.debug("Introspecting " + type);
reg.loadDescriptors("MbeansDescriptorsIntrospectionSource", c, type);
descriptor=reg.findManagedBean(type);
this.setModelMBeanInfo(descriptor.createMBeanInfo());
- } catch( Exception ex) {
- ex.printStackTrace();
+ } catch( Throwable ex) {
+ log.error( "TCL: " + Thread.currentThread().getContextClassLoader(),
+ ex);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
|