From geronimo-cvs-return-1306-apmail-incubator-geronimo-cvs-archive=incubator.apache.org@incubator.apache.org Thu Nov 06 19:56:03 2003 Return-Path: Delivered-To: apmail-incubator-geronimo-cvs-archive@www.apache.org Received: (qmail 83463 invoked from network); 6 Nov 2003 19:56:03 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 Nov 2003 19:56:03 -0000 Received: (qmail 85541 invoked by uid 500); 6 Nov 2003 19:55:52 -0000 Delivered-To: apmail-incubator-geronimo-cvs-archive@incubator.apache.org Received: (qmail 85508 invoked by uid 500); 6 Nov 2003 19:55:51 -0000 Mailing-List: contact geronimo-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: geronimo-dev@incubator.apache.org Delivered-To: mailing list geronimo-cvs@incubator.apache.org Received: (qmail 85495 invoked from network); 6 Nov 2003 19:55:51 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 6 Nov 2003 19:55:51 -0000 Received: (qmail 83419 invoked by uid 1711); 6 Nov 2003 19:56:01 -0000 Date: 6 Nov 2003 19:56:01 -0000 Message-ID: <20031106195601.83418.qmail@minotaur.apache.org> From: dain@apache.org To: incubator-geronimo-cvs@apache.org Subject: cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/service GeronimoMBeanContext.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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(); } /**