User: schaefera
Date: 01/11/26 13:46:51
Modified: src/main/org/jboss/management/j2ee EjbModule.java
J2EEApplication.java J2EEDeployedObject.java
J2EEManagedObject.java J2EEServer.java
Added: src/main/org/jboss/management/j2ee EjbModuleMBean.java
Log:
Added the next layer of the JSR-77 implementation. Right now the application
(EAR) as well as the EJB-Module is added and removed dynamically.
Revision Changes Path
1.3 +111 -25 jboss/src/main/org/jboss/management/j2ee/EjbModule.java
Index: EjbModule.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/EjbModule.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EjbModule.java 2001/11/20 07:01:39 1.2
+++ EjbModule.java 2001/11/26 21:46:51 1.3
@@ -1,16 +1,18 @@
/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.jboss.management.j2ee;
+import java.net.URL;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.j2ee.EJB;
@@ -21,26 +23,101 @@
import java.security.InvalidParameterException;
/**
-* This class is the connection between the JSR and the
-* JBoss specific implementation.
-*
-* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.2 $
-*/
+ * Root class of the JBoss JSR-77 implementation of
+ * {@link javax.management.j2ee.EjbModule EjbModule}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
+ * @version $Revision: 1.3 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines and implementing of the
+ * the create() and destroy() helper method
+ * </ul>
+ **/
public class EjbModule
extends J2EEModule
- implements javax.management.j2ee.EjbModule
+ implements EjbModuleMBean
{
- // -------------------------------------------------------------------------
- // Members
- // -------------------------------------------------------------------------
- private List mEJBs = new ArrayList();
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
+ private List mEJBs = new ArrayList();
+ // Static --------------------------------------------------------
+
+ public static ObjectName create( MBeanServer pServer, String pApplicationName,
String pName, URL pURL ) {
+ String lDD = null;
+ ObjectName lApplication = null;
+ try {
+ ObjectName lServer = (ObjectName) pServer.queryNames(
+ new ObjectName( J2EEManagedObject.getDomainName() +
":type=J2EEServer,*" ),
+ null
+ ).iterator().next();
+ String lServerName = lServer.getKeyPropertyList().get( "type" ) + "=" +
+ lServer.getKeyPropertyList().get( "name" );
+ System.out.println( "EjbModule.create(), server name: " + lServerName );
+ lApplication = (ObjectName) pServer.queryNames(
+ new ObjectName( J2EEManagedObject.getDomainName() +
":type=J2EEApplication" +
+ ",name=" + pApplicationName + "," + lServerName + ",*"
+ ),
+ null
+ ).iterator().next();
+ // First get the deployement descriptor
+ lDD = J2EEDeployedObject.getDeploymentDescriptor( pURL,
J2EEDeployedObject.EJB );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ try {
+ // Now create the J2EEApplication
+ return pServer.createMBean(
+ "org.jboss.management.j2ee.EjbModule",
+ null,
+ new Object[] {
+ pName,
+ lApplication,
+ lDD
+ },
+ new String[] {
+ String.class.getName(),
+ ObjectName.class.getName(),
+ String.class.getName()
+ }
+ ).getObjectName();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static void destroy( MBeanServer pServer, String pModuleName ) {
+ try {
+/*
+ // Find the Object to be destroyed
+ ObjectName lSearch = new ObjectName(
+ J2EEManagedObject.getDomainName() + ":type=EJBModule,name=" + pName +
",*"
+ );
+ ObjectName lEjbModule = (ObjectName) pServer.queryNames(
+ lSearch,
+ null
+ ).iterator().next();
+*/
+ // Now remove the EjbModule
+ pServer.unregisterMBean( new ObjectName( pModuleName ) );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
/**
* Constructor taking the Name of this Object
*
@@ -54,7 +131,7 @@
MalformedObjectNameException,
InvalidParentException
{
- super( "EjbModule", pName, pApplication, pDeploymentDescriptor );
+ super( "EJBModule", pName, pApplication, pDeploymentDescriptor );
/*
if( pEJBs == null || pEJBs.length == 0 ) {
throw new InvalidParameterException( "EJB list may not be null or empty" );
@@ -62,11 +139,11 @@
mEJBs = new ArrayList( Arrays.asList( pEJBs ) );
*/
}
-
- // -------------------------------------------------------------------------
- // EjbModule Implementation
- // -------------------------------------------------------------------------
+ // Public --------------------------------------------------------
+
+ // EJBModule implementation --------------------------------------
+
public EJB[] getEjbs() {
return (EJB[]) mEJBs.toArray( new EJB[ 0 ] );
}
@@ -82,10 +159,19 @@
}
}
+ // Object overrides ---------------------------------------------------
+
public String toString() {
return "EJBModule[ " + super.toString() +
"EJBs: " + mEJBs +
" ]";
}
-
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.4 +74 -45 jboss/src/main/org/jboss/management/j2ee/J2EEApplication.java
Index: J2EEApplication.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEApplication.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- J2EEApplication.java 2001/11/23 06:20:12 1.3
+++ J2EEApplication.java 2001/11/26 21:46:51 1.4
@@ -1,44 +1,51 @@
/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.jboss.management.j2ee;
-import java.io.InputStreamReader;
-import java.io.StringWriter;
import java.net.URL;
import java.security.InvalidParameterException;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
import javax.management.MalformedObjectNameException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
/**
-* This class is the connection between the JSR and the
-* JBoss specific implementation.
-*
-* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schafer</a>
-* @version $Revision: 1.3 $
-*/
+ * Root class of the JBoss JSR-77 implementation of
+ * {@link javax.management.j2ee.J2EEApplication J2EEApplication}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
+ * @version $Revision: 1.4 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines and implementing of the
+ * the destroy() helper method
+ * </ul>
+ **/
public class J2EEApplication
- extends J2EEDeployedObject
- implements J2EEApplicationMBean
+ extends J2EEDeployedObject
+ implements J2EEApplicationMBean
{
- // -------------------------------------------------------------------------
- // Members
- // -------------------------------------------------------------------------
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
private List mModules = new ArrayList();
- public static ObjectName create( MBeanServer pServer, String pName, URL pURL ) {
+ // Static --------------------------------------------------------
+
+ public static ObjectName create( MBeanServer pServer, String pName, String
pDescriptor ) {
String lDD = null;
ObjectName lServer = null;
try {
@@ -46,20 +53,6 @@
new ObjectName( J2EEManagedObject.getDomainName() +
":type=J2EEServer,*" ),
null
).iterator().next();
- // First get the deployement descriptor
- System.out.println( "URL: " + pURL.getFile() );
- JarFile lFile = new JarFile( pURL.getFile() );
- JarEntry lDDEntry = lFile.getJarEntry( "META-INF/application.xml" );
- if( lDDEntry != null ) {
- InputStreamReader lInput = new InputStreamReader( lFile.getInputStream(
lDDEntry ) );
- StringWriter lOutput = new StringWriter();
- char[] lBuffer = new char[ 1024 ];
- int lLength = 0;
- while( ( lLength = lInput.read( lBuffer ) ) > 0 ) {
- lOutput.write( lBuffer, 0, lLength );
- }
- lDD = lOutput.toString();
- }
}
catch( Exception e ) {
e.printStackTrace();
@@ -72,7 +65,7 @@
new Object[] {
pName,
lServer,
- lDD
+ pDescriptor
},
new String[] {
String.class.getName(),
@@ -82,14 +75,31 @@
).getObjectName();
}
catch( Exception e ) {
+ e.printStackTrace();
return null;
}
}
-
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
-
+
+ public static void destroy( MBeanServer pServer, String pName ) {
+ try {
+ // Find the Object to be destroyed
+ ObjectName lSearch = new ObjectName(
+ J2EEManagedObject.getDomainName() + ":type=J2EEApplication,name=" +
pName + ",*"
+ );
+ ObjectName lApplication = (ObjectName) pServer.queryNames(
+ lSearch,
+ null
+ ).iterator().next();
+ // Now remove the J2EEApplication
+ pServer.unregisterMBean( lApplication );
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ // Constructors --------------------------------------------------
+
/**
* Constructor taking the Name of this Object
*
@@ -107,7 +117,9 @@
}
// Public --------------------------------------------------------
-
+
+ // J2EEApplication implementation --------------------------------
+
public ObjectName[] getModules() {
return (ObjectName[]) mModules.toArray( new ObjectName[ 0 ] );
}
@@ -120,9 +132,10 @@
return null;
}
+ // J2EEManagedObjectMBean implementation -------------------------
+
public void addChild( ObjectName pChild ) {
- Hashtable lProperties = pChild.getKeyPropertyList();
- String lType = lProperties.get( "type" ) + "";
+ String lType = J2EEManagedObject.getType( pChild );
if( "EJBModule".equals( lType ) ) {
mModules.add( pChild );
} else if( "WebModule".equals( lType ) ) {
@@ -133,13 +146,29 @@
}
public void removeChild( ObjectName pChild ) {
- //AS ToDo
+ String lType = J2EEManagedObject.getType( pChild );
+ if( "EJBModule".equals( lType ) ) {
+ mModules.remove( pChild );
+ } else if( "WebModule".equals( lType ) ) {
+ mModules.remove( pChild );
+ } else if( "ConnectorModule".equals( lType ) ) {
+ mModules.remove( pChild );
+ }
}
+ // Object overrides ---------------------------------------------------
+
public String toString() {
return "J2EEApplication { " + super.toString() + " } [ " +
"modules: " + mModules +
" ]";
}
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.3 +101 -11 jboss/src/main/org/jboss/management/j2ee/J2EEDeployedObject.java
Index: J2EEDeployedObject.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEDeployedObject.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- J2EEDeployedObject.java 2001/11/20 07:01:39 1.2
+++ J2EEDeployedObject.java 2001/11/26 21:46:51 1.3
@@ -1,22 +1,102 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.jboss.management.j2ee;
+// import java.io.File;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
+// import java.util.jar.JarEntry;
+// import java.util.jar.JarFile;
+
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+/**
+ * Root class of the JBoss JSR-77 implementation of
+ * {@link javax.management.j2ee.J2EEDeployedObject J2EEDeployedObject}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
+ * @version $Revision: 1.3 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines and adding the static method
+ * to load a Deployment Descriptor
+ * </ul>
+ **/
public abstract class J2EEDeployedObject
extends J2EEManagedObject
implements javax.management.j2ee.J2EEDeployedObject
{
- // -------------------------------------------------------------------------
- // Members
- // -------------------------------------------------------------------------
+ // Constants -----------------------------------------------------
+
+ public static final int APPLICATION = 0;
+ public static final int WEB = 1;
+ public static final int EJB = 2;
+ public static final int RAR = 3;
+
+ private static final String[] sDescriptors = new String[] {
+ "META-INF/application.xml",
+ "WEB-INF/web.xml",
+ "META-INF/ejb-jar.xml",
+ "META-INF/??AS??.xml"
+ };
+
+ // Attributes ----------------------------------------------------
private String mDeploymentDescriptor;
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
+ // Static --------------------------------------------------------
+
+ public static String getDeploymentDescriptor( URL pJarUrl, int pType ) {
+ String lDD = null;
+ InputStreamReader lInput = null;
+ StringWriter lOutput = null;
+ try {
+ // First get the deployement descriptor
+ System.out.println( "File: " + pJarUrl + ", descriptor: " + sDescriptors[
pType ] );
+ ClassLoader localCl = new URLClassLoader( new URL[] { pJarUrl } );
+ lInput = new InputStreamReader( localCl.getResourceAsStream( sDescriptors[
pType ] ) );
+ lOutput = new StringWriter();
+ char[] lBuffer = new char[ 1024 ];
+ int lLength = 0;
+ while( ( lLength = lInput.read( lBuffer ) ) > 0 ) {
+ lOutput.write( lBuffer, 0, lLength );
+ }
+ lDD = lOutput.toString();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ finally {
+ if( lInput != null ) {
+ try {
+ lInput.close();
+ }
+ catch( Exception e ) {
+ }
+ }
+ if( lOutput != null ) {
+ try {
+ lOutput.close();
+ }
+ catch( Exception e ) {
+ }
+ }
+ }
+ return lDD;
+ }
+ // Constructors --------------------------------------------------
+
/**
* Constructor taking the Name of this Object
*
@@ -38,19 +118,29 @@
super( pType, pName, pParent );
mDeploymentDescriptor = pDeploymentDescriptor;
}
-
- // -------------------------------------------------------------------------
- // Properties (Getters/Setters)
- // -------------------------------------------------------------------------
-
+
+ // Public --------------------------------------------------------
+
+ // javax.management.j2ee.J2EEDeployedObject implementation -------
+
public String getDeploymentDescriptor() {
return mDeploymentDescriptor;
}
+ // java.lang.Object overrides ------------------------------------
+
public String toString() {
return "J2EEDeployedObject { " + super.toString() + " } [ " +
"deployment descriptor: " + mDeploymentDescriptor +
" ]";
}
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.5 +118 -71 jboss/src/main/org/jboss/management/j2ee/J2EEManagedObject.java
Index: J2EEManagedObject.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEManagedObject.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- J2EEManagedObject.java 2001/11/23 06:20:12 1.4
+++ J2EEManagedObject.java 2001/11/26 21:46:51 1.5
@@ -1,9 +1,9 @@
/*
-* JBoss, the OpenSource J2EE webOS
-*
-* Distributable under LGPL license.
-* See terms of license at gnu.org.
-*/
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.jboss.management.j2ee;
import java.io.Serializable;
@@ -22,43 +22,64 @@
import org.jboss.system.ServiceMBeanSupport;
/**
-* JBoss specific implementation.
-*
-* @author Marc Fleury
-**/
+ * Root class of the JBoss JSR-77 implementation of
+ * {@link javax.management.j2ee.J2EEManagedObject J2EEManagedObject}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
+ * @version $Revision: 1.5 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines as well as adding some
+ * static helper methods
+ * </ul>
+ **/
public abstract class J2EEManagedObject
extends ServiceMBeanSupport
implements javax.management.j2ee.J2EEManagedObject, Serializable
{
- // -------------------------------------------------------------------------
- // Static
- // -------------------------------------------------------------------------
+
+ // Constants -----------------------------------------------------
- private static String sDomainName = null;
-// protected static MBeanServer sServer = null;
+ public static final String TYPE = "type";
+ public static final String NAME = "name";
- public static String getDomainName() {
- return sDomainName;
- }
+ // Attributes ----------------------------------------------------
-/*
- public static MBeanServer getServer() {
- return sServer;
- }
-*/
-
- // -------------------------------------------------------------------------
- // Members
- // -------------------------------------------------------------------------
-
private ObjectName mParent = null;
private ObjectName mName = null;
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
+ // Static --------------------------------------------------------
+
+ private static String sDomainName = null;
+
+ public static String getDomainName() {
+ return sDomainName;
+ }
/**
+ * Retrieves the type out of an JSR-77 object name
+ *
+ * @param pName Object Name to check if null then
+ * it will be treated like NO type found
+ *
+ * @return The type of the given Object Name or an EMPTY
+ * string if either Object Name null or type not found
+ **/
+ protected static String getType( ObjectName pName ) {
+ String lType = null;
+ if( pName != null ) {
+ lType = (String) pName.getKeyPropertyList().get( TYPE );
+ }
+ // Return an empty string if type not found
+ return lType == null ? "" : lType;
+ }
+
+ // Constructors --------------------------------------------------
+
+ /**
* Constructor for the root J2EEManagement object
*
* @param pDomainName Name of the domain
@@ -76,8 +97,8 @@
}
sDomainName = pDomainName;
Hashtable lProperties = new Hashtable();
- lProperties.put( "type", pType );
- lProperties.put( "name", pName );
+ lProperties.put( TYPE, pType );
+ lProperties.put( NAME, pName );
mName = new ObjectName( getDomainName(), lProperties );
System.out.println( "J2EEManagedObject(), create root with name: " + mName );
}
@@ -97,40 +118,50 @@
MalformedObjectNameException,
InvalidParentException
{
- try {
Hashtable lProperties = (Hashtable) pParent.getKeyPropertyList().clone();
- System.out.println( "J2EEManagedObject(), parent properties: " + lProperties
);
- System.out.println( "J2EEManagedObject(), parent type: " + lProperties.get(
"type" ) );
- System.out.println( "J2EEManagedObject(), parent name: " + lProperties.get(
"name" ) );
lProperties.put( lProperties.get( "type" ), lProperties.get( "name" ) );
- lProperties.put( "type", pType );
- lProperties.put( "name", pName );
+ lProperties.put( TYPE, pType );
+ lProperties.put( NAME, pName );
mName = new ObjectName( getDomainName(), lProperties );
- System.out.println( "J2EEManagedObject(), properties: " + lProperties );
setParent( pParent );
- }
- catch( Exception e ) {
- e.printStackTrace();
- }
}
-
- // -------------------------------------------------------------------------
- // Properties (Getters/Setters)
- // -------------------------------------------------------------------------
- public String getName() {
- return mName.toString();
- }
+ // Public --------------------------------------------------------
+
+ // J2EEManagedObjectMBean implementation
----------------------------------------------
public ObjectName getObjectName() {
System.out.println( "J2EEManagedObject.getObjectName(), name: " + mName );
return mName;
}
- public ObjectName getObjectName( MBeanServer pServer, ObjectName pName ) {
- return getObjectName();
+ public ObjectName getParent() {
+ return mParent;
+ }
+
+ public void setParent( ObjectName pParent )
+ throws
+ InvalidParentException
+ {
+ if( pParent == null ) {
+ throw new InvalidParameterException( "Parent must be set" );
+ }
+ mParent = pParent;
+ }
+
+ public void addChild( ObjectName pChild ) {
+ //AS ToDo: Remove later is just here to compile
+ }
+ public void removeChild( ObjectName pChild ) {
+ //AS ToDo: Remove later is just here to compile
}
+ // J2EEManagedObject implementation
----------------------------------------------
+
+ public String getName() {
+ return mName.toString();
+ }
+
public boolean isStateManageable() {
return this instanceof StateManageable;
}
@@ -142,23 +173,11 @@
public boolean isEventProvider() {
return this instanceof EventProvider;
}
-
- public String toString() {
- return "J2EEManagedObject [ name: " + mName + ", parent: " + mParent + " ];";
- }
- public ObjectName getParent() {
- return mParent;
- }
+ // ServiceMBeanSupport overrides
---------------------------------------------------
- public void setParent( ObjectName pParent )
- throws
- InvalidParentException
- {
- if( pParent == null ) {
- throw new InvalidParameterException( "Parent must be set" );
- }
- mParent = pParent;
+ public ObjectName getObjectName( MBeanServer pServer, ObjectName pName ) {
+ return getObjectName();
}
public void postRegister( java.lang.Boolean pRegistrationDone ) {
@@ -182,10 +201,38 @@
}
}
- public void addChild( ObjectName pChild ) {
- //AS ToDo: Remove later is just here to compile
+ public void preDeregister()
+ throws Exception
+ {
+ System.out.println( "J2EEManagedObject.preDeregister(), parent: " + mParent );
+ try {
+ // Only remove child if it is a child (root has not parent)
+ if( mParent != null ) {
+ // Notify the parent about its new child
+ getServer().invoke(
+ mParent,
+ "removeChild",
+ new Object[] { mName },
+ new String [] { ObjectName.class.getName() }
+ );
+ }
+ }
+ catch( JMException jme ) {
+ jme.printStackTrace();
+ }
}
- public void removeChild( ObjectName pChild ) {
- //AS ToDo: Remove later is just here to compile
+
+ // Object overrides ---------------------------------------------------
+
+ public String toString() {
+ return "J2EEManagedObject [ name: " + mName + ", parent: " + mParent + " ];";
}
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.4 +49 -39 jboss/src/main/org/jboss/management/j2ee/J2EEServer.java
Index: J2EEServer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEServer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- J2EEServer.java 2001/11/23 06:20:12 1.3
+++ J2EEServer.java 2001/11/26 21:46:51 1.4
@@ -1,3 +1,9 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
package org.jboss.management.j2ee;
import java.util.ArrayList;
@@ -9,20 +15,28 @@
import javax.management.ObjectName;
/**
-* Is the access point to management information for a single J2EE Server
-* Core implementation representing a logical core server of one instance
-* of a J2EE platform product.
-*
-* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
-**/
+ * JBoss implementation of the JSR-77 {@link javax.management.j2ee.J2EEServer
+ * J2EEServer}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
+ * @version $Revision: 1.4 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines and adding of the
+ * {@link #removeChild removeChild()} implementation.
+ * </ul>
+ **/
public class J2EEServer
extends J2EEManagedObject
implements J2EEServerMBean
{
- // -------------------------------------------------------------------------
- // Members
- // -------------------------------------------------------------------------
+ // Constants -----------------------------------------------------
+ // Attributes ----------------------------------------------------
+
private List mApplications = new ArrayList();
private List mResources = new ArrayList();
@@ -33,43 +47,20 @@
private String mJ2eeVendor = null;
- // -------------------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------------------
+ // Static --------------------------------------------------------
- public J2EEServer( String pName, ObjectName pDomain, String pJ2eeVendor )
- throws
- MalformedObjectNameException,
- InvalidParentException
- {
- super( "J2EEServer", pName, pDomain );
- mJ2eeVendor = pJ2eeVendor;
- }
+ // Constructors --------------------------------------------------
- public J2EEServer(
- String pName,
- ObjectName pDomain,
- ObjectName[] pApplications,
- ObjectName[] pResources,
- ObjectName[] pNodes,
- ObjectName[] pJVMs,
- String pJ2eeVendor
- )
+ public J2EEServer( String pName, ObjectName pDomain, String pJ2eeVendor )
throws
MalformedObjectNameException,
InvalidParentException
{
super( "J2EEServer", pName, pDomain );
- mApplications.addAll( Arrays.asList( pApplications ) );
- mResources.addAll( Arrays.asList( pResources ) );
- mNodes.addAll( Arrays.asList( pNodes ) );
- mJVMs.addAll( Arrays.asList( pJVMs ) );
mJ2eeVendor = pJ2eeVendor;
}
- // -------------------------------------------------------------------------
- // Properties (Getters/Setters)
- // -------------------------------------------------------------------------
+ // Public --------------------------------------------------------
public ObjectName[] getApplications() {
return (ObjectName[]) mApplications.toArray( new ObjectName[ 0 ] );
@@ -120,8 +111,7 @@
}
public void addChild( ObjectName pChild ) {
- Hashtable lProperties = pChild.getKeyPropertyList();
- String lType = lProperties.get( "type" ) + "";
+ String lType = J2EEManagedObject.getType( pChild );
if( "J2EEApplication".equals( lType ) ) {
mApplications.add( pChild );
} else if( "Node".equals( lType ) ) {
@@ -134,7 +124,16 @@
}
public void removeChild( ObjectName pChild ) {
- //AS ToDo
+ String lType = J2EEManagedObject.getType( pChild );
+ if( "J2EEApplication".equals( lType ) ) {
+ mApplications.remove( pChild );
+ } else if( "Node".equals( lType ) ) {
+ mNodes.remove( pChild );
+ } else if( "JVM".equals( lType ) ) {
+ mJVMs.remove( pChild );
+ } else if( "Resource".equals( lType ) ) {
+ mResources.remove( pChild );
+ }
}
public String toString() {
@@ -147,4 +146,15 @@
" ]";
}
+ // Z implementation ----------------------------------------------
+
+ // Y overrides ---------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
}
1.1 jboss/src/main/org/jboss/management/j2ee/EjbModuleMBean.java
Index: EjbModuleMBean.java
===================================================================
package org.jboss.management.j2ee;
import javax.management.j2ee.EjbModule;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
**/
public interface EjbModuleMBean
extends EjbModule, J2EEManagedObjectMBean
{
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development