User: schaefera
  Date: 02/03/03 22:01:14

  Modified:    src/main/org/jboss/management/j2ee EjbModule.java
                        J2EEManagedObject.java JDBC.java
                        JDBCDataSource.java JNDI.java JavaMail.java
                        SingleJBossServerManagement.java
  Log:
  Added State Management to JDBC and JavaMail and some fixes.
  
  Revision  Changes    Path
  1.14      +134 -16   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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EjbModule.java    3 Mar 2002 05:24:21 -0000       1.13
  +++ EjbModule.java    4 Mar 2002 06:01:14 -0000       1.14
  @@ -14,8 +14,11 @@
   import java.security.InvalidParameterException;
   import java.util.ArrayList;
   import java.util.Arrays;
  +import java.util.ArrayList;
  +import java.util.Iterator;
   import java.util.List;
   import javax.management.AttributeChangeNotification;
  +import javax.management.JMException;
   import javax.management.MBeanServer;
   import javax.management.MalformedObjectNameException;
   import javax.management.Notification;
  @@ -36,7 +39,7 @@
    * {@link javax.management.j2ee.EJBModule EJBModule}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.13 $
  + * @version $Revision: 1.14 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -58,6 +61,8 @@
      private List mEJBs = new ArrayList();
      private long mStartTime = -1;
      private int mState = ServiceMBean.STOPPED;
  +   private ObjectName mService;
  +   private Listener mListener;
      //used to see if we should remove our parent when we are destroyed.
      private static final Map iCreatedParent = new HashMap();
   
  @@ -73,7 +78,7 @@
                                                "state.failed"
                                             };
      
  -   public static ObjectName create( MBeanServer pServer, String pApplicationName, 
String pName, URL pURL ) {
  +   public static ObjectName create( MBeanServer pServer, String pApplicationName, 
String pName, URL pURL, ObjectName pService ) {
         Logger lLog = Logger.getLogger( EjbModule.class );
         String lDD = null;
         ObjectName lApplication = null;
  @@ -139,12 +144,14 @@
               new Object[] {
                  pName,
                  lApplication,
  -               lDD
  +               lDD,
  +               pService
               },
               new String[] {
                  String.class.getName(),
                  ObjectName.class.getName(),
  -               String.class.getName()
  +               String.class.getName(),
  +               ObjectName.class.getName()
               }
            ).getObjectName();
            //remember if we created our parent, if we did we have to kill it on 
destroy.
  @@ -191,12 +198,13 @@
      *
      * @throws InvalidParameterException If the given Name is null
      **/
  -   public EjbModule( String pName, ObjectName pApplication, String 
pDeploymentDescriptor )
  +   public EjbModule( String pName, ObjectName pApplication, String 
pDeploymentDescriptor, ObjectName pService )
         throws
            MalformedObjectNameException,
            InvalidParentException
      {
         super( "EjbModule", pName, pApplication, pDeploymentDescriptor );
  +      mService = pService;
      }
   
      // Public --------------------------------------------------------
  @@ -241,22 +249,17 @@
            mEJBs.remove( pChild );
         }
      }
  -
  -   // org.jboss.ServiceMBean overrides ------------------------------------
  -
  -   public void postRegister( Boolean pRegisterationDone ) {
  -      super.postRegister( pRegisterationDone );
  -      // If set then register for its events
  -/*
  +   
  +   public void postCreation() {
         try {
  -         getServer().addNotificationListener( mService, new Listener(), null, null 
);
  +         mListener = new Listener();
  +         getServer().addNotificationListener( mService, mListener, null, null );
         }
         catch( JMException jme ) {
            //AS ToDo: later on we have to define what happens when service is null or
            //AS ToDo: not found.
            jme.printStackTrace();
         }
  -*/
         sendNotification(
            new Notification(
               sTypes[ 0 ],
  @@ -267,8 +270,8 @@
            )
         );
      }
  -
  -   public void preDeregister() {
  +   
  +   public void preDestruction() {
         sendNotification(
            new Notification(
               sTypes[ 1 ],
  @@ -278,6 +281,121 @@
               "EJB Module deleted"
            )
         );
  +      // Remove the listener of the target MBean
  +      try {
  +         getServer().removeNotificationListener( mService, mListener );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
  +      }
  +   }
  +   
  +   // javax.management.j2ee.StateManageable implementation ----------
  +   
  +   public long getStartTime() {
  +      return mStartTime;
  +   }
  +   
  +   public int getState() {
  +      return mState;
  +   }
  +   
  +   /**
  +    * This method is only overwriten because to catch the exception
  +    * which is not specified in {@link javax.management.j2ee.StateManageable
  +    * StateManageable} interface.
  +    **/
  +   public void start()
  +   {
  +      try {
  +         super.start();
  +      }
  +      catch( Exception e ) {
  +         getLog().error( "start failed", e );
  +      }
  +   }
  +   
  +   public void startRecursive() {
  +      // No recursive start here
  +      try {
  +         start();
  +         Iterator i = mEJBs.iterator();
  +         while( i.hasNext() ) {
  +            ObjectName lName = (ObjectName) i.next();
  +            try {
  +               getServer().invoke(
  +                  lName,
  +                  "start",
  +                  new Object[] {},
  +                  new String[] {}
  +               );
  +            }
  +            catch( JMException jme ) {
  +               getLog().error( "start of EJB failed", jme );
  +            }
  +         }
  +      }
  +      catch( Exception e ) {
  +         getLog().error( "start failed", e );
  +      }
  +   }
  +   
  +   public void stop() {
  +      try {
  +         Iterator i = mEJBs.iterator();
  +         while( i.hasNext() ) {
  +            ObjectName lName = (ObjectName) i.next();
  +            try {
  +               getServer().invoke(
  +                  lName,
  +                  "stop",
  +                  new Object[] {},
  +                  new String[] {}
  +               );
  +            }
  +            catch( JMException jme ) {
  +               getLog().error( "stop of EJB failed", jme );
  +            }
  +         }
  +         super.stop();
  +      }
  +      catch( Exception e ) {
  +         getLog().error( "stop failed", e );
  +      }
  +   }
  +         
  +   // ServiceMBeanSupport overrides ---------------------------------
  +   
  +   public void startService() {
  +      try {
  +         getServer().invoke(
  +            mService,
  +            "start",
  +            new Object[] {},
  +            new String[] {}
  +         );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service could not 
be started
  +         jme.printStackTrace();
  +      }
  +   }
  +   
  +   public void stopService() {
  +      try {
  +         getServer().invoke(
  +            mService,
  +            "stop",
  +            new Object[] {},
  +            new String[] {}
  +         );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service could not 
be stopped
  +         jme.printStackTrace();
  +      }
      }
      
      // Object overrides ---------------------------------------------------
  
  
  
  1.8       +42 -18    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- J2EEManagedObject.java    10 Dec 2001 06:27:49 -0000      1.7
  +++ J2EEManagedObject.java    4 Mar 2002 06:01:14 -0000       1.8
  @@ -27,7 +27,7 @@
    * {@link javax.management.j2ee.J2EEManagedObject J2EEManagedObject}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -186,28 +186,44 @@
         return getObjectName();
      }
      
  -   public void postRegister( java.lang.Boolean pRegistrationDone ) {
  +   /**
  +    * Last steps to be done after MBean is registered on MBeanServer. This
  +    * method is made final because it contains vital steps mandatory to all
  +    * J2EEManagedObjects. To perform your own Post-Creation steps please
  +    * override {@link #postCreation postCreation()} method.
  +    **/
  +   public final void postRegister( java.lang.Boolean pRegistrationDone ) {
         log.debug("postRegister(), parent: " + mParent );
  -      if( pRegistrationDone.booleanValue() && mParent != null ) {
  -         try {
  -            // Notify the parent about its new child
  -            getServer().invoke(
  -               mParent,
  -               "addChild",
  -               new Object[] { mName },
  -               new String [] { ObjectName.class.getName() }
  -            );
  -            super.postRegister( pRegistrationDone );
  -         }
  -         catch( JMException jme ) {
  -            jme.printStackTrace();
  -            // Stop it because of the error
  -            super.postRegister( new Boolean( false ) );
  +      if( pRegistrationDone.booleanValue() ) {
  +         // Let the subclass handle post creation steps
  +         postCreation();
  +         if( mParent != null ) {
  +            try {
  +               // Notify the parent about its new child
  +               getServer().invoke(
  +                  mParent,
  +                  "addChild",
  +                  new Object[] { mName },
  +                  new String [] { ObjectName.class.getName() }
  +               );
  +               super.postRegister( pRegistrationDone );
  +            }
  +            catch( JMException jme ) {
  +               jme.printStackTrace();
  +               // Stop it because of the error
  +               super.postRegister( new Boolean( false ) );
  +            }
            }
         }
      }
      
  -   public void preDeregister()
  +   /**
  +    * Last steps to be done before MBean is unregistered on MBeanServer. This
  +    * method is made final because it contains vital steps mandatory to all
  +    * J2EEManagedObjects. To perform your own Pre-Destruction steps please
  +    * override {@link #preDestruction preDestruction()} method.
  +    **/
  +   public final void preDeregister()
         throws Exception
      {
         log.debug("preDeregister(), parent: " + mParent );
  @@ -222,6 +238,8 @@
                  new String [] { ObjectName.class.getName() }
               );
            }
  +         // Let the subclass handle pre destruction steps
  +         preDestruction();
         }
         catch( JMException jme ) {
            jme.printStackTrace();
  @@ -237,6 +255,12 @@
      // Package protected ---------------------------------------------
      
      // Protected -----------------------------------------------------
  +   
  +   public void postCreation() {
  +   }
  +   
  +   public void preDestruction() {
  +   }
      
      // Private -------------------------------------------------------
      
  
  
  
  1.8       +84 -21    jboss/src/main/org/jboss/management/j2ee/JDBC.java
  
  Index: JDBC.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/JDBC.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JDBC.java 20 Dec 2001 03:08:40 -0000      1.7
  +++ JDBC.java 4 Mar 2002 06:01:14 -0000       1.8
  @@ -27,7 +27,7 @@
    * {@link javax.management.j2ee.JDBC JDBC}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -35,6 +35,9 @@
    * <ul>
    * <li> Creation
    * </ul>
  + *
  + * @todo This resource should not implement state manageable because it
  + *       has no MBean/Service associated but codes stays.
    **/
   public class JDBC
      extends J2EEResource
  @@ -47,6 +50,7 @@
      private long mStartTime = -1;
      private int mState = ServiceMBean.STOPPED;
      private ObjectName mService;
  +   private Listener mListener;
      
      private List mDatasources = new ArrayList();
      
  @@ -63,7 +67,7 @@
                                             };
      
      public static ObjectName create( MBeanServer pServer, String pName ) {
  -      Logger lLog = Logger.getLogger( JNDI.class );
  +      Logger lLog = Logger.getLogger( JDBC.class );
         ObjectName lServer = null;
         try {
            lServer = (ObjectName) pServer.queryNames(
  @@ -72,11 +76,11 @@
            ).iterator().next();
         }
         catch( Exception e ) {
  -         lLog.error( "Could not create JSR-77 JDBC Manager", e );
  +         lLog.error( "Could not find parent J2EEServer", e );
            return null;
         }
         try {
  -         // Now create the JNDI Representant
  +         // Now create the JDBC Representant
            return pServer.createMBean(
               "org.jboss.management.j2ee.JDBC",
               null,
  @@ -138,6 +142,7 @@
            InvalidParentException
      {
         super( "JDBC", pName, pServer );
  +//AS      mService = pService;
      }
      
      // Public --------------------------------------------------------
  @@ -190,7 +195,6 @@
      }
   
      public void startRecursive() {
  -      // No recursive start here
         start();
         Iterator i = mDatasources.iterator();
         ObjectName lDataSource = null;
  @@ -205,13 +209,23 @@
               );
            }
            catch( JMException jme ) {
  -            getLog().error( "Could not stop JSR-77 JDBC-DataSource: " + 
lDataSource, jme );
  +            getLog().error( "Could not start JSR-77 JDBC-DataSource: " + 
lDataSource, jme );
            }
         }
      }
   
      public void stopService() {
         Iterator i = mDatasources.iterator();
  +      mState = ServiceMBean.STOPPING;
  +      sendNotification(
  +         new Notification(
  +            sTypes[ 2 ],
  +            getName(),
  +            1,
  +            System.currentTimeMillis(),
  +            "JDBC Manager stopping"
  +         )
  +      );
         while( i.hasNext() ) {
            ObjectName lDataSource = (ObjectName) i.next();
            try {
  @@ -226,16 +240,6 @@
               getLog().error( "Could not stop JSR-77 JDBC-DataSource: " + 
lDataSource, jme );
            }
         }
  -      mState = ServiceMBean.STOPPING;
  -      sendNotification(
  -         new Notification(
  -            sTypes[ 2 ],
  -            getName(),
  -            1,
  -            System.currentTimeMillis(),
  -            "JDBC Manager stopping"
  -         )
  -      );
         mState = ServiceMBean.STOPPED;
         sendNotification(
            new Notification(
  @@ -248,10 +252,23 @@
         );
      }
      
  -   // org.jboss.ServiceMBean overrides ------------------------------------
  -   
  -   public void postRegister( Boolean pRegisterationDone ) {
  -      super.postRegister( pRegisterationDone );
  +   /**
  +    * @todo Listener cannot be used right now because there is no MBean associated
  +    *       to it and therefore no state management possible but currently it stays
  +    *       StateManageable to save the code.
  +    **/
  +   public void postCreation() {
  +/*AS 
  +      try {
  +         mListener = new Listener();
  +         getServer().addNotificationListener( mService, mListener, null, null );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         getLog().error( "Could not add listener at target service", jme );
  +      }
  +*/
         sendNotification(
            new Notification(
               sTypes[ 0 ],
  @@ -263,7 +280,12 @@
         );
      }
      
  -   public void preDeregister() {
  +   /**
  +    * @todo Listener cannot be used right now because there is no MBean associated
  +    *       to it and therefore no state management possible but currently it stays
  +    *       StateManageable to save the code.
  +    **/
  +   public void preDestruction() {
         sendNotification(
            new Notification(
               sTypes[ 1 ],
  @@ -273,6 +295,17 @@
               "JDBC Resource deleted"
            )
         );
  +/*AS
  +      // Remove the listener of the target MBean
  +      try {
  +         getServer().removeNotificationListener( mService, mListener );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
  +      }
  +*/
      }
      
      // javax.management.j2ee.JDBC implementation ---------------------
  @@ -321,4 +354,34 @@
      // Private -------------------------------------------------------
      
      // Inner classes -------------------------------------------------
  +   
  +   private class Listener implements NotificationListener {
  +      
  +      public void handleNotification( Notification pNotification, Object pHandback )
  +      {
  +         if( pNotification instanceof AttributeChangeNotification ) {
  +            AttributeChangeNotification lChange = (AttributeChangeNotification) 
pNotification;
  +            if( "State".equals( lChange.getAttributeName() ) )
  +            {
  +               mState = ( (Integer) lChange.getNewValue() ).intValue();
  +               if( mState == ServiceMBean.STARTED ) {
  +                  mStartTime = lChange.getTimeStamp();
  +               } else {
  +                  mStartTime = -1;
  +               }
  +               // Now send the event to the JSR-77 listeners
  +               sendNotification(
  +                  new Notification(
  +                     sTypes[ getState() + 2 ],
  +                     getName(),
  +                     1,
  +                     System.currentTimeMillis(),
  +                     "State changed"
  +                  )
  +               );
  +            }
  +         }
  +      }
  +      
  +   }
   }
  
  
  
  1.10      +23 -20    jboss/src/main/org/jboss/management/j2ee/JDBCDataSource.java
  
  Index: JDBCDataSource.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/JDBCDataSource.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JDBCDataSource.java       27 Feb 2002 18:45:22 -0000      1.9
  +++ JDBCDataSource.java       4 Mar 2002 06:01:14 -0000       1.10
  @@ -24,7 +24,7 @@
    * {@link javax.management.j2ee.JDBCDataSource JDBCDataSource}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -49,6 +49,7 @@
      private int mState = ServiceMBean.STOPPED;
      private ObjectName mService;
      private ObjectName mJdbcDriver;
  +   private Listener mListener;
      
      // Static --------------------------------------------------------
      
  @@ -210,26 +211,16 @@
            getLog().error( "start failed", e );
         }
      }
  -
  -   // javax.management.j2ee.JDBCDataSource implementation -----------------
  -   
  -   public ObjectName getJdbcDriver()
  -   {
  -      return mJdbcDriver;
  -   }
      
  -   // org.jboss.ServiceMBean overrides ------------------------------------
  -   
  -   public void postRegister( Boolean pRegisterationDone ) {
  -      super.postRegister( pRegisterationDone );
  -      // If set then register for its events
  +   public void postCreation() {
         try {
  -         getServer().addNotificationListener( mService, new Listener(), null, null 
);
  +         mListener = new Listener();
  +         getServer().addNotificationListener( mService, mListener, null, null );
         }
         catch( JMException jme ) {
            //AS ToDo: later on we have to define what happens when service is null or
            //AS ToDo: not found.
  -         jme.printStackTrace();
  +         getLog().error( "Could not add listener at target service", jme );
         }
         sendNotification(
            new Notification(
  @@ -242,11 +233,7 @@
         );
      }
      
  -   public void preDeregister() {
  -      Logger lLog = getLog();
  -      if( lLog.isInfoEnabled() ) {
  -         lLog.info( "JDBCDataSource.preDeregister(): " + getName() );
  -      }
  +   public void preDestruction() {
         sendNotification(
            new Notification(
               sTypes[ 1 ],
  @@ -256,6 +243,22 @@
               "JDBC DataSource Resource deleted"
            )
         );
  +      // Remove the listener of the target MBean
  +      try {
  +         getServer().removeNotificationListener( mService, mListener );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
  +      }
  +   }
  +   
  +   // javax.management.j2ee.JDBCDataSource implementation -----------------
  +   
  +   public ObjectName getJdbcDriver()
  +   {
  +      return mJdbcDriver;
      }
      
      // ServiceMBeanSupport overrides ---------------------------------
  
  
  
  1.11      +15 -8     jboss/src/main/org/jboss/management/j2ee/JNDI.java
  
  Index: JNDI.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/JNDI.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JNDI.java 17 Feb 2002 03:34:59 -0000      1.10
  +++ JNDI.java 4 Mar 2002 06:01:14 -0000       1.11
  @@ -22,7 +22,7 @@
    * {@link javax.management.j2ee.JNDI JNDI}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -46,6 +46,7 @@
      private long mStartTime = -1;
      private int mState = ServiceMBean.STOPPED;
      private ObjectName mService;
  +   private Listener mListener;
      
      // Static --------------------------------------------------------
      
  @@ -192,13 +193,10 @@
         }
      }
      
  -   // org.jboss.ServiceMBean overrides ------------------------------------
  -   
  -   public void postRegister( Boolean pRegisterationDone ) {
  -      super.postRegister( pRegisterationDone );
  -      // If set then register for its events
  +   public void postCreation() {
         try {
  -         getServer().addNotificationListener( mService, new Listener(), null, null 
);
  +         mListener = new Listener();
  +         getServer().addNotificationListener( mService, mListener, null, null );
         }
         catch( JMException jme ) {
            //AS ToDo: later on we have to define what happens when service is null or
  @@ -216,7 +214,7 @@
         );
      }
      
  -   public void preDeregister() {
  +   public void preDestruction() {
         sendNotification(
            new Notification(
               sTypes[ 1 ],
  @@ -226,6 +224,15 @@
               "JNDI Resource deleted"
            )
         );
  +      // Remove the listener of the target MBean
  +      try {
  +         getServer().removeNotificationListener( mService, mListener );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
  +      }
      }
      
      // java.lang.Object overrides ------------------------------------
  
  
  
  1.6       +44 -37    jboss/src/main/org/jboss/management/j2ee/JavaMail.java
  
  Index: JavaMail.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/JavaMail.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JavaMail.java     27 Feb 2002 18:45:22 -0000      1.5
  +++ JavaMail.java     4 Mar 2002 06:01:14 -0000       1.6
  @@ -22,7 +22,7 @@
    * {@link javax.management.j2ee.JavaMail JavaMail}.
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -42,6 +42,7 @@
      private long mStartTime = -1;
      private int mState = ServiceMBean.STOPPED;
      private ObjectName mService;
  +   private Listener mListener;
      
      // Static --------------------------------------------------------
   
  @@ -119,42 +120,6 @@
         super( "JavaMail", pName, pServer );
         mService = pService;
      }
  -
  -   // org.jboss.ServiceMBean overrides ------------------------------------
  -
  -   public void postRegister( Boolean pRegisterationDone ) {
  -      super.postRegister( pRegisterationDone );
  -      // If set then register for its events
  -      try {
  -         getServer().addNotificationListener( mService, new Listener(), null, null 
);
  -      }
  -      catch( JMException jme ) {
  -         //AS ToDo: later on we have to define what happens when service is null or
  -         //AS ToDo: not found.
  -         jme.printStackTrace();
  -      }
  -      sendNotification(
  -         new Notification(
  -            sTypes[ 0 ],
  -            getName(),
  -            1,
  -            System.currentTimeMillis(),
  -            "JavaMail Resource created"
  -         )
  -      );
  -   }
  -   
  -   public void preDeregister() {
  -      sendNotification(
  -         new Notification(
  -            sTypes[ 1 ],
  -            getName(),
  -            1,
  -            System.currentTimeMillis(),
  -            "JavaMail Resource deleted"
  -         )
  -      );
  -   }
      
      // javax.managment.j2ee.EventProvider implementation -------------
      
  @@ -202,6 +167,48 @@
         }
         catch( Exception e ) {
            getLog().error( "start failed", e );
  +      }
  +   }
  +   
  +   public void postCreation() {
  +      try {
  +         mListener = new Listener();
  +         getServer().addNotificationListener( mService, mListener, null, null );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
  +      }
  +      sendNotification(
  +         new Notification(
  +            sTypes[ 0 ],
  +            getName(),
  +            1,
  +            System.currentTimeMillis(),
  +            "Java Mail Resource created"
  +         )
  +      );
  +   }
  +   
  +   public void preDestruction() {
  +      sendNotification(
  +         new Notification(
  +            sTypes[ 1 ],
  +            getName(),
  +            1,
  +            System.currentTimeMillis(),
  +            "Java Mail Resource deleted"
  +         )
  +      );
  +      // Remove the listener of the target MBean
  +      try {
  +         getServer().removeNotificationListener( mService, mListener );
  +      }
  +      catch( JMException jme ) {
  +         //AS ToDo: later on we have to define what happens when service is null or
  +         //AS ToDo: not found.
  +         jme.printStackTrace();
         }
      }
      
  
  
  
  1.9       +46 -49    
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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SingleJBossServerManagement.java  17 Jan 2002 21:57:27 -0000      1.8
  +++ SingleJBossServerManagement.java  4 Mar 2002 06:01:14 -0000       1.9
  @@ -23,7 +23,7 @@
   * Represents the single JBoss server management domain
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Andreas Schaefer</a>.
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.9 $
    *   
    * <p><b>Revisions:</b>
    *
  @@ -53,54 +53,51 @@
      // Properties (Getters/Setters)
      // -------------------------------------------------------------------------
      
  -   public void postRegister( java.lang.Boolean pRegistrationDone ) {
  -      super.postRegister( pRegistrationDone );
  -      if( pRegistrationDone.booleanValue() ) {
  -         // Create Server Component
  -         log.debug("getObjectName(), name: " + getObjectName() );
  -         try {
  -            log.debug("getObjectName(), create J2EEServer instance" );
  -            // Create single JBoss server
  -            ObjectName lServer = getServer().createMBean(
  -               "org.jboss.management.j2ee.J2EEServer",
  -               null,
  -               new Object[] {
  -                  "Single",
  -                  getObjectName(),
  -                  "jboss.org"
  -               },
  -               new String[] {
  -                  String.class.getName(),
  -                  ObjectName.class.getName(),
  -                  String.class.getName()
  -               }
  -            ).getObjectName();
  -            // Create its node
  -            ObjectName lNode = getServer().createMBean(
  -               "org.jboss.management.j2ee.Node",
  -               null,
  -               new Object[] {
  -                  "Localhost",
  -                  lServer,
  -                  "PC Pentium 4",
  -                  "Windows 2000",
  -                  new String[] { "127.0.0.1" }
  -               },
  -               new String[] {
  -                  String.class.getName(),
  -                  ObjectName.class.getName(),
  -                  String.class.getName(),
  -                  String.class.getName(),
  -                  String[].class.getName()
  -               }
  -            ).getObjectName();
  -         }
  -         catch( JMException jme ) {
  -            log.error("unexpected exception", jme);
  -         }
  -         catch( Exception e ) {
  -            log.error("unexpected exception", e);
  -         }
  +   public void postCreation() {
  +      // Create Server Component
  +      log.debug("getObjectName(), name: " + getObjectName() );
  +      try {
  +         log.debug("getObjectName(), create J2EEServer instance" );
  +         // Create single JBoss server
  +         ObjectName lServer = getServer().createMBean(
  +            "org.jboss.management.j2ee.J2EEServer",
  +            null,
  +            new Object[] {
  +               "Single",
  +               getObjectName(),
  +               "jboss.org"
  +            },
  +            new String[] {
  +               String.class.getName(),
  +               ObjectName.class.getName(),
  +               String.class.getName()
  +            }
  +         ).getObjectName();
  +         // Create its node
  +         ObjectName lNode = getServer().createMBean(
  +            "org.jboss.management.j2ee.Node",
  +            null,
  +            new Object[] {
  +               "Localhost",
  +               lServer,
  +               "PC Pentium 4",
  +               "Windows 2000",
  +               new String[] { "127.0.0.1" }
  +            },
  +            new String[] {
  +               String.class.getName(),
  +               ObjectName.class.getName(),
  +               String.class.getName(),
  +               String.class.getName(),
  +               String[].class.getName()
  +            }
  +         ).getObjectName();
  +      }
  +      catch( JMException jme ) {
  +         log.error("unexpected exception", jme);
  +      }
  +      catch( Exception e ) {
  +         log.error("unexpected exception", e);
         }
      }
      
  
  
  

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

Reply via email to