User: schaefera
  Date: 01/11/20 20:50:53

  Modified:    src/main/org/jboss/management/j2ee IpAddress.java
                        J2EEManagedObject.java J2EEServer.java Node.java
                        SingleJBossServerManagement.java
  Added:       src/main/org/jboss/management/j2ee NodeMBean.java
  Log:
  Added a Node to JSR-77 implementation and added the mbean example to
  jboss-service.xml to test it.
  
  Revision  Changes    Path
  1.3       +1 -1      jboss/src/main/org/jboss/management/j2ee/IpAddress.java
  
  Index: IpAddress.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/IpAddress.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IpAddress.java    2001/11/20 07:01:39     1.2
  +++ IpAddress.java    2001/11/21 04:50:53     1.3
  @@ -40,7 +40,7 @@
      {
         super( "IpAddress", pName, pNode );
         if( pAddress == null || pAddress.length() == 0 ) {
  -         throw new InvalidParameterException( "There driver must always be defined" 
);
  +         throw new InvalidParameterException( "There IP-Address must always be 
defined" );
         }
         mAddress = pAddress;
      }
  
  
  
  1.3       +3 -7      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- J2EEManagedObject.java    2001/11/20 07:01:39     1.2
  +++ J2EEManagedObject.java    2001/11/21 04:50:53     1.3
  @@ -162,7 +162,6 @@
      }
      
      public void postRegister( java.lang.Boolean pRegistrationDone ) {
  -      super.postRegister( pRegistrationDone );
         System.out.println( "J2EEManagedObject.postRegister(), parent: " + mParent );
         if( pRegistrationDone.booleanValue() && mParent != null ) {
            try {
  @@ -173,15 +172,12 @@
                  new Object[] { mName },
                  new String [] { ObjectName.class.getName() }
               );
  +            super.postRegister( pRegistrationDone );
            }
            catch( JMException jme ) {
               jme.printStackTrace();
  -/*
  -            throw new InvalidParentException(
  -               "Problem to notify the parent about its new child",
  -               jme
  -            );
  -*/
  +            // Stop it because of the error
  +            super.postRegister( new Boolean( false ) );
            }
         }
      }
  
  
  
  1.2       +21 -78    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- J2EEServer.java   2001/11/20 07:01:39     1.1
  +++ J2EEServer.java   2001/11/21 04:50:53     1.2
  @@ -2,6 +2,7 @@
   
   import java.util.ArrayList;
   import java.util.Arrays;
  +import java.util.Hashtable;
   import java.util.List;
   
   import javax.management.MalformedObjectNameException;
  @@ -28,8 +29,6 @@
      
      private List mNodes = new ArrayList();
      
  -   private List mPorts = new ArrayList();
  -   
      private List mJVMs = new ArrayList();
      
      private String mJ2eeVendor = null;
  @@ -38,12 +37,13 @@
      // Constructors
      // -------------------------------------------------------------------------
      
  -   public J2EEServer( String pName, ObjectName pDomain )
  +   public J2EEServer( String pName, ObjectName pDomain, String pJ2eeVendor )
         throws
            MalformedObjectNameException,
            InvalidParentException
      {
         super( "J2EEServer", pName, pDomain );
  +      mJ2eeVendor = pJ2eeVendor;
      }
      
      public J2EEServer(
  @@ -52,7 +52,6 @@
         ObjectName[] pApplications,
         ObjectName[] pResources,
         ObjectName[] pNodes,
  -      ObjectName[] pPorts,
         ObjectName[] pJVMs,
         String pJ2eeVendor
      )
  @@ -64,7 +63,6 @@
         mApplications.addAll( Arrays.asList( pApplications ) );
         mResources.addAll( Arrays.asList( pResources ) );
         mNodes.addAll( Arrays.asList( pNodes ) );
  -      mPorts.addAll( Arrays.asList( pPorts ) );
         mJVMs.addAll( Arrays.asList( pJVMs ) );
         mJ2eeVendor = pJ2eeVendor;
      }
  @@ -73,22 +71,10 @@
      // Properties (Getters/Setters)
      // -------------------------------------------------------------------------  
   
  -   /**
  -   * @return The actual list of Applications deployed on this server. The
  -   *          list is never null but maybe empty.
  -   **/
      public ObjectName[] getApplications() {
         return (ObjectName[]) mApplications.toArray( new ObjectName[ 0 ] );
      }
   
  -   /**
  -   * Looks up an application with the given index
  -   *
  -   * @param pIndex Index of the requested application
  -   *
  -   * @return Application found for the given index or null
  -   *         if index is out of bounds.
  -   **/
      public ObjectName getApplication( int pIndex ) {
         if( pIndex >= 0 && pIndex < mApplications.size() ) {
            return (ObjectName) mApplications.get( pIndex );
  @@ -96,43 +82,10 @@
         return null;
      }
   
  -   /**
  -   * @return The actual list of Ports which is never null
  -   **/
  -   public ObjectName[] getPorts() {
  -      return (ObjectName[]) mPorts.toArray( new ObjectName[ 0 ] );
  -   }
  -
  -   /**
  -   * Looks up an Port with the given index
  -   *
  -   * @param pIndex Index of the requested Port
  -   *
  -   * @return Port found for the given index or null
  -   *         if index is out of bounds.
  -   **/
  -   public ObjectName getPort( int pIndex ) {
  -      if( pIndex >= 0 && pIndex < mPorts.size() ) {
  -         return (ObjectName) mPorts.get( pIndex );
  -      }
  -      return null;
  -   }
  -
  -   /**
  -   * @return The actual list of Nodes which is never null
  -   **/
      public ObjectName[] getNodes() {
         return (ObjectName[]) mNodes.toArray( new ObjectName[ 0 ] );
      }
   
  -   /**
  -   * Looks up an Node with the given index
  -   *
  -   * @param pIndex Index of the requested Node
  -   *
  -   * @return Node found for the given index or null
  -   *         if index is out of bounds.
  -   **/
      public ObjectName getNode( int pIndex ) {
         if( pIndex >= 0 && pIndex < mNodes.size() ) {
            return (ObjectName) mNodes.get( pIndex );
  @@ -140,22 +93,10 @@
         return null;
      }
   
  -   /**
  -   * @return The actual list of Resources which is never null
  -   *
  -   **/
      public ObjectName[] getResources() {
         return (ObjectName[]) mResources.toArray( new ObjectName[ 0 ] );
      }
   
  -   /**
  -   * Looks up an Resource with the given index
  -   *
  -   * @param pIndex Index of the requested Resource
  -   *
  -   * @return Resource found for the given index or null
  -   *         if index is out of bounds.
  -   **/
      public ObjectName getResource( int pIndex ) {
         if( pIndex >= 0 && pIndex < mResources.size() ) {
            return (ObjectName) mResources.get( pIndex );
  @@ -163,21 +104,10 @@
         return null;
      }
   
  -   /**
  -   * @return The actual list of JavaVMs which is never empty
  -   **/
      public ObjectName[] getJavaVMs() {
         return (ObjectName[]) mJVMs.toArray( new ObjectName[ 0 ] );
      }
   
  -   /**
  -   * Looks up an JVM with the given index
  -   *
  -   * @param pIndex Index of the requested JVM
  -   *
  -   * @return JVM found for the given index or null
  -   *         if index is out of bounds.
  -   **/
      public ObjectName getJavaVM( int pIndex ) {
         if( pIndex >= 0 && pIndex < mJVMs.size() ) {
            return (ObjectName) mJVMs.get( pIndex );
  @@ -185,20 +115,33 @@
         return null;
      }
   
  -   /**
  -   * @return The Indentifications of the J2EE plattform vendor or
  -   *         this server.
  -   **/
      public String getJ2eeVendor() {
         return mJ2eeVendor;
      }
      
  +   public void addChild( ObjectName pChild ) {
  +      Hashtable lProperties = pChild.getKeyPropertyList();
  +      String lType = lProperties.get( "type" ) + "";
  +      if( "Application".equals( lType ) ) {
  +         mApplications.add( pChild );
  +      } else if( "Node".equals( lType ) ) {
  +         mNodes.add( pChild );
  +      } else if( "JVM".equals( lType ) ) {
  +         mJVMs.add( pChild );
  +      } else if( "Resource".equals( lType ) ) {
  +         mResources.add( pChild );
  +      }
  +   }
  +   
  +   public void removeChild( ObjectName pChild ) {
  +      //AS ToDo
  +   }
  +
      public String toString() {
         return "J2EEServer { " + super.toString() + " } [ " +
            "applications: " + mApplications +
            ", resources: " + mResources +
            ", nodes: " + mNodes +
  -         ", ports: " + mPorts +
            ", JVMs: " + mJVMs +
            ", J2EE vendor: " + mJ2eeVendor +
            " ]";
  
  
  
  1.3       +37 -23    jboss/src/main/org/jboss/management/j2ee/Node.java
  
  Index: Node.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/Node.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Node.java 2001/11/20 07:01:39     1.2
  +++ Node.java 2001/11/21 04:50:53     1.3
  @@ -11,24 +11,20 @@
   import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
   
  -import javax.management.j2ee.IpAddress;
  -import javax.management.j2ee.JVM;
  -
   /**
   * @author Marc Fleury
   **/
   public class Node
      extends J2EEManagedObject
  -   implements javax.management.j2ee.Node
  +   implements NodeMBean
   {
      // -------------------------------------------------------------------------
      // Members
      // -------------------------------------------------------------------------  
   
  -   private String hardwareType;
  -   private IpAddress[] ipAddresses;
  -   private JVM[] javaVMs;
  -   private String osType;
  +   private String mHardwareType;
  +   private ObjectName[] mIPAddressList;
  +   private String mOSType;
   
      // -------------------------------------------------------------------------
      // Constructors
  @@ -38,23 +34,24 @@
      * @param pName Name of the Node
      * @param pHardwareType Type of Hardware
      * @param pOsType Type of the OS
  -   * @param pJavaVMs List of Java VMs
      * @param pIpAddresses List of IP Addresses
      *
      * @throws InvalidParameterException If list of IPAddresses or Java VMs is null 
or empty
      **/
  -   public Node( String pName, ObjectName pServer, String pHardwareType, String 
pOsType, JVM[] pJavaVMs, IpAddress[] pIpAddresses )
  +   public Node( String pName, ObjectName pServer, String pHardwareType, String 
pOsType, ObjectName[] pIpAddresses )
         throws
            MalformedObjectNameException,
            InvalidParentException
      {
         super( "Node", pName, pServer );
  -      hardwareType = pHardwareType;
  +      mHardwareType = pHardwareType;
  +/*
         if( pIpAddresses == null || pIpAddresses.length == 0 ) {
            throw new InvalidParameterException( "There must always be at least one 
IpAddress defined" );
         }
  -      ipAddresses = pIpAddresses;
  -       osType = pOsType;
  +*/
  +      mIPAddressList = pIpAddresses;
  +      mOSType = pOsType;
      }
   
      // -------------------------------------------------------------------------
  @@ -62,23 +59,42 @@
      // -------------------------------------------------------------------------  
   
      public String getHardwareType() {
  -      return hardwareType;
  +      return mHardwareType;
  +   }
  +
  +   public String getOsType() {
  +      return mOSType;
      }
   
  -   public IpAddress[] getIpAddresses() {
  -      return ipAddresses;
  +   public ObjectName[] getIpAddresses() {
  +      return mIPAddressList;
      }
   
  -   public IpAddress getIpAddress( int pIndex ) {
  -      if( pIndex >= 0 && pIndex < ipAddresses.length ) {
  -         return ipAddresses[ pIndex ];
  +   public ObjectName getIpAddress( int pIndex ) {
  +      if( pIndex >= 0 && pIndex < mIPAddressList.length ) {
  +         return mIPAddressList[ pIndex ];
         } else {
            return null;
         }
      }
   
  -   public String getOsType() {
  -      return osType;
  +   public void addChild( ObjectName pChild ) {
  +/*
  +      Hashtable lProperties = pChild.getKeyPropertyList();
  +      String lType = lProperties.get( "type" ) + "";
  +      if( "J2EEApplication".equals( lType ) ) {
  +         m
  +         mApplications.add( pChild );
  +      } else if( "J2EEDeployments".equals( lType ) ) {
  +         mDeployments.add( pChild );
  +      } else if( "J2EEServer".equals( lType ) ) {
  +         mServers.add( pChild );
  +      }
  +*/
  +   }
  +   
  +   public void removeChild( ObjectName pChild ) {
  +      //AS ToDo
      }
   
      public String toString() {
  @@ -86,8 +102,6 @@
            "name: " + getName() +
            ", hardware type: " + getHardwareType() +
            ", os type: " + getOsType() +
  -         // Do not change to java.util.Arrays.asList() because this
  -         // would create an endless loop !!
            ", IP addresses: " + getIpAddresses() +
            " ]";
      }
  
  
  
  1.2       +30 -10    
jboss/src/main/org/jboss/management/j2ee/SingleJBossServerManagement.java
  
  Index: SingleJBossServerManagement.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/SingleJBossServerManagement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SingleJBossServerManagement.java  2001/11/20 07:01:39     1.1
  +++ SingleJBossServerManagement.java  2001/11/21 04:50:53     1.2
  @@ -42,20 +42,40 @@
            System.out.println( "SingleJBossServerManagement.getObjectName(), name: " 
+ getObjectName() );
            try {
               System.out.println( "SingleJBossServerManagement.getObjectName(), 
create J2EEServer instance" );
  +            // Create single JBoss server
               ObjectName lServer = getServer().createMBean(
                  "org.jboss.management.j2ee.J2EEServer",
                  null,
  -               new Object[] { "Single", getObjectName() },
  -               new String[] { String.class.getName(), ObjectName.class.getName() }
  +               new Object[] {
  +                  "Single",
  +                  getObjectName(),
  +                  "jboss.org"
  +               },
  +               new String[] {
  +                  String.class.getName(),
  +                  ObjectName.class.getName(),
  +                  String.class.getName()
  +               }
               ).getObjectName();
  -   /*
  -            pServer.invoke(
  -               lServer,
  -               "start",
  -               new Object[] {},
  -               new String[] {}
  -            );
  -   */
  +            // Create its node
  +            ObjectName lNode = getServer().createMBean(
  +               "org.jboss.management.j2ee.Node",
  +               null,
  +               new Object[] {
  +                  "Localhost",
  +                  lServer,
  +                  "PC Pentium 4",
  +                  "Windows 2000",
  +                  new ObjectName[ 0 ]
  +               },
  +               new String[] {
  +                  String.class.getName(),
  +                  ObjectName.class.getName(),
  +                  String.class.getName(),
  +                  String.class.getName(),
  +                  ObjectName[].class.getName()
  +               }
  +            ).getObjectName();
            }
            catch( JMException jme ) {
               jme.printStackTrace();
  
  
  
  1.1                  jboss/src/main/org/jboss/management/j2ee/NodeMBean.java
  
  Index: NodeMBean.java
  ===================================================================
  package org.jboss.management.j2ee;
  
  import javax.management.j2ee.Node;
  
  /**
  * MBean Interface for a Node
  *
  * @author <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>
  **/
  public interface NodeMBean
     extends Node, J2EEManagedObjectMBean
  {
  }
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to