From: Gavin_King/Cirrus%<CI...@ci...> - 2002-07-18 03:38:54
|
Okay, a long quote from the JBoss manual below tells me just about everything I need to know. You dont *have* to inherit any JBoss specific interfaces, etc. Approach (1) of the 3 approaches listed gives you a way to avoid this. I propose the following MBean interface package cirrus.hibernate.jmx; public interface HibernateServiceMBean { // the JNDI name public String getName(); public void setName(String jndiName); // bind / unbind the SessionFactory public void start() throws Exception; public void stop() throws Exception; public boolean isStarted(); public boolean setStarted(boolean started) throws Exception; public boolean getShowSQL(); public void setShowSQL(boolean showSQL); // a comma-seperated list of properties public void setProperties(String properties); public String getProperties(); // a comma-seperated list of resources public void setMapResources(String mapResourceList); public String getMapResources(); // some attributes for extra-important properties public String getDatasource(); public void setDatasource(String datasource); public boolean getUseOuterJoin(); public void setUseOuterJoin(boolean uoj); } which is not very different from John's original one, except it doesn't inherit org.jboss.util.ServiceMBean. ============================================================ Quote: Writing JBoss MBean Services ---------------------------- Writing a custom service that integrates into the JBoss server requires the use of the org.jboss.util.Service interface pattern if the custom service is depdendent on other JBoss services. This means that you cannot perform any JBoss service dependent intialization in any of the javax.management.MBeanRegistration interface methods. Instead, you must do this in the Service interface init and/or start methods. You need to do one of the following: (1) Add any of the Service methods that you want called on your MBean to your MBean interface. (2) Have your MBean interface extend the org.jboss.util.Service interface. (3) Have your MBean interface extend the org.jboss.util.ServiceMBean interface. This is a subinterface of org.jboss.util.Service that adds String getName(), int getState(), and String getStateString() methods. Which approach you choose depends on whether or not you want to be associated with JBoss specific code. If you don't, then you would use the first approach. If you don't mind, then the simplest approach is to have your MBean interface extend from org.jboss.util.ServiceMBean and your MBean implementation class extend from the abstract org.jboss.util.ServiceMBeanSupport class. This class implements the org.jboss.util.ServiceMBean interface except for the String getName() method. ServiceMBeanSupport provides implementations of the init, start, stop and destroy methods that integrate logging and JBoss service state management. Each method delegates any subclass specific work to initService, startService, stopService, and destroyService methods respectively. When subclassing ServiceMBeanSupport you would override one or more of the initService, startService, stopService, and destroyService methods in addition to getName as required. |