User: starksm
Date: 01/04/20 15:42:07
Modified: src/main/org/jboss/util ServiceMBeanSupport.java
Log:
Add access to the MBeanServer
Revision Changes Path
1.10 +41 -37 jboss/src/main/org/jboss/util/ServiceMBeanSupport.java
Index: ServiceMBeanSupport.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/ServiceMBeanSupport.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ServiceMBeanSupport.java 2000/12/07 18:16:14 1.9
+++ ServiceMBeanSupport.java 2001/04/20 22:42:07 1.10
@@ -15,12 +15,13 @@
import javax.management.ObjectName;
import org.jboss.logging.Log;
-/**
- * <description>
+
+/** An abstract base class JBoss services can subclass
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.9 $
+ * @author [EMAIL PROTECTED]
+ * @version $Revision: 1.10 $
*/
public abstract class ServiceMBeanSupport
extends NotificationBroadcasterSupport
@@ -28,7 +29,7 @@
{
// Attributes ----------------------------------------------------
private int state;
-
+ private MBeanServer server;
public static String[] states = {"Stopped","Stopping","Starting","Started"};
public static int STOPPED = 0;
public static int STOPPING = 1;
@@ -44,6 +45,11 @@
// Public --------------------------------------------------------
public abstract String getName();
+ public MBeanServer getServer()
+ {
+ return server;
+ }
+
public int getState()
{
return state;
@@ -54,28 +60,26 @@
return states[state];
}
- public void init()
- throws Exception
- {
-
- log = Log.createLog( getName() );
-
- log.log("Initializing");
- log.setLog(log);
- try
- {
- initService();
- } catch (Exception e)
- {
- log.error("Initialization failed");
- log.exception(e);
- throw e;
- } finally
- {
- log.unsetLog();
- }
- log.log("Initialized");
- }
+ public void init()
+ throws Exception
+ {
+ log = Log.createLog( getName() );
+ log.log("Initializing");
+ log.setLog(log);
+ try
+ {
+ initService();
+ } catch (Exception e)
+ {
+ log.error("Initialization failed");
+ log.exception(e);
+ throw e;
+ } finally
+ {
+ log.unsetLog();
+ }
+ log.log("Initialized");
+ }
public void start()
throws Exception
@@ -109,10 +113,10 @@
log.log("Started");
}
- public void stop()
- {
- if (getState() != STARTED)
- return;
+ public void stop()
+ {
+ if (getState() != STARTED)
+ return;
state = STOPPING;
//AS It seems that the first attribute is not needed anymore and use a long
instead of a Date
@@ -137,8 +141,8 @@
public void destroy()
{
- if (getState() != STOPPED)
- stop();
+ if (getState() != STOPPED)
+ stop();
log.log("Destroying");
log.setLog(log);
@@ -157,11 +161,11 @@
public ObjectName preRegister(MBeanServer server, ObjectName name)
throws java.lang.Exception
{
- name = getObjectName(server, name);
-
- return name;
+ name = getObjectName(server, name);
+ this.server = server;
+ return name;
}
-
+
public void postRegister(java.lang.Boolean registrationDone)
{
if (!registrationDone.booleanValue())
@@ -175,7 +179,7 @@
public void postDeregister()
{
- destroy();
+ destroy();
}
// Protected -----------------------------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development