geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx GBeanMBeanContext.java CollectionProxy.java GBeanMBean.java
Date Tue, 20 Jan 2004 22:39:05 GMT
dain        2004/01/20 14:39:05

  Modified:    modules/kernel/src/java/org/apache/geronimo/gbean GBean.java
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        CollectionProxy.java GBeanMBean.java
  Added:       modules/kernel/src/java/org/apache/geronimo/gbean
                        GBeanContext.java
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        GBeanMBeanContext.java
  Log:
  Added GBeanContext - this is currently commented out because it requires
  all GBeans be updated
  
  Revision  Changes    Path
  1.2       +7 -1      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/GBean.java
  
  Index: GBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/GBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GBean.java	14 Jan 2004 22:16:37 -0000	1.1
  +++ GBean.java	20 Jan 2004 22:39:04 -0000	1.2
  @@ -66,6 +66,12 @@
    */
   public interface GBean {
       /**
  +     * Sets the operating context for the GBean.
  +     * @param context the context object or null
  +     */
  +//    void setGBeanContext(GBeanContext context);
  +
  +    /**
        * Starts the GBean.  This informs the GBean that it is about to transition to the
running state.
        * @throws org.apache.geronimo.gbean.WaitingException if the target is waiting for
an external condition before it can fully start
        * @throws java.lang.Exception if the target failed to start; this will cause a transition
to the failed state
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanContext.java
  
  Index: GBeanContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.gbean;
  
  
  /**
   * Context handle for a GBean which allows the bean to determin the current state, and to
change the
   * current state.
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/20 22:39:04 $
   */
  public interface GBeanContext {
      /**
       * Gets the state of this component as an int.
       * The int return is required by the JSR77 specification.
       *
       * @return the current state of this component
       */
      public int getState();
  
      /**
       * 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;
  
      /**
       * 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;
  
      /**
       * Moves this component to the FAILED state.
       *
       * The component is guaranteed to be in the failed state when the method returns.
       *
       */
      public void fail();
  }
  
  
  
  1.8       +10 -15    incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CollectionProxy.java
  
  Index: CollectionProxy.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CollectionProxy.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CollectionProxy.java	19 Jan 2004 06:33:24 -0000	1.7
  +++ CollectionProxy.java	20 Jan 2004 22:39:05 -0000	1.8
  @@ -55,32 +55,30 @@
    */
   package org.apache.geronimo.gbean.jmx;
   
  +import java.lang.reflect.Method;
  +import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Collections;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Iterator;
   import java.util.Map;
   import java.util.NoSuchElementException;
   import java.util.Set;
  -import java.util.HashSet;
  -import java.util.ArrayList;
  -import java.lang.reflect.Method;
  -
   import javax.management.ObjectName;
   
  -import org.apache.geronimo.gbean.WaitingException;
  -import org.apache.geronimo.gbean.EndpointCollection;
  -import org.apache.geronimo.gbean.EndpointCollectionListener;
  -import org.apache.geronimo.gbean.EndpointCollectionEvent;
  -import org.apache.geronimo.kernel.jmx.InterfaceCallbackFilter;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.geronimo.gbean.EndpointCollection;
  +import org.apache.geronimo.gbean.EndpointCollectionEvent;
  +import org.apache.geronimo.gbean.EndpointCollectionListener;
  +import org.apache.geronimo.gbean.WaitingException;
   
  +import net.sf.cglib.proxy.CallbackFilter;
  +import net.sf.cglib.proxy.Callbacks;
   import net.sf.cglib.proxy.Enhancer;
   import net.sf.cglib.proxy.Factory;
   import net.sf.cglib.proxy.SimpleCallbacks;
  -import net.sf.cglib.proxy.CallbackFilter;
  -import net.sf.cglib.proxy.Callbacks;
   
   /**
    *
  @@ -135,13 +133,11 @@
           } else {
               enhancer.setSuperclass(type);
           }
  -        //enhancer.setCallbackFilter(new InterfaceCallbackFilter(type));
           enhancer.setCallbackFilter(new CallbackFilter() {
               public int accept(Method method) {
                   return Callbacks.INTERCEPT;
               }
           });
  -
           enhancer.setCallbacks(new SimpleCallbacks());
           enhancer.setClassLoader(type.getClassLoader());
           factory = enhancer.create();
  @@ -153,7 +149,6 @@
               interceptor.disconnect();
           }
           proxy.listeners = null;
  -
           gmbean = null;
           name = null;
           proxies = null;
  
  
  
  1.3       +10 -1     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
  
  Index: GBeanMBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GBeanMBean.java	16 Jan 2004 23:31:21 -0000	1.2
  +++ GBeanMBean.java	20 Jan 2004 22:39:05 -0000	1.3
  @@ -304,6 +304,10 @@
   
           if (registrationDone.booleanValue()) {
               // we're now offically on line
  +            if (target instanceof GBean) {
  +                GBean gbean = (GBean) target;
  +//                gbean.setGBeanContext(new GBeanMBeanContext(server, this, objectName));
  +            }
               offline = false;
           } else {
               // we need to bring the endpoints back off line
  @@ -328,6 +332,11 @@
           for (Iterator iterator = endpointMap.values().iterator(); iterator.hasNext();)
{
               GBeanMBeanEndpoint endpoint = (GBeanMBeanEndpoint) iterator.next();
               endpoint.offline();
  +        }
  +
  +        if (target instanceof GBean) {
  +            GBean gbean = (GBean) target;
  +//            gbean.setGBeanContext(null);
           }
   
           offline = true;
  
  
  
  1.1                  incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanContext.java
  
  Index: GBeanMBeanContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  package org.apache.geronimo.gbean.jmx;
  
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  
  import org.apache.geronimo.gbean.GBeanContext;
  import org.apache.geronimo.kernel.management.State;
  
  /**
   * 
   * 
   * @version $Revision: 1.1 $ $Date: 2004/01/20 22:39:05 $
   */
  public class GBeanMBeanContext implements GBeanContext {
      /**
       * The MBean server in which the Geronimo MBean is registered.
       */
      private MBeanServer server;
  
      /**
       * The GeronimoMBean which owns the target.
       */
      private GBeanMBean gmbean;
  
      /**
       * The object name of the Geronimo MBean.
       */
      private ObjectName objectName;
  
      /**
       * Creates a new context for a target.
       *
       * @param server a reference to the mbean server in which the Geronimo Mbean is registered
       * @param gmbean the Geronimo Mbean the contains the target
       * @param objectName the registered name of the Geronimo MBean
       */
      public GBeanMBeanContext(MBeanServer server, GBeanMBean gmbean, ObjectName objectName)
{
          this.server = server;
          this.gmbean = gmbean;
          this.objectName = objectName;
      }
  
      /**
       * Gets a reference to the MBean server in which the Geronimo MBean is registered.
       * @return a reference to the MBean server in which the Geronimo MBean is registered
       */
      public MBeanServer getServer() {
          return server;
      }
  
      /**
       * Gets the registered name of the Geronimo MBean
       * @return the registered name of the Geronimo MBean
       */
      public ObjectName getObjectName() {
          return objectName;
      }
  
      /**
       * Gets the state of this component as an int.
       * The int return is required by the JSR77 specification.
       *
       * @return the current state of this component
       */
      public int getState() {
          return gmbean.getState();
      }
  
      /**
       * 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 {
          gmbean.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 = gmbean.getState();
          if (state == State.RUNNING_INDEX || state == State.STARTING_INDEX) {
              gmbean.stop();
          } else if (state == State.STOPPING_INDEX) {
              gmbean.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() {
          gmbean.fail();
      }
  }
  
  
  

Mime
View raw message