|
From: Mark P. <Mar...@co...> - 2005-01-21 22:34:26
|
Hi,
=20
I was playing around with the JMX sandbox - very useful - and have a few =
questions Wasn't sure if I should post on the forum...but anyway...
=20
I couldn't get the MetadataModelMBeanInfoAssembler to work, when I tried =
to execute a managed operation I got "no result" shown in the MX4J http =
console, although only the methods I chose to expose were displayed. If =
I remove the usage of the metadata and rely on the reflection support - =
it all works fine but I'd like to only expose some of the methods in my =
class.
=20
Here is a code snip since I was doing this inside a helper class I =
already had for MX4J. Commenting out the metadata config code results =
in a happy app... :) =20
=20
=20
JmxMBeanAdapter adapter =3D new JmxMBeanAdapter();
adapter.setBeanFactory(beanFactory_);
adapter.setServer(mBeanServer_);
adapter.setBeans(beans_);
=20
//metadata config start
JmxAttributeSource attributesImpl =3D new =
CommonsAttributesJmxAttributeSource();
MetadataModelMBeanInfoAssembler ass =3D new =
MetadataModelMBeanInfoAssembler();
ass.setAttributeSource(attributesImpl);
MetadataNamingStrategy naming =3D new MetadataNamingStrategy();
naming.setAttributeSource(attributesImpl);
adapter.setAssembler(ass);
adapter.setNamingStrategy(naming);
//metadata config end
=20
LOG.info("Registering mbeans....");
adapter.afterPropertiesSet();
LOG.info("Done registering mbeans.");
=20
and I have added attributes such as
=20
/**
* =
@@org.springframework.jmx.metadata.support.ManagedResource(objectName=3D"=
TeamWork:Name=3DUserService", description=3D"User Management")
* =20
*/
public class HibernateUserService extends HibernateDaoSupport implements
UserService
=20
=20
/**
*=20
* =
@@org.springframework.jmx.metadata.support.ManagedOperation(description=3D=
"Create a user with a unique id")
*/
public User create(String uniqueName)
=20
=20
and the beans_ map contains an entry=20
<entry key=3D"TeamWork:Name=3DUserService"><ref =
bean=3D"UserService"/></entry>
with a log like this....
INFO [main] 2005-01-21 17:26:01,359 =
[com.codestreet.application.jmx.DefaultAdapterFactoryBean] - Registering =
mbeans....
DEBUG [main] 2005-01-21 17:26:01,671 =
[org.springframework.jmx.JmxMBeanAdapter] - Bean Name: UserService has =
been autodetected for JMXification. Instantiating Now.
DEBUG [main] 2005-01-21 17:26:01,671 =
[org.springframework.jmx.JmxMBeanAdapter] - Bean with name: UserService =
is already registered for JMXification.
DEBUG [main] 2005-01-21 17:26:01,906 =
[org.springframework.jmx.JmxMBeanAdapter] - Located bean under key =
[TeamWork:Name=3DUserService] registering with JMX server.
DEBUG [main] 2005-01-21 17:26:01,906 =
[org.springframework.jmx.JmxMBeanAdapter] - Registering and Assembling =
MBean: TeamWork:Name=3DUserService
INFO [main] 2005-01-21 17:26:01,937 =
[org.springframework.jmx.JmxMBeanAdapter] - Registered MBean: =
TeamWork:Name=3DUserService
INFO [main] 2005-01-21 17:26:01,937 =
[com.codestreet.application.jmx.DefaultAdapterFactoryBean] - Done =
registering mbeans.
=20
Another issue was that for some reason the commons-attributes compiler =
was changing the string TeamWork:Name=3DUserService to =
TeamWork.Name=3DUserService, replacing the colon with a period. Have =
you seen that?
=20
By way of extention has it been considered to add support for decribing =
method parameters in the operation attribute and relaying that info to =
the modelmbean?
=20
Thanks any help...
=20
Cheers,
Mark
=20
=20
=20
=20
=20
=20
=20
=20
|