I'm new to JMX, and would appreciate advise on the following question:
Suppose you expose some class as an MBean . E.g, you have MyConnectionPool which is an MBean (implementing interface MyConnectionPoolMBean, and registered on an mbean server).
Is it accepptable to allow local classes (in the same JVM) to directly access methods of my MyConnectionPool , *wihtout* going through the mbean Server ?
MyConnectionPool pool=new MyConnectionPool(); MBeanServer server = MBeanServerFactory.createMBeanServer(); server.registerMBean(pool, someObjectName); pool.getConnection(..); // is this ok ? pool.setMaxLimie(6); // is this ok ?
The last 2 lines do direct access to the Pool mbean, not going through the mbean server... I mentioned those 2 different line, because - the first line calls a method that probably isn't exposed through the JMX interface of the pool (getConnection is not a management method... and connection is not even serializable...). - the second line calls a method that' probably exposed through the JMX interface of the pool (setting a limit is indeed a management method).
Are both these lines acceptable ? And will it work for all types of beans (even, say, Model bean) ?