diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/AppClientModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/AppClientModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/AppClientModule.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/AppClientModule.java 2005-08-07 03:05:41.983040000 -0300 @@ -47,12 +47,13 @@ * @param pDeploymentDescriptor * @throws InvalidParameterException If the given Name is null */ - public AppClientModule(String pName, ObjectName pApplication, String[] pJVMs, String pDeploymentDescriptor) + public AppClientModule(String pName, ObjectName pApplication, ObjectName deployedService, + String[] pJVMs, String pDeploymentDescriptor) throws MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.AppClientModule, pName, pApplication, pJVMs, pDeploymentDescriptor); + super(J2EETypeConstants.AppClientModule, pName, deployedService, pApplication, pJVMs, pDeploymentDescriptor); } // Public -------------------------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJB.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJB.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJB.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJB.java 2005-08-07 04:03:16.240017600 -0300 @@ -29,7 +29,7 @@ * @author Scott.Stark@jboss.org * @author thomas.diesler@jboss.org * @version $Revision: 1.14.6.1 $ - * @jmx:mbean extends="org.jboss.management.j2ee.J2EEManagedObjectMBean, org.jboss.management.j2ee.statistics.StatisticsProvider" + * @jmx:mbean extends="org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEManagedObjectMBean, org.jboss.management.j2ee.statistics.StatisticsProvider" */ public abstract class EJB extends J2EEManagedObject @@ -44,11 +44,6 @@ // Attributes ---------------------------------------------------- private static Logger log = Logger.getLogger(EJB.class); - /** - * The ObjectName of the ejb container MBean - */ - protected ObjectName ejbContainerName; - // Static -------------------------------------------------------- /** @@ -131,7 +126,7 @@ InvalidParentException { super(ejbType, ejbName, ejbModuleName); - this.ejbContainerName = ejbContainerName; + this.mService = ejbContainerName; } // Begin StatisticsProvider interface methods @@ -209,7 +204,7 @@ */ protected ObjectName getContainerName() { - return this.ejbContainerName; + return this.mService; } /** @@ -220,9 +215,9 @@ ObjectName cacheName = null; try { - Hashtable props = ejbContainerName.getKeyPropertyList(); + Hashtable props = mService.getKeyPropertyList(); props.put("plugin", "cache"); - cacheName = new ObjectName(ejbContainerName.getDomain(), props); + cacheName = new ObjectName(mService.getDomain(), props); } catch (MalformedObjectNameException e) { @@ -238,9 +233,9 @@ ObjectName poolName = null; try { - Hashtable props = ejbContainerName.getKeyPropertyList(); + Hashtable props = mService.getKeyPropertyList(); props.put("plugin", "pool"); - poolName = new ObjectName(ejbContainerName.getDomain(), props); + poolName = new ObjectName(mService.getDomain(), props); } catch (MalformedObjectNameException e) { diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBMBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBMBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBMBean.java 2005-05-17 18:03:44.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBMBean.java 2005-08-07 04:38:02.930531200 -0300 @@ -11,6 +11,7 @@ */ public interface EJBMBean extends + org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEManagedObjectMBean, org.jboss.management.j2ee.statistics.StatisticsProvider { diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBModule.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBModule.java 2005-08-07 05:36:22.682928000 -0300 @@ -28,14 +28,12 @@ * @author Scott.Stark@jboss.org * @author thomas.diesler@jboss.org * @version $Revision: 1.25.6.1 $ - * @jmx:mbean extends="org.jboss.management.j2ee.EventProvider, org.jboss.management.j2ee.J2EEModuleMBean" + * @jmx:mbean extends="org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEModuleMBean" */ public class EJBModule extends J2EEModule implements EJBModuleMBean { - private static final String[] eventTypes = {NotificationConstants.OBJECT_CREATED, - NotificationConstants.OBJECT_DELETED}; // Attributes ---------------------------------------------------- private static Logger log = Logger.getLogger(EJBModule.class); @@ -43,7 +41,6 @@ // list of object names as strings private List mEJBs = new ArrayList(); - private ObjectName moduleServiceName; private String mJBossDD; private String mJAWSDD; private String mCMPDD; @@ -104,6 +101,7 @@ if (parentApps.isEmpty()) { lCreated = J2EEApplication.create(mbeanServer, + null, earName, null); lParent = lCreated; @@ -213,8 +211,7 @@ MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.EJBModule, jarName, jsr77ParentName, pJVMs, pDeploymentDescriptor); - this.moduleServiceName = moduleServiceName; + super(J2EETypeConstants.EJBModule, jarName, jsr77ParentName, moduleServiceName, pJVMs, pDeploymentDescriptor); mJBossDD = (pJBossDD == null ? "" : pJBossDD); mJAWSDD = (pJAWSDD == null ? "" : pJAWSDD); mCMPDD = (pCMPDD == null ? "" : pCMPDD); @@ -300,33 +297,6 @@ } } - public void postCreation() - { - sendNotification(NotificationConstants.OBJECT_CREATED, "EJB Module created"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "EJB Module destroyed"); - } - - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return eventTypes; - } - - public String getEventType(int index) - { - String type = null; - if (index >= 0 && index < eventTypes.length) - { - type = eventTypes[index]; - } - return type; - } - // Object overrides --------------------------------------------------- public String toString() diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBModuleMBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBModuleMBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/EJBModuleMBean.java 2005-05-17 18:03:44.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/EJBModuleMBean.java 2005-08-07 04:42:54.880334400 -0300 @@ -9,9 +9,9 @@ /** * MBean interface. */ -public interface EJBModuleMBean +public interface EJBModuleMBean extends - org.jboss.management.j2ee.EventProvider, + org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEModuleMBean { diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/factory/EARModuleFactory.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/factory/EARModuleFactory.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/factory/EARModuleFactory.java 2005-08-02 20:34:36.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/factory/EARModuleFactory.java 2005-08-07 03:04:08.879163200 -0300 @@ -40,7 +40,8 @@ DeploymentInfo di = (DeploymentInfo) data; String moduleName = di.shortName; - ObjectName jsr77Name = J2EEApplication.create(server, moduleName, di.localUrl); + ObjectName jsr77Name = J2EEApplication.create(server, di.deployedObject, + moduleName, di.localUrl); deploymentToModuleNameMap.put(di, jsr77Name); if (jsr77Name != null) { diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/factory/RARModuleFactory.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/factory/RARModuleFactory.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/factory/RARModuleFactory.java 2005-08-02 20:34:36.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/factory/RARModuleFactory.java 2005-08-07 03:10:41.974406400 -0300 @@ -53,6 +53,7 @@ String rarName = di.shortName; ObjectName rarService = di.deployedObject; ObjectName jsr77ModuleName = ResourceAdapterModule.create(mbeanServer, + di.deployedObject, (di.parent == null ? null : di.parent.shortName), rarName, di.localUrl); diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEApplication.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEApplication.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEApplication.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEApplication.java 2005-08-07 03:19:46.026715200 -0300 @@ -26,7 +26,7 @@ * @version $Revision: 1.19.6.1 $ * @todo When all components of a J2EEApplication is state manageable * this have to be too !! - * @jmx:mbean extends="org.jboss.management.j2ee.J2EEDeployedObjectMBean" + * @jmx:mbean extends="org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEDeployedObjectMBean" */ public class J2EEApplication extends J2EEDeployedObject @@ -51,7 +51,8 @@ * jar/war/war without an ear * @return the JSR77 ObjectName for the J2EEApplication */ - public static ObjectName create(MBeanServer mbeanServer, String earName, URL url) + public static ObjectName create(MBeanServer mbeanServer, ObjectName deployedService, + String earName, URL url) { String lDD = null; ObjectName jsr77Name = null; @@ -61,7 +62,7 @@ try { // Now create the J2EEApplication - J2EEApplication j2eeApp = new J2EEApplication(earName, j2eeServerName, lDD); + J2EEApplication j2eeApp = new J2EEApplication(earName, j2eeServerName, deployedService, lDD); jsr77Name = j2eeApp.getObjectName(); /* Check to see if the ear is already registered. This will occur when an ear is deployed because we do not receive the ear module start @@ -127,10 +128,11 @@ * @param pDeploymentDescriptor * @throws InvalidParameterException If the given Name is null */ - public J2EEApplication(String name, ObjectName mbeanServer, String pDeploymentDescriptor) + public J2EEApplication(String name, ObjectName mbeanServer, ObjectName deployedService, + String pDeploymentDescriptor) throws MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.J2EEApplication, name, mbeanServer, pDeploymentDescriptor); + super(J2EETypeConstants.J2EEApplication, name, mbeanServer, deployedService, pDeploymentDescriptor); } // Public -------------------------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java 2005-05-17 18:03:44.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java 2005-08-07 04:42:15.834188800 -0300 @@ -10,7 +10,10 @@ * MBean interface. * @todo When all components of a J2EEApplication is state manageable this have to be too !! */ -public interface J2EEApplicationMBean extends org.jboss.management.j2ee.J2EEDeployedObjectMBean +public interface J2EEApplicationMBean + extends + org.jboss.management.j2ee.StateManageable, + org.jboss.management.j2ee.J2EEDeployedObjectMBean { java.lang.String[] getmodules(); diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEDeployedObject.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEDeployedObject.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEDeployedObject.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEDeployedObject.java 2005-08-07 02:52:36.062942400 -0300 @@ -143,6 +143,7 @@ public J2EEDeployedObject(String pType, String pName, ObjectName pParent, + ObjectName deployedService, String pDeploymentDescriptor) throws MalformedObjectNameException, @@ -150,6 +151,7 @@ { super(pType, pName, pParent); mDeploymentDescriptor = pDeploymentDescriptor; + mService = deployedService; } // Public -------------------------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEManagedObject.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEManagedObject.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEManagedObject.java 2005-08-02 21:17:08.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEManagedObject.java 2005-08-07 05:54:29.105126400 -0300 @@ -22,7 +22,11 @@ import org.jboss.logging.Logger; import org.jboss.management.j2ee.statistics.StatisticsProvider; import org.jboss.mx.util.JBossNotificationBroadcasterSupport; +import org.jboss.mx.util.MBeanProxy; import org.jboss.mx.util.ObjectNameConverter; +import org.jboss.system.ServiceContext; +import org.jboss.system.ServiceController; +import org.jboss.system.ServiceControllerMBean; /** * Root class of the JBoss JSR-77 implementation of J2EEManagedObject. @@ -48,6 +52,12 @@ private ObjectName name = null; /** Sequence number for jmx notifications we send out. */ private SynchronizedLong sequenceNumber = new SynchronizedLong(0); + + /** responsable fo SMO events and state */ + protected StateManagement mState; + + /** JBoss service that this ManagedObject represents */ + protected ObjectName mService; protected Logger log; protected MBeanServer server; @@ -187,10 +197,82 @@ lProperties.put(NAME, resName); name = ObjectNameConverter.convert(J2EEDomain.getDomainName(), lProperties); setparent(jsr77ParentName.getCanonicalName()); + mState = new StateManagement(this); } // Public -------------------------------------------------------- + // javax.managment.j2ee.EventProvider implementation ------------- + + public String[] getEventTypes() + { + return StateManagement.stateTypes; + } + + public String getEventType(int pIndex) + { + if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) + { + return StateManagement.stateTypes[pIndex]; + } + else + { + return null; + } + } + + // javax.management.j2ee.StateManageable implementation ---------- + + public long getStartTime() + { + return mState.getStartTime(); + } + + public int getState() + { + return mState.getState(); + } + public String getStateString() + { + return mState.getStateString(); + } + + public void mejbStart() + { + try + { + server.invoke(mService, + "start", + new Object[]{}, + new String[]{}); + } + catch (Exception e) + { + log.error("Start of URL Resource failed", e); + } + } + + public void mejbStartRecursive() + { + // No recursive start here + mejbStart(); + } + + public void mejbStop() + { + try + { + server.invoke(mService, + "stop", + new Object[]{}, + new String[]{}); + } + catch (Exception e) + { + log.error("Stop of URL Resource failed", e); + } + } + // J2EEManagedObjectMBean implementation ---------------------------------------------- public Logger getLog() @@ -400,13 +482,64 @@ // Package protected --------------------------------------------- // Protected ----------------------------------------------------- - protected void postCreation() { + try + { + if (mService != null) + { + boolean isListener = getServer().isInstanceOf(mService, + "javax.management.NotificationBroadcaster"); + if ((isListener) && (mService != null)) + { + getServer().addNotificationListener(mService, mState, null, null); + } + } + } + catch (Exception jme) + { + log.debug("Failed to register as listener of: " + mService, jme); + } + sendNotification(NotificationConstants.OBJECT_CREATED, "ManagedObject created"); + + // Initialize the state + try + { + ServiceControllerMBean controller = (ServiceControllerMBean) + MBeanProxy.get(ServiceControllerMBean.class, ServiceController.OBJECT_NAME, + getServer()); + if (mService != null) + { + ServiceContext context = controller.getServiceContext(mService); + int jsr77State = StateManagement.convertServiceContext(context.state); + mState.setState(jsr77State); + } + } + catch (Exception e) + { + log.trace("Failed to initialze state from: " + mService, e); + } } protected void preDestruction() { + sendNotification(NotificationConstants.OBJECT_DELETED, "ManagedObject destroyed"); + // Remove the listener of the target MBean + try + { + if (mService != null) + { + boolean isListener = getServer().isInstanceOf(mService, + "javax.management.NotificationBroadcaster"); + if (isListener) { + getServer().removeNotificationListener(mService, mState); + } + } + } + catch (JMException jme) + { + // When the service is not available anymore then just ignore the exception + } } /** diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/J2EEModule.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/J2EEModule.java 2005-08-07 03:04:47.514718400 -0300 @@ -47,13 +47,14 @@ public J2EEModule(String pType, String pName, ObjectName pParent, + ObjectName deployedService, String[] pJVMs, String pDeploymentDescriptor) throws MalformedObjectNameException, InvalidParentException { - super(pType, pName, pParent, pDeploymentDescriptor); + super(pType, pName, pParent, deployedService, pDeploymentDescriptor); mJVMs = new ArrayList(Arrays.asList(pJVMs == null ? new String[0] : pJVMs)); } diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JavaMailResource.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JavaMailResource.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JavaMailResource.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JavaMailResource.java 2005-08-07 02:46:34.082440000 -0300 @@ -37,9 +37,6 @@ // Attributes ---------------------------------------------------- - private StateManagement mState; - private ObjectName mailServiceName; - // Static -------------------------------------------------------- public static ObjectName create(MBeanServer mbeanServer, String resName, @@ -88,8 +85,7 @@ InvalidParentException { super(J2EETypeConstants.JavaMailResource, resName, j2eeServerName); - this.mailServiceName = mailServiceName; - mState = new StateManagement(this); + this.mService = mailServiceName; } // Public -------------------------------------------------------- @@ -100,7 +96,7 @@ public String getuserName() throws Exception { - return (String) server.getAttribute(mailServiceName, "User"); + return (String) server.getAttribute(mService, "User"); } /** @@ -109,7 +105,7 @@ public void setuserName(String pName) throws Exception { - server.setAttribute(mailServiceName, new Attribute("User", pName)); + server.setAttribute(mService, new Attribute("User", pName)); } /** @@ -118,7 +114,7 @@ public void setpassword(String pPassword) throws Exception { - server.setAttribute(mailServiceName, new Attribute("Password", pPassword)); + server.setAttribute(mService, new Attribute("Password", pPassword)); } /** @@ -127,7 +123,7 @@ public String getjndiName() throws Exception { - return (String) server.getAttribute(mailServiceName, "JNDIName"); + return (String) server.getAttribute(mService, "JNDIName"); } /** @@ -136,7 +132,7 @@ public void setjndiName(String pName) throws Exception { - server.setAttribute(mailServiceName, new Attribute("JNDIName", pName)); + server.setAttribute(mService, new Attribute("JNDIName", pName)); } /** @@ -145,7 +141,7 @@ public String getconfiguration() throws Exception { - return server.getAttribute(mailServiceName, "Configuration") + ""; + return server.getAttribute(mService, "Configuration") + ""; } /** @@ -161,7 +157,7 @@ DocumentBuilder lParser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputStream lInput = new ByteArrayInputStream(pConfigurationElement.getBytes()); Document lDocument = lParser.parse(lInput); - server.setAttribute(mailServiceName, new Attribute("Configuration", lDocument.getDocumentElement())); + server.setAttribute(mService, new Attribute("Configuration", lDocument.getDocumentElement())); } // javax.managment.j2ee.EventProvider implementation ------------- @@ -183,92 +179,6 @@ } } - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - public String getStateString() - { - return mState.getStateString(); - } - - public void mejbStart() - { - try - { - server.invoke(mailServiceName, - "start", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.error("start failed", e); - } - } - - public void mejbStartRecursive() - { - // No recursive start here - try - { - mejbStart(); - } - catch (Exception e) - { - log.error("start failed", e); - } - } - - public void mejbStop() - { - try - { - server.invoke(mailServiceName, - "stop", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.error("Stop of JavaMailResource failed", e); - } - } - - public void postCreation() - { - try - { - server.addNotificationListener(mailServiceName, mState, null, null); - } - catch (JMException e) - { - log.debug("Failed to add notification listener", e); - } - sendNotification(NotificationConstants.OBJECT_CREATED, "Java Mail Resource created"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "Java Mail Resource deleted"); - // Remove the listener of the target MBean - try - { - server.removeNotificationListener(mailServiceName, mState); - } - catch (JMException jme) - { - // When the service is not available anymore then just ignore the exception - } - } - // java.lang.Object overrides ------------------------------------ public String toString() diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JDBCDataSource.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JDBCDataSource.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JDBCDataSource.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JDBCDataSource.java 2005-08-07 02:47:38.334830400 -0300 @@ -32,8 +32,6 @@ // Attributes ---------------------------------------------------- - private StateManagement mState; - private ObjectName mService; private ObjectName mJdbcDriver; // Static -------------------------------------------------------- @@ -138,7 +136,6 @@ { super(J2EETypeConstants.JDBCDataSource, pName, pServer); mService = pService; - mState = new StateManagement(this); } // Public -------------------------------------------------------- @@ -162,84 +159,6 @@ } } - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - public String getStateString() - { - return mState.getStateString(); - } - - public void mejbStart() - { - try - { - getServer().invoke(mService, - "start", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - getLog().error("start failed", e); - } - } - - public void mejbStartRecursive() - { - mejbStart(); - } - - public void mejbStop() - { - try - { - getServer().invoke(mService, - "stop", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - getLog().error("Stop of JDBCDataSource failed", e); - } - } - - public void postCreation() - { - try - { - getServer().addNotificationListener(mService, mState, null, null); - } - catch (JMException jme) - { - getLog().debug("Could not add listener at target service", jme); - } - sendNotification(NotificationConstants.OBJECT_CREATED, "JDBC DataSource Resource deleted"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "JDBC DataSource Resource deleted"); - // Remove the listener of the target MBean - try - { - getServer().removeNotificationListener(mService, mState); - } - catch (JMException jme) - { - // When the service is not available anymore then just ignore the exception - } - } - // javax.management.j2ee.JDBCDataSource implementation ----------------- public ObjectName getJdbcDriver() diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JDBCResource.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JDBCResource.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JDBCResource.java 2005-08-05 18:03:14.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JDBCResource.java 2005-08-07 02:49:18.969536000 -0300 @@ -41,9 +41,6 @@ // Attributes ---------------------------------------------------- - private StateManagement mState; - private ObjectName mService; - // list of object names as strings private List mDataSources = new ArrayList(); @@ -121,46 +118,10 @@ InvalidParentException { super(J2EETypeConstants.JDBCResource, resName, pServer); - mState = new StateManagement(this); } // Public -------------------------------------------------------- - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return StateManagement.stateTypes; - } - - public String getEventType(int pIndex) - { - if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) - { - return StateManagement.stateTypes[pIndex]; - } - else - { - return null; - } - } - - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - public String getStateString() - { - return mState.getStateString(); - } - public void mejbStart() { // No component behind therefore just do it as it is started diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JNDIResource.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JNDIResource.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/JNDIResource.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/JNDIResource.java 2005-08-07 02:45:09.971494400 -0300 @@ -9,7 +9,6 @@ import org.jboss.logging.Logger; -import javax.management.JMException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -30,9 +29,6 @@ // Attributes ---------------------------------------------------- - private StateManagement mState; - private ObjectName jndiServiceName; - // Static -------------------------------------------------------- public static ObjectName create(MBeanServer mbeanServer, String resName, @@ -82,110 +78,11 @@ { super(J2EETypeConstants.JNDIResource, resName, mbeanServer); log.debug("Service name: " + jndiServiceName); - this.jndiServiceName = jndiServiceName; - mState = new StateManagement(this); + this.mService = jndiServiceName; } // Public -------------------------------------------------------- - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return StateManagement.stateTypes; - } - - public String getEventType(int pIndex) - { - if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) - { - return StateManagement.stateTypes[pIndex]; - } - else - { - return null; - } - } - - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - public String getStateString() - { - return mState.getStateString(); - } - - public void mejbStart() - { - try - { - server.invoke(jndiServiceName, - "start", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.debug("Start of JNDI Resource failed", e); - } - } - - public void mejbStartRecursive() - { - // No recursive start here - mejbStart(); - } - - public void mejbStop() - { - try - { - server.invoke(jndiServiceName, - "stop", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.debug("Stop of JNDI Resource failed", e); - } - } - - public void postCreation() - { - try - { - server.addNotificationListener(jndiServiceName, mState, null, null); - } - catch (JMException e) - { - log.debug("Failed to add notification listener", e); - } - sendNotification(NotificationConstants.OBJECT_CREATED, "JNDI Resource created"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "JNDI Resource destroyed"); - // Remove the listener of the target MBean - try - { - server.removeNotificationListener(jndiServiceName, mState); - } - catch (JMException jme) - { - // When the service is not available anymore then just ignore the exception - } - } - // java.lang.Object overrides ------------------------------------ public String toString() diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/MBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/MBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/MBean.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/MBean.java 2005-08-07 02:42:48.407936000 -0300 @@ -6,15 +6,19 @@ */ package org.jboss.management.j2ee; -import org.jboss.logging.Logger; -import org.jboss.mx.util.MBeanProxy; -import org.jboss.system.ServiceMBean; +import java.util.Hashtable; import javax.management.JMException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -import java.util.Hashtable; + +import org.jboss.logging.Logger; +import org.jboss.mx.util.MBeanProxy; +import org.jboss.system.ServiceContext; +import org.jboss.system.ServiceController; +import org.jboss.system.ServiceControllerMBean; +import org.jboss.system.ServiceMBean; /** * Root class of the JBoss implementation of a custom MBean managed object. @@ -33,11 +37,7 @@ // Attributes ---------------------------------------------------- private static Logger log = Logger.getLogger(MBean.class); - private ObjectName jbossServiceName; - private StateManagement mState; private boolean monitorsStateChanges = false; - /** Does the mbean have a State attribute */ - private boolean hasState; // Static -------------------------------------------------------- @@ -108,8 +108,7 @@ InvalidParentException { super(J2EETypeConstants.MBean, pName, pServiceModule); - mState = new StateManagement(this); - jbossServiceName = pTarget; + mService = pTarget; } /** @@ -124,133 +123,22 @@ return monitorsStateChanges; } - public boolean isstateManageable() - { - return hasState; - } - - // J2EEManagedObjectMBean implementation ------------------------- - public void postCreation() { try { - // First check if the service implements the NotificationBroadcaster - monitorsStateChanges = getServer().isInstanceOf(jbossServiceName, + monitorsStateChanges = getServer().isInstanceOf(mService, "javax.management.NotificationBroadcaster"); - if (monitorsStateChanges) - { - getServer().addNotificationListener(jbossServiceName, mState, null, null); - } } catch (Exception jme) { - log.debug("Failed to register as listener of: " + jbossServiceName, jme); - } - sendNotification(NotificationConstants.OBJECT_CREATED, "MBean created"); - - // Initialize the state - try - { - ServiceMBean mbean = (ServiceMBean) MBeanProxy.get(ServiceMBean.class, - this.jbossServiceName, getServer()); - int jbossState = mbean.getState(); - int jsr77State = StateManagement.convertJBossState(jbossState); - mState.setState(jsr77State); - } - catch (Exception e) - { - log.trace("Failed to initialze state from: " + jbossServiceName, e); - hasState = false; - } - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "MBean destroyed"); - // Remove the listener of the target MBean - try - { - if( monitorsStateChanges ) - getServer().removeNotificationListener(jbossServiceName, mState); - } - catch (JMException jme) - { - // When the service is not available anymore then just ignore the exception - } - } - - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return StateManagement.stateTypes; - } - - public String getEventType(int pIndex) - { - if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) - { - return StateManagement.stateTypes[pIndex]; - } - else - { - return null; - } - } - - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - - public String getStateString() - { - return mState.getStateString(); - } - - public void mejbStart() - { - try - { - getServer().invoke(jbossServiceName, - "start", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - getLog().error("Start of MBean failed", e); - } - } - - public void mejbStartRecursive() - { - // No recursive start here - mejbStart(); - } - - public void mejbStop() - { - try - { - getServer().invoke(jbossServiceName, - "stop", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - getLog().error("Stop of MBean failed", e); + log.debug("Failed to get monitor state: " + mService, jme); } + + super.postCreation(); } + + // J2EEManagedObjectMBean implementation ------------------------- // java.lang.Object overrides -------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ResourceAdapterModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ResourceAdapterModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ResourceAdapterModule.java 2004-04-20 06:17:12.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ResourceAdapterModule.java 2005-08-07 03:25:42.649513600 -0300 @@ -27,7 +27,7 @@ * @author Scott McLaughlin. * @author thomas.diesler@jboss.org * @version $Revision: 1.16 $ - * @jmx:mbean extends="org.jboss.management.j2ee.J2EEModuleMBean" + * @jmx:mbean extends="org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEModuleMBean" */ public class ResourceAdapterModule extends J2EEModule @@ -58,8 +58,8 @@ * @param pURL URL path to the local deployment of the module (where to find the DD file) * @return the JSR77 ObjectName of the RARModule */ - public static ObjectName create(MBeanServer mbeanServer, String earName, - String rarName, URL pURL) + public static ObjectName create(MBeanServer mbeanServer, ObjectName deployedService, + String earName, String rarName, URL pURL) { String lDD = null; ObjectName lParent = null; @@ -93,6 +93,7 @@ if (parentApps.size() == 0) { lCreated = J2EEApplication.create(mbeanServer, + null, earName, null); lParent = lCreated; @@ -120,7 +121,7 @@ // Now create the ResourceAdapterModule ResourceAdapterModule rarModule = new ResourceAdapterModule(rarName, - lParent, jvms, lDD); + lParent, deployedService, jvms, lDD); jsr77Name = rarModule.getObjectName(); mbeanServer.registerMBean(rarModule, jsr77Name); @@ -175,12 +176,12 @@ * @param pDeploymentDescriptor * @throws InvalidParameterException If the given Name is null */ - public ResourceAdapterModule(String rarName, ObjectName jsr77ParentName, + public ResourceAdapterModule(String rarName, ObjectName jsr77ParentName, ObjectName deployedService, String[] pJVMs, String pDeploymentDescriptor) throws MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.ResourceAdapterModule, rarName, jsr77ParentName, pJVMs, pDeploymentDescriptor); + super(J2EETypeConstants.ResourceAdapterModule, rarName, jsr77ParentName, deployedService, pJVMs, pDeploymentDescriptor); } // Public -------------------------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ResourceAdapterModuleMBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ResourceAdapterModuleMBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ResourceAdapterModuleMBean.java 2005-05-17 18:03:44.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ResourceAdapterModuleMBean.java 2005-08-07 04:43:48.287129600 -0300 @@ -9,7 +9,10 @@ /** * MBean interface. */ -public interface ResourceAdapterModuleMBean extends org.jboss.management.j2ee.J2EEModuleMBean +public interface ResourceAdapterModuleMBean + extends + org.jboss.management.j2ee.StateManageable, + org.jboss.management.j2ee.J2EEModuleMBean { java.lang.String[] getresourceAdapters(); diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ServiceModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ServiceModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/ServiceModule.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/ServiceModule.java 2005-08-07 03:14:17.995028800 -0300 @@ -112,7 +112,7 @@ throws MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.ServiceModule, moduleName, j2eeServerName, jvmNames, pDeploymentDescriptor); + super(J2EETypeConstants.ServiceModule, moduleName, j2eeServerName, null, jvmNames, pDeploymentDescriptor); } // Public -------------------------------------------------------- diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/StateManagement.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/StateManagement.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/StateManagement.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/StateManagement.java 2005-08-07 05:16:09.999174400 -0300 @@ -6,12 +6,14 @@ */ package org.jboss.management.j2ee; -import org.jboss.system.ServiceMBean; +import java.security.InvalidParameterException; import javax.management.AttributeChangeNotification; import javax.management.Notification; import javax.management.NotificationListener; -import java.security.InvalidParameterException; + +import org.jboss.system.ServiceContext; +import org.jboss.system.ServiceMBean; /** * Root class of the JBoss JSR-77 implementation of StateManagement @@ -99,6 +101,39 @@ } /** + * Converts a state from ServiceContext to the JSR-77 state + * + * @param theState the JBoss ServiceMBean state. + * @return Converted state or -1 if unknown. + */ + public static int convertServiceContext(int theState) + { + int jsr77State = -1; + switch (theState) + { + case ServiceContext.CREATED: + jsr77State = CREATED; + break; + case ServiceContext.RUNNING: + jsr77State = StateManageable.RUNNING; + break; + case ServiceContext.FAILED: + jsr77State = StateManageable.FAILED; + break; + case ServiceContext.STOPPED: + jsr77State = StateManageable.STOPPED; + break; + case ServiceContext.DESTROYED: + jsr77State = DESTROYED; + break; + default: + jsr77State = -1; + break; + } + return jsr77State; + } + + /** * Converts a JSR-77 state to the JBoss ServiceMBean state * * @param theState the JSR-77 state. diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/URLResource.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/URLResource.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/URLResource.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/URLResource.java 2005-08-07 02:17:18.588163200 -0300 @@ -31,9 +31,6 @@ // Attributes ---------------------------------------------------- private static Logger log = Logger.getLogger(URLResource.class); - private StateManagement mState; - private ObjectName mService; - // Static -------------------------------------------------------- public static ObjectName create(MBeanServer pServer, String pName, ObjectName pService) @@ -105,105 +102,6 @@ if (log.isDebugEnabled()) log.debug("Service name: " + pService); mService = pService; - mState = new StateManagement(this); - } - - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return StateManagement.stateTypes; - } - - public String getEventType(int pIndex) - { - if (pIndex >= 0 && pIndex < StateManagement.stateTypes.length) - { - return StateManagement.stateTypes[pIndex]; - } - else - { - return null; - } - } - - // javax.management.j2ee.StateManageable implementation ---------- - - public long getStartTime() - { - return mState.getStartTime(); - } - - public int getState() - { - return mState.getState(); - } - public String getStateString() - { - return mState.getStateString(); - } - - public void mejbStart() - { - try - { - server.invoke(mService, - "start", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.error("Start of URL Resource failed", e); - } - } - - public void mejbStartRecursive() - { - // No recursive start here - mejbStart(); - } - - public void mejbStop() - { - try - { - server.invoke(mService, - "stop", - new Object[]{}, - new String[]{}); - } - catch (Exception e) - { - log.error("Stop of URL Resource failed", e); - } - } - - public void postCreation() - { - try - { - server.addNotificationListener(mService, mState, null, null); - } - catch (JMException e) - { - log.debug("Failed to add notification listener", e); - } - sendNotification(NotificationConstants.OBJECT_CREATED, "URL Resource created"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "URL Resource deleted"); - // Remove the listener of the target MBean - try - { - server.removeNotificationListener(mService, mState); - } - catch (JMException jme) - { - // When the service is not available anymore then just ignore the exception - } } // java.lang.Object overrides ------------------------------------ diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/WebModule.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/WebModule.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/WebModule.java 2005-08-02 20:38:16.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/WebModule.java 2005-08-07 17:05:46.959779200 -0300 @@ -7,7 +7,12 @@ package org.jboss.management.j2ee; import org.jboss.logging.Logger; +import org.jboss.mx.util.MBeanProxy; +import org.jboss.system.ServiceContext; +import org.jboss.system.ServiceController; +import org.jboss.system.ServiceControllerMBean; +import javax.management.JMException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -26,16 +31,13 @@ * @author Scott.Stark@jboss.org * @author thomas.diesler@jboss.org * @version $Revision: 1.15.6.2 $ - * @jmx:mbean extends="org.jboss.management.j2ee.EventProvider, org.jboss.management.j2ee.J2EEModuleMBean" + * @jmx:mbean extends="org.jboss.management.j2ee.StateManageable, org.jboss.management.j2ee.J2EEModuleMBean" */ public class WebModule extends J2EEModule implements WebModuleMBean { - private static final String[] eventTypes = {NotificationConstants.OBJECT_CREATED, - NotificationConstants.OBJECT_DELETED}; - // Attributes ---------------------------------------------------- private static Logger log = Logger.getLogger(WebModule.class); @@ -101,6 +103,7 @@ if (lApplications.isEmpty()) { lCreated = J2EEApplication.create(mbeanServer, + null, earName, null); jsr77ParentName = lCreated; @@ -190,7 +193,7 @@ throws MalformedObjectNameException, InvalidParentException { - super(J2EETypeConstants.WebModule, warName, j2eeAppName, jvms, webDD); + super(J2EETypeConstants.WebModule, warName, webContainerName, j2eeAppName, jvms, webDD); this.jbossWebDD = (jbossWebDD == null ? "" : jbossWebDD); } @@ -252,33 +255,6 @@ } } - // javax.managment.j2ee.EventProvider implementation ------------- - - public String[] getEventTypes() - { - return eventTypes; - } - - public String getEventType(int index) - { - String type = null; - if (index >= 0 && index < eventTypes.length) - { - type = eventTypes[index]; - } - return type; - } - - public void postCreation() - { - sendNotification(NotificationConstants.OBJECT_CREATED, "Web module created"); - } - - public void preDestruction() - { - sendNotification(NotificationConstants.OBJECT_DELETED, "Web module destroyed"); - } - // Object overrides --------------------------------------------------- public String toString() diff -ru -x CVS jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/WebModuleMBean.java jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/WebModuleMBean.java --- jboss-4.0.3RC2-06-08-2005\management\src/main/org/jboss/management/j2ee/WebModuleMBean.java 2005-05-17 18:03:44.000000000 -0300 +++ jboss-4.0-patch\management\src/main/org/jboss/management/j2ee/WebModuleMBean.java 2005-08-07 06:14:16.903096000 -0300 @@ -9,10 +9,7 @@ /** * MBean interface. */ -public interface WebModuleMBean - extends - org.jboss.management.j2ee.EventProvider, - org.jboss.management.j2ee.J2EEModuleMBean +public interface WebModuleMBean extends org.jboss.management.j2ee.J2EEModuleMBean { /**