You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2003/11/06 20:56:01 UTC
cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service GeronimoMBeanContext.java
dain 2003/11/06 11:56:01
Modified: modules/kernel/src/java/org/apache/geronimo/kernel/service
GeronimoMBeanContext.java
Log:
Added start, stop and fail methods which allow a target to controll the
state of the encapsulating GeronimoMBean.
Revision Changes Path
1.2 +52 -2 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoMBeanContext.java
Index: GeronimoMBeanContext.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service/GeronimoMBeanContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GeronimoMBeanContext.java 8 Sep 2003 04:38:35 -0000 1.1
+++ GeronimoMBeanContext.java 6 Nov 2003 19:56:00 -0000 1.2
@@ -59,7 +59,7 @@
import javax.management.Notification;
import javax.management.ObjectName;
-import org.apache.geronimo.kernel.service.GeronimoMBean;
+import org.apache.geronimo.kernel.management.State;
/**
* Context handle for Geronimo MBean targets which gives a target a reference to the MBean server, the object name
@@ -68,8 +68,19 @@
* @version $Revision$ $Date$
*/
public class GeronimoMBeanContext {
+ /**
+ * The MBean server in which the Geronimo MBean is registered.
+ */
private MBeanServer server;
+
+ /**
+ * The GeronimoMBean which owns the target.
+ */
private GeronimoMBean geronimoMBean;
+
+ /**
+ * The object name of the Geronimo MBean.
+ */
private ObjectName objectName;
/**
@@ -99,6 +110,45 @@
*/
public ObjectName getObjectName() {
return objectName;
+ }
+
+ /**
+ * Attempts to bring the component into the fully running state. If an Exception occurs while
+ * starting the component, the component is automaticaly failed.
+ *
+ * There is no guarantee that the Geronimo MBean will be running when the method returns.
+ *
+ * @throws Exception if a problem occurs while starting the component
+ */
+ public void start() throws Exception {
+ geronimoMBean.attemptFullStart();
+ }
+
+ /**
+ * Attempt to bring the component into the fully stopped state. If an exception occurs while
+ * stopping the component, tthe component is automaticaly failed.
+ *
+ * There is no guarantee that the Geronimo MBean will be stopped when the method returns.
+ *
+ * @throws Exception if a problem occurs while stopping the component
+ */
+ public void stop() throws Exception {
+ final int state = geronimoMBean.getState();
+ if (state == State.RUNNING_INDEX || state == State.STARTING_INDEX) {
+ geronimoMBean.stop();
+ } else if (state == State.STOPPING_INDEX) {
+ geronimoMBean.attemptFullStop();
+ }
+ }
+
+ /**
+ * Moves this component to the FAILED state.
+ *
+ * The component is guaranteed to be in the failed state when the method returns.
+ *
+ */
+ public void fail() {
+ geronimoMBean.fail();
}
/**