User: schaefera
  Date: 01/06/04 15:55:15

  Modified:    src/main/org/jboss/mgt Application.java EJB.java
                        ServerDataCollector.java
                        ServerDataCollectorMBean.java
  Log:
  Adjusted the Server Data Collector to work with the Container-MBeans to
  get its management information.
  
  Revision  Changes    Path
  1.3       +11 -0     jboss/src/main/org/jboss/mgt/Application.java
  
  Index: Application.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/mgt/Application.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Application.java  2001/05/22 05:08:00     1.2
  +++ Application.java  2001/06/04 22:55:15     1.3
  @@ -88,6 +88,17 @@
      }
      
      /**
  +    * Returns the requested module if found
  +    *
  +    * @param pModuleId Id of the Module to be saved. Please use the
  +    *                  constants provided in here.
  +    * @return Module if found and otherwise null
  +    **/
  +   public Module getModule( int pModuleId ) {
  +      return (Module) mModules.get( new Integer( pModuleId ) );
  +   }
  +   
  +   /**
       * @return Collection of Modules deployed with this application. Each
       *         item is of type {@link org.jboss.mgt.Module Module}.
       **/
  
  
  
  1.4       +9 -17     jboss/src/main/org/jboss/mgt/EJB.java
  
  Index: EJB.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/mgt/EJB.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EJB.java  2001/05/22 05:08:00     1.3
  +++ EJB.java  2001/06/04 22:55:15     1.4
  @@ -18,11 +18,9 @@
      // Constants
      // -------------------------------------------------------------------------  
   
  -   public static final int STATELESS_SESSION = 1;
  -   public static final int STATEFUL_SESSION = 2;
  -   public static final int ENTITY_BMP = 3;
  -   public static final int ENTITY_CMP = 4;
  -   public static final int MESSAGE = 5;
  +   public static final int SESSION = 1;
  +   public static final int ENTITY = 2;
  +   public static final int MESSAGE_DRIVEN = 3;
   
      // -------------------------------------------------------------------------
      // Members
  @@ -95,20 +93,14 @@
      public String toString() {
         String lType = null;
         switch( getType() ) {
  -         case STATELESS_SESSION:
  -            lType = "Stateless Session";
  +         case SESSION:
  +            lType = "Session";
               break;
  -         case STATEFUL_SESSION:
  -            lType = "Statefull Session";
  +         case ENTITY:
  +            lType = "Entity";
               break;
  -         case ENTITY_BMP:
  -            lType = "Entity BMP";
  -            break;
  -         case ENTITY_CMP:
  -            lType = "Entity CMP";
  -            break;
  -         case MESSAGE:
  -            lType = "Message";
  +         case MESSAGE_DRIVEN:
  +            lType = "MessageDriven";
         }
   
         return "EJB [ " + getName() + 
  
  
  
  1.3       +103 -1    jboss/src/main/org/jboss/mgt/ServerDataCollector.java
  
  Index: ServerDataCollector.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/mgt/ServerDataCollector.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerDataCollector.java  2001/05/22 05:08:00     1.2
  +++ ServerDataCollector.java  2001/06/04 22:55:15     1.3
  @@ -9,6 +9,7 @@
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Hashtable;
  +import java.util.Iterator;
   import java.util.Map;
   
   import javax.management.MalformedObjectNameException;
  @@ -22,6 +23,7 @@
   import javax.naming.Reference;
   import javax.naming.StringRefAddr;
   
  +import org.jboss.ejb.Container;
   import org.jboss.logging.Log;
   import org.jboss.naming.NonSerializableFactory;
   import org.jboss.util.ServiceMBeanSupport;
  @@ -50,6 +52,9 @@
      private MBeanServer mServer;
      private String mName;
      private Map mApplications = new Hashtable();
  +   private Boolean mRefresh = new Boolean( true );
  +   private Thread mWorker;
  +   private int mRefreshSleep = 2000;
   
      // -------------------------------------------------------------------------
      // Constructors
  @@ -79,6 +84,23 @@
      // Methods
      // -------------------------------------------------------------------------  
   
  +   public int getRefreshSleep() {
  +      return mRefreshSleep;
  +   }
  +   
  +   public void setRefreshSleep( int pSleep ) {
  +      if( pSleep > 0 ) {
  +         mRefreshSleep = pSleep;
  +      }
  +   }
  +   
  +   public void refresh() {
  +      // Mark it to be refreshed
  +      synchronized( mRefresh ) {
  +         mRefresh = new Boolean( true );
  +      }
  +   }
  +
      public ObjectName getObjectName(
         MBeanServer server,
         ObjectName name
  @@ -175,10 +197,12 @@
           throws Exception
      {
         bind( this );
  -//      refresh();
  +      mWorker = new RefreshWorker( log );
  +      mWorker.start();
      }
      
      protected void stopService() {
  +      mWorker.stop();
         try {
            unbind();
         }
  @@ -236,5 +260,83 @@
         NonSerializableFactory.unbind( lJNDIName );
         log.log("JBoss Management service '" + lJNDIName + "' removed from JNDI" );
        }
  +   
  +   /**
  +    * Worker class to perform the refresh of the data
  +    **/
  +   private class RefreshWorker
  +      extends Thread
  +   {
  +      private Log mLog;
  +      
  +      public RefreshWorker( Log pLog ) {
  +         mLog = pLog;
  +      }
  +      
  +      public void run() {
  +         while( true ) {
  +            try {
  +               synchronized( mRefresh ) {
  +                  if( mRefresh.booleanValue() ) {
  +                     doRefresh();
  +                     mRefresh = new Boolean( false );
  +                  }
  +               }
  +               Thread.sleep( mRefreshSleep );
  +            }
  +            catch( InterruptedException e ) {
  +            }
  +         }
  +      }
  +      
  +      private void doRefresh() {
  +         try {
  +            // Drop the actual info
  +            mApplications = new Hashtable();
  +            // Look up all the registered Containers for the EJB Module and loop 
through
  +            Iterator i = mServer.queryNames( new ObjectName( "Management:*" ), null 
).iterator();
  +            while( i.hasNext() ) {
  +               ObjectName lName = (ObjectName) i.next();
  +               if( lName.getKeyProperty( "container" ) == null ) {
  +                  continue;
  +               }
  +               Container lContainer = (Container) mServer.getAttribute( lName, 
"Container" );
  +               // Check if application name already exists
  +               String lApplicationName = lContainer.getApplication().getName();
  +               Application lApplication = null;
  +               if( mApplications.containsKey( lApplicationName ) ) {
  +                  lApplication = (Application) mApplications.get( lApplicationName 
);
  +               }
  +               else {
  +                  lApplication = new Application( lApplicationName, "DD:Fix it 
later" );
  +                  mApplications.put( lApplicationName, lApplication );
  +               }
  +               // Check if the EJB module is there
  +               Module lModule = lApplication.getModule( Application.EJBS );
  +               if( lModule == null ) {
  +                  lModule = new Module( "EJB", "DD:Fix it later" );
  +                  lApplication.saveModule( Application.EJBS, lModule );
  +               }
  +               // Add EJB Info
  +               int lType = 0;
  +               if( lContainer.getBeanMetaData().isSession() ) {
  +                  lType = EJB.SESSION;
  +               }
  +               if( lContainer.getBeanMetaData().isEntity() ) {
  +                  lType = EJB.ENTITY;
  +               }
  +               if( lContainer.getBeanMetaData().isMessageDriven() ) {
  +                  lType = EJB.MESSAGE_DRIVEN;
  +               }
  +               String lEjbName = lContainer.getBeanMetaData().getEjbName();
  +               EJB lEjb = new EJB( lEjbName, lType, true );
  +               lModule.addItem( lEjb );
  +            }
  +         }
  +         catch( Exception e ) {
  +            e.printStackTrace();
  +         }
  +      }
  +   }
   
   }
  
  
  
  1.3       +15 -0     jboss/src/main/org/jboss/mgt/ServerDataCollectorMBean.java
  
  Index: ServerDataCollectorMBean.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/mgt/ServerDataCollectorMBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServerDataCollectorMBean.java     2001/05/22 05:08:00     1.2
  +++ ServerDataCollectorMBean.java     2001/06/04 22:55:15     1.3
  @@ -29,6 +29,21 @@
      // Methods
      // -------------------------------------------------------------------------
   
  +   /** @return Sleep period in milliseconds between to refresh cycles **/
  +   public int getRefreshSleep();
  +   /**
  +    * Sets the Sleep time (in milliseconds) between two refresh cycles
  +    *
  +    * @param pSleep Sleep period in milliseconds
  +    **/
  +   public void setRefreshSleep( int pSleep );
  +   
  +   /**
  +    * Informs this intance the environment changes and he should update its
  +    * data
  +    **/
  +   public void refresh();
  +
      /**
       * Returns an application if found with the given key.
       *
  
  
  

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

Reply via email to