Java Reference
In-Depth Information
public void setAttribute( Attribute attribute )
throws MBeanException,
AttributeNotFoundException, ReflectionException,
InvalidAttributeValueException
{
String fname = attribute.getName();
Object fvalue = attribute.getValue();
try
{
Class c = this.getClass();
String type = getType( fname, false, true );
if( type == null )
throw new AttributeNotFoundException( fname );
Class[] types = { Class.forName( type ) };
Method m = c.getDeclaredMethod( "set" + fname, types );
Object[] args = { fvalue };
m.invoke( ( Object ) this, args );
}
catch( AttributeNotFoundException ae )
{
throw ae;
}
catch( Exception e )
{
e.printStackTrace();
}
}
public AttributeList setAttributes( AttributeList attributes )
{
Attribute[] atts = ( Attribute[] ) attributes.toArray();
AttributeList list = new AttributeList();
for( int i = 0; i < atts.length; i++ )
{
Attribute a = atts[i];
try{
this.setAttribute( a );
}catch( Exception e ) { e.printStackTrace(); }
}//for
B
Implement
DynamicMBean
interface
B
Implement
DynamicMBean
interface
return attributes;
}
public AttributeList getAttributes( String[] names )
{
AttributeList list = new AttributeList();
B
Implement
DynamicMBean
interface
for( int i = 0; i < names.length; i++ )
{
try{
list.add( new Attribute( names[i],
this.getAttribute ( names[i] ) ) );
Search WWH ::




Custom Search