djencks     2004/01/22 12:58:41

  Modified:    modules/common/src/java/org/apache/geronimo/common/propertyeditor
                        PropertyEditors.java
               modules/common/src/test/org/apache/geronimo/common/propertyeditor
                        ArrayPropertyEditorAdapterTest.java
               modules/core/src/test/org/apache/geronimo/test/util
                        ServerUtil.java
               modules/deployment/src/test-resources/etc
                        bootstrapped-service.xml
               modules/kernel/src/conf boot.mlet
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        AbstractManagedObject.java
               modules/kernel/src/java/org/apache/geronimo/kernel
                        Kernel.java
               modules/kernel/src/test/org/apache/geronimo/kernel
                        GBeanTest.java
  Added:       modules/common/src/java/org/apache/geronimo/common/propertyeditor
                        ArrayPropertyEditorAdapter.java
               modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        DependencyService.java DependencyServiceMBean.java
  Removed:     modules/kernel/src/java/org/apache/geronimo/kernel/classspace
                        ClassSpace.java ClassSpaceException.java
                        ClassSpaceLoader.java ClassSpaceUtil.java
                        DefaultClassSpace.java classspace-mbean.xml
               modules/kernel/src/java/org/apache/geronimo/kernel/service
                        AbstractManagedObject2.java
                        ArrayPropertyEditorAdapter.java
                        DependencyService2.java
                        DependencyService2MBean.java
                        GeronimoAttributeInfo.java GeronimoMBean.java
                        GeronimoMBeanContext.java
                        GeronimoMBeanEndpoint.java
                        GeronimoMBeanEndpointConnection.java
                        GeronimoMBeanEndpointListener.java
                        GeronimoMBeanInfo.java GeronimoMBeanTarget.java
                        GeronimoNotificationInfo.java
                        GeronimoOperationInfo.java
                        GeronimoParameterInfo.java ParserUtil.java
                        StartException.java StopException.java
               modules/kernel/src/test/org/apache/geronimo/kernel/classspace
                        DefaultClassSpaceTest.java
               modules/kernel/src/test/org/apache/geronimo/kernel/service
                        BootstrapTestObject.java GeronimoMBeanTest.java
                        LifeCycleTest.java ParserUtilTest.java Person.java
                        family-service.xml
  Log:
  Move the last useful classes and remove ClassSpace and GeronimoMBean
  
  Revision  Changes    Path
  1.6       +31 -32    
incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java
  
  Index: PropertyEditors.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/propertyeditor/PropertyEditors.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PropertyEditors.java      8 Sep 2003 04:08:10 -0000       1.5
  +++ PropertyEditors.java      22 Jan 2004 20:58:40 -0000      1.6
  @@ -64,7 +64,6 @@
   
   import org.apache.geronimo.common.Classes;
   import org.apache.geronimo.common.NullArgumentException;
  -import org.apache.geronimo.kernel.service.ArrayPropertyEditorAdapter;
   
   /**
    * A collection of PropertyEditor utilities.
  @@ -76,7 +75,7 @@
   public class PropertyEditors
   {
       /**
  -     * Augment the PropertyEditorManager search path to incorporate the 
  +     * Augment the PropertyEditorManager search path to incorporate the
        * Geronimo specific editors.
        */
       static
  @@ -84,7 +83,7 @@
           // Append our package to the serach path
           appendEditorSearchPath("org.apache.geronimo.common.propertyeditor");
       }
  -    
  +
       /**
        * Locate a value editor for a given target type.
        *
  @@ -96,9 +95,9 @@
           if (type == null) {
               throw new NullArgumentException("type");
           }
  -        
  +
           PropertyEditor editor = PropertyEditorManager.findEditor(type);
  -        
  +
           // Try to use adapter for array types
           if (editor == null && type.isArray()) {
               Class ctype = type.getComponentType();
  @@ -107,10 +106,10 @@
                   editor = new ArrayPropertyEditorAdapter(ctype, editor);
               }
           }
  -        
  +
           return editor;
       }
  -    
  +
       /**
        * Locate a value editor for a given target type.
        *
  @@ -123,7 +122,7 @@
           if (typeName == null) {
               throw new NullArgumentException("typeName");
           }
  -        
  +
           Class type = null;
           try {
               type = Classes.loadClass(typeName);
  @@ -132,10 +131,10 @@
               // look for a nested class
               type = Classes.loadClass(typeName + "$PropertyEditor");
           }
  -        
  +
           return findEditor(type);
       }
  -    
  +
       /**
        * Get a value editor for a given target type.
        *
  @@ -150,10 +149,10 @@
           if (editor == null) {
               throw new PropertyEditorException("No property editor for type: 
" + type);
           }
  -        
  +
           return editor;
       }
  -    
  +
       /**
        * Get a value editor for a given target type.
        *
  @@ -169,10 +168,10 @@
           if (editor == null) {
               throw new PropertyEditorException("No property editor for type: 
" + typeName);
           }
  -        
  +
           return editor;
       }
  -    
  +
       /**
        * Register an editor class to be used to editor values of a given 
target class.
        *
  @@ -187,10 +186,10 @@
           if (editorType == null) {
               throw new NullArgumentException("editorType");
           }
  -        
  +
           PropertyEditorManager.registerEditor(type, editorType);
       }
  -    
  +
       /**
        * Register an editor class to be used to editor values of a given 
target class.
        *
  @@ -207,13 +206,13 @@
           if (editorTypeName == null) {
               throw new NullArgumentException("editorTypeName");
           }
  -        
  +
           Class type = Classes.loadClass(typeName);
           Class editorType = Classes.loadClass(editorTypeName);
  -        
  +
           registerEditor(type, editorType);
       }
  -    
  +
       /**
        * Gets the package names that will be searched for property editors.
        *
  @@ -222,15 +221,15 @@
       public static List getEditorSearchPath()
       {
           String[] path = PropertyEditorManager.getEditorSearchPath();
  -        
  +
           List list = new ArrayList(path.length);
           for (int i=0; i<path.length; i++) {
               list.add(path[i]);
           }
  -        
  +
           return list;
       }
  -    
  +
       /**
        * Sets the package names that will be searched for property editors.
        *
  @@ -241,11 +240,11 @@
           if (path == null) {
               throw new NullArgumentException("path");
           }
  -        
  +
           String[] elements = (String[])path.toArray(new String[path.size()]);
           PropertyEditorManager.setEditorSearchPath(elements);
       }
  -    
  +
       /**
        * Append package names to the property editor search path.
        *
  @@ -257,13 +256,13 @@
               throw new NullArgumentException("names");
           }
           if (names.size() == 0) return;
  -        
  +
           List path = getEditorSearchPath();
           path.addAll(names);
  -        
  +
           setEditorSearchPath(path);
       }
  -    
  +
       /**
        * Append package names to the property editor search path.
        *
  @@ -275,15 +274,15 @@
               throw new NullArgumentException("names");
           }
           if (names.length == 0) return;
  -        
  +
           List list = new ArrayList(names.length);
           for (int i=0; i<names.length; i++) {
               list.add(names[i]);
           }
  -        
  +
           appendEditorSearchPath(list);
       }
  -    
  +
       /**
        * Append a package name to the property editor search path.
        *
  @@ -294,7 +293,7 @@
           if (name == null) {
               throw new NullArgumentException("name");
           }
  -        
  +
           appendEditorSearchPath(new String[] { name });
       }
   }
  
  
  
  1.3       +47 -37    
incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapter.java
  
  
  
  
  1.3       +11 -11    
incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java
  
  Index: ArrayPropertyEditorAdapterTest.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/propertyeditor/ArrayPropertyEditorAdapterTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArrayPropertyEditorAdapterTest.java       8 Sep 2003 04:10:57 -0000       
1.2
  +++ ArrayPropertyEditorAdapterTest.java       22 Jan 2004 20:58:40 -0000      
1.3
  @@ -63,7 +63,7 @@
   import junit.framework.TestCase;
   
   /**
  - * Unit test for [EMAIL PROTECTED] 
org.apache.geronimo.kernel.service.ArrayPropertyEditorAdapter} class.
  + * Unit test for [EMAIL PROTECTED] 
org.apache.geronimo.common.propertyeditor.ArrayPropertyEditorAdapter} class.
    *
    * @version $Revision$ $Date$
    */
  @@ -71,37 +71,37 @@
       extends TestCase
   {
       PropertyEditor editor;
  -    
  +
       protected void setUp()
       {
           editor = PropertyEditors.findEditor(URL[].class);
       }
  -    
  +
       public void testGetValue_Simple()
       {
           String input = "http://apache.org";;
  -        
  +
           editor.setAsText(input);
           Object output = editor.getValue();
  -        
  +
           assertNotNull(output);
           assertEquals(URL[].class, output.getClass());
  -        
  +
           URL[] urls = (URL[])output;
           assertEquals(1, urls.length);
           assertEquals(input, urls[0].toString());
       }
  -    
  +
       public void testGetValue_2URLs()
       {
           String input = "http://apache.org, http://google.com";;
  -        
  +
           editor.setAsText(input);
           Object output = editor.getValue();
  -        
  +
           assertNotNull(output);
           assertEquals(URL[].class, output.getClass());
  -        
  +
           URL[] urls = (URL[])output;
           assertEquals(2, urls.length);
           assertEquals("http://apache.org";, urls[0].toString());
  
  
  
  1.4       +2 -2      
incubator-geronimo/modules/core/src/test/org/apache/geronimo/test/util/ServerUtil.java
  
  Index: ServerUtil.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/test/util/ServerUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerUtil.java   22 Jan 2004 08:10:26 -0000      1.3
  +++ ServerUtil.java   22 Jan 2004 20:58:40 -0000      1.4
  @@ -86,7 +86,7 @@
           MBeanServer mbServer = 
MBeanServerFactory.createMBeanServer("LocalTestServer");
           mbServer.createMBean("javax.management.relation.RelationService", 
RELATION_SERVICE, new Object[]{Boolean.TRUE}, new String[]{"boolean"});
           
mbServer.createMBean("org.apache.geronimo.kernel.deployment.DependencyService", 
DEPENDS_SERVICE);
  -        
mbServer.createMBean("org.apache.geronimo.kernel.service.DependencyService2", 
DEPENDS_SERVICE2);
  +        
mbServer.createMBean("org.apache.geronimo.gbean.jmx.DependencyService2", 
DEPENDS_SERVICE2);
   
           return mbServer;
       }
  
  
  
  1.7       +22 -1     
incubator-geronimo/modules/deployment/src/test-resources/etc/bootstrapped-service.xml
  
  Index: bootstrapped-service.xml
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/deployment/src/test-resources/etc/bootstrapped-service.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- bootstrapped-service.xml  22 Jan 2004 15:18:41 -0000      1.6
  +++ bootstrapped-service.xml  22 Jan 2004 20:58:40 -0000      1.7
  @@ -1,7 +1,6 @@
   <gbeans>
   
       <gbean class="org.apache.geronimo.deployment.xml.LocalEntityResolver" 
objectName="geronimo.system:type=EntityResolver">
  -        <!--default attribute="CatalogFileURI" 
type="java.net.URI">file:/Users/david/geronimo/head2/incubator-geronimo/modules/core/src/conf/resolver-catalog.xml</default-->
           <default attribute="CatalogFileURI" 
type="java.net.URI">core/src/conf/resolver-catalog.xml</default>
           <default attribute="FailOnUnresolvable" 
type="boolean">false</default>
       </gbean>
  @@ -98,6 +97,28 @@
               <pattern>geronimo.boot:role=Kernel</pattern>
           </endpoint>
       </gbean>
  +
  +    <gbean 
class="org.apache.geronimo.connector.deployment.ConnectorDeployer" 
objectName="geronimo.deployment:type=connector">
  +        <default attribute="ConnectionTrackerNamePattern" 
type="javax.management.ObjectName">geronimo.connector:service=ConnectionTrackingCoordinator</default>
  +        <endpoint name="ParserFactory">
  +            <pattern>geronimo.system:type=ParserFactory</pattern>
  +        </endpoint>
  +    </gbean>
  +
  +    <!-- uncomment and set the packageURL to deploy the openjca adapter -->
  +    <!--gbean class="org.apache.geronimo.deployment.util.ExplicitDeployment" 
objectName="geronimo.app:name=OpenJCAAdapter">
  +        <default attribute="ConfigID" 
type="java.net.URI">org/apache/geronimo/OpenJCA</default>
  +        <default attribute="PackageURL" 
type="java.net.URL">file:/Users/david/.maven/repository/openejb-jca/jars/openejb-jca-DEV.jar</default>
  +        <endpoint name="ConfigurationParent">
  +            
<pattern>geronimo.config:name="org/apache/geronimo/Bootstrap"</pattern>
  +        </endpoint>
  +        <endpoint name="BatchDeployerFactory">
  +            <pattern>geronimo.system:type=BatchDeployerFactory</pattern>
  +        </endpoint>
  +        <endpoint name="Kernel">
  +            <pattern>geronimo.boot:role=Kernel</pattern>
  +        </endpoint>
  +    </gbean-->
   
       <!-- web -->
   
  
  
  
  1.5       +1 -1      incubator-geronimo/modules/kernel/src/conf/boot.mlet
  
  Index: boot.mlet
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/conf/boot.mlet,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- boot.mlet 17 Nov 2003 10:57:40 -0000      1.4
  +++ boot.mlet 22 Jan 2004 20:58:40 -0000      1.5
  @@ -11,7 +11,7 @@
         >
   </MLET>
   
  -<MLET CODE="org.apache.geronimo.kernel.service.DependencyService2"
  +<MLET CODE="org.apache.geronimo.gbean.jmx.DependencyService2"
         NAME="geronimo.boot:role=DependencyService2"
         ARCHIVE=""
         >
  
  
  
  1.3       +5 -6      
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractManagedObject.java
  
  Index: AbstractManagedObject.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractManagedObject.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractManagedObject.java        15 Jan 2004 00:45:54 -0000      1.2
  +++ AbstractManagedObject.java        22 Jan 2004 20:58:40 -0000      1.3
  @@ -84,7 +84,6 @@
   import org.apache.geronimo.kernel.management.NotificationType;
   import org.apache.geronimo.kernel.management.State;
   import org.apache.geronimo.kernel.management.StateManageable;
  -import org.apache.geronimo.kernel.service.DependencyService2MBean;
   import org.apache.geronimo.gbean.WaitingException;
   
   /**
  @@ -115,7 +114,7 @@
       /**
        * A dynamic proxy to the dependency service.
        */
  -    private DependencyService2MBean dependencyService;
  +    private DependencyServiceMBean dependencyService;
   
       /**
        * The sequence number of the events.
  @@ -185,8 +184,8 @@
       public synchronized ObjectName preRegister(MBeanServer server, 
ObjectName objectName) throws Exception {
           this.server = server;
           this.objectName = objectName;
  -        dependencyService = (DependencyService2MBean) 
MBeanProxyFactory.getProxy(
  -                DependencyService2MBean.class,
  +        dependencyService = (DependencyServiceMBean) 
MBeanProxyFactory.getProxy(
  +                DependencyServiceMBean.class,
                   server,
                   new ObjectName("geronimo.boot:role=DependencyService2"));
   
  @@ -223,7 +222,7 @@
           return objectName;
       }
   
  -    public DependencyService2MBean getDependencyService() {
  +    public DependencyServiceMBean getDependencyService() {
           return dependencyService;
       }
   
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/DependencyService.java
  
  Index: DependencyService.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 [EMAIL PROTECTED]
   *
   * 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 java.util.Collection;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  import javax.management.JMException;
  import javax.management.MBeanRegistration;
  import javax.management.MBeanServer;
  import javax.management.MBeanServerNotification;
  import javax.management.Notification;
  import javax.management.NotificationFilterSupport;
  import javax.management.NotificationListener;
  import javax.management.ObjectName;
  
  import org.apache.geronimo.kernel.jmx.JMXUtil;
  
  /**
   * DependencyService is the record keeper of the dependencies in Geronimo.  
The DependencyService
   * does not enforce any dependencies, it is simply a place where components 
can register their intent
   * to be dependent on another component.  Since a JMX Component can pretty 
much do whatever it wants
   * a component must watch the components it depends on to assure that they 
are following the
   * J2EE-Management state machine.
   *
   * The DependencyService uses the nomenclature of parent-child where a child 
is dependent on a parent.
   * The names parent and child have no other meaning are just a convience to 
make the code readable.
   *
   * @jmx:mbean
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/22 20:58:40 $
   */
  public class DependencyService implements MBeanRegistration, 
NotificationListener, DependencyServiceMBean {
      /**
       * The mbean server we are registered with.
       */
      private MBeanServer server;
  
      /**
       * A map from child names to a list of parents.
       */
      private final Map childToParentMap = new HashMap();
  
      /**
       * A map from parent back to a list of its children.
       */
      private final Map parentToChildMap = new HashMap();
  
      /**
       * A map from a component's ObjectName to the list of ObjectPatterns that 
the component is blocking
       * from starting.
       */
      private final Map startHoldsMap = new HashMap();
  
      public ObjectName preRegister(MBeanServer server, ObjectName objectName) 
throws Exception {
          if (objectName == null) {
              objectName = JMXUtil.DEPENDENCY_SERVICE_NAME;
          }
          this.server = server;
  
          NotificationFilterSupport mbeanServerFilter = new 
NotificationFilterSupport();
          
mbeanServerFilter.enableType(MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
          server.addNotificationListener(JMXUtil.DELEGATE_NAME, this, 
mbeanServerFilter, null);
  
          return objectName;
      }
  
      public void postRegister(Boolean aBoolean) {
      }
  
      public void preDeregister() throws Exception {
      }
  
      public void postDeregister() {
          try {
              server.removeNotificationListener(JMXUtil.DELEGATE_NAME, this);
          } catch (JMException ignored) {
              // no big deal... just good citizen clean up code
          }
          synchronized(this) {
              server = null;
              childToParentMap.clear();
              parentToChildMap.clear();
              startHoldsMap.clear();
          }
      }
  
      /**
       * Declares a dependency from a child to a parent.
       * @param child the dependent component
       * @param parent the component the child is depending on
       *
       * @jmx:managed-operation
       */
      public synchronized void addDependency(ObjectName child, ObjectName 
parent) {
          Set parents = (Set) childToParentMap.get(child);
          if (parents == null) {
              parents = new HashSet();
              childToParentMap.put(child, parents);
          }
          parents.add(parent);
  
          Set children = (Set) parentToChildMap.get(parent);
          if (children == null) {
              children = new HashSet();
              parentToChildMap.put(parent, children);
          }
          children.add(child);
      }
  
      /**
       * Removes a dependency from a child to a parent
       * @param child the dependnet component
       * @param parent the component that the child wil no longer depend on
       *
       * @jmx:managed-operation
       */
      public synchronized void removeDependency(ObjectName child, ObjectName 
parent) {
          Set parents = (Set) childToParentMap.get(child);
          if (parents != null) {
              parents.remove(parent);
          }
  
          Set children = (Set) parentToChildMap.get(parent);
          if (children != null) {
              children.remove(child);
          }
      }
  
      /**
       * Removes all dependencies for a child
       * @param child the component that will no longer depend on anything
       *
       * @jmx:managed-operation
       */
      public synchronized void removeAllDependencies(ObjectName child) {
          Set parents = (Set) childToParentMap.remove(child);
          if(parents == null) {
              return;
          }
          for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
              ObjectName parent = (ObjectName) iterator.next();
              Set children = (Set) parentToChildMap.get(parent);
              if (children != null) {
                  children.remove(child);
              }
  
          }
      }
  
      /**
       * Adds dependencies from the child to every parent in the parents set
       *
       * @param child the dependent component
       * @param parents the set of components the child is depending on
       *
       * @jmx:managed-operation
       */
      public synchronized void addDependencies(ObjectName child, Set parents) {
          Set existingParents = (Set) childToParentMap.get(child);
          if (existingParents == null) {
              existingParents = new HashSet(parents);
              childToParentMap.put(child, existingParents);
          } else {
              existingParents.addAll(parents);
          }
  
          for (Iterator i = parents.iterator(); i.hasNext();) {
              Object startParent = i.next();
              Set children = (Set) parentToChildMap.get(startParent);
              if (children == null) {
                  children = new HashSet();
                  parentToChildMap.put(startParent, children);
              }
              children.add(child);
          }
      }
  
      /**
       * Gets the set of parents that the child is depending on
       *
       * @param child the dependent component
       * @return a collection containing all of the components the child 
depends on; will never be null
       *
       * @jmx:managed-operation
       */
      public synchronized Set getParents(ObjectName child) {
          Set parents = (Set) childToParentMap.get(child);
          if (parents == null) {
              return Collections.EMPTY_SET;
          }
          return parents;
      }
  
      /**
       * Gets all of the MBeans that have a dependency on the specified 
startParent.
       *
       * @param parent the component the returned childen set depend on
       * @return a collection containing all of the components that depend on 
the parent; will never be null
       *
       * @jmx:managed-operation
       */
      public synchronized Set getChildren(ObjectName parent) {
          Set children = (Set) parentToChildMap.get(parent);
          if (children == null) {
              return Collections.EMPTY_SET;
          }
          return children;
      }
  
      /**
       * Adds a hold on a collection of object name patterns.  If the name of a 
component matches an object name
       * pattern in the collection, the component should not start.
       * @param objectName the name of the component placing the holds
       * @param holds a collection of object name patterns which should not 
start
       *
       * @jmx:managed-operation
       */
      public synchronized void addStartHolds(ObjectName objectName, 
java.util.Collection holds) {
          Collection currentHolds = (Collection)startHoldsMap.get(objectName);
          if(currentHolds == null) {
              currentHolds = new LinkedList(holds);
              startHoldsMap.put(objectName, currentHolds);
          } else {
              currentHolds.addAll(holds);
          }
      }
  
      /**
       * Removes a collection of holds.
       * @param objectName the object name of the components owning the holds
       * @param holds a collection of the holds to remove
       *
       * @jmx:managed-operation
       */
      public synchronized void removeStartHolds(ObjectName objectName, 
java.util.Collection holds) {
          Collection currentHolds = (Collection)startHoldsMap.get(objectName);
          if(currentHolds != null) {
              currentHolds.removeAll(holds);
          }
      }
  
      /**
       * Removes all of the holds owned by a component.
       * @param objectName the object name of the component that will no longer 
have any holds
       *
       * @jmx:managed-operation
       */
      public synchronized void removeAllStartHolds(ObjectName objectName) {
          startHoldsMap.remove(objectName);
      }
  
      /**
       * Gets the object name of the mbean blocking the start specified mbean.
       * @param objectName the mbean to check for blockers
       * @return the mbean blocking the specified mbean, or null if there are 
no blockers
       *
       * @jmx:managed-operation
       */
      public synchronized ObjectName checkBlocker(ObjectName objectName) {
          // check if objectName name is on one of the hold lists
          for (Iterator iterator = startHoldsMap.keySet().iterator(); 
iterator.hasNext();) {
              ObjectName blocker = (ObjectName) iterator.next();
              List holds = (List) startHoldsMap.get(blocker);
              for (Iterator holdsIterator = holds.iterator(); 
holdsIterator.hasNext();) {
                  ObjectName pattern = (ObjectName) holdsIterator.next();
                  if(pattern.apply(objectName)) {
                      return blocker;
                  }
              }
          }
          return null;
      }
  
      public void handleNotification(Notification n, Object handback) {
          String type = n.getType();
          if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(type)) 
{
              MBeanServerNotification notification = (MBeanServerNotification) 
n;
              ObjectName source = notification.getMBeanName();
              synchronized(this) {
                  removeAllDependencies(source);
                  removeAllStartHolds(source);
              }
          }
      }
  }
  
  
  
  1.1                  
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/DependencyServiceMBean.java
  
  Index: DependencyServiceMBean.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 [EMAIL PROTECTED]
   *
   * 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;
  
  /**
   * JMX MBean interface for [EMAIL PROTECTED] 
org.apache.geronimo.gbean.jmx.DependencyService}.
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/22 20:58:40 $
   */
  public interface DependencyServiceMBean
  {
  
      /**
       * Declares a dependency from a child to a parent.
       * @param child the dependent component
       * @param parent the component the child is depending on
       */
      void addDependency(javax.management.ObjectName 
child,javax.management.ObjectName parent) ;
  
      /**
       * Removes a dependency from a child to a parent
       * @param child the dependnet component
       * @param parent the component that the child wil no longer depend on
       */
      void removeDependency(javax.management.ObjectName 
child,javax.management.ObjectName parent) ;
  
      /**
       * Removes all dependencies for a child
       * @param child the component that will no longer depend on anything
       */
      void removeAllDependencies(javax.management.ObjectName child) ;
  
      /**
       * Adds dependencies from the child to every parent in the parents set
       * @param child the dependent component
       * @param parents the set of components the child is depending on
       */
      void addDependencies(javax.management.ObjectName child,java.util.Set 
parents) ;
  
      /**
       * Gets the set of parents that the child is depending on
       * @param child the dependent component
       * @return a collection containing all of the components the child 
depends on; will never be null
       */
      java.util.Set getParents(javax.management.ObjectName child) ;
  
      /**
       * Gets all of the MBeans that have a dependency on the specified 
startParent.
       * @param parent the component the returned childen set depend on
       * @return a collection containing all of the components that depend on 
the parent; will never be null
       */
      java.util.Set getChildren(javax.management.ObjectName parent) ;
  
      /**
       * Adds a hold on a collection of object name patterns. If the name of a 
component matches an object name pattern in the collection, the component 
should not start.
       * @param objectName the name of the component placing the holds
       * @param holds a collection of object name patterns which should not 
start
       */
      void addStartHolds(javax.management.ObjectName 
objectName,java.util.Collection holds) ;
  
      /**
       * Removes a collection of holds.
       * @param objectName the object name of the components owning the holds
       * @param holds a collection of the holds to remove
       */
      void removeStartHolds(javax.management.ObjectName 
objectName,java.util.Collection holds) ;
  
      /**
       * Removes all of the holds owned by a component.
       * @param objectName the object name of the component that will no longer 
have any holds
       */
      void removeAllStartHolds(javax.management.ObjectName objectName) ;
  
      /**
       * Gets the object name of the mbean blocking the start specified mbean.
       * @param objectName the mbean to check for blockers
       * @return the mbean blocking the specified mbean, or null if there are 
no blockers
       */
      javax.management.ObjectName checkBlocker(javax.management.ObjectName 
objectName) ;
  
  }
  
  
  
  1.8       +3 -3      
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
  
  Index: Kernel.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Kernel.java       22 Jan 2004 02:46:27 -0000      1.7
  +++ Kernel.java       22 Jan 2004 20:58:40 -0000      1.8
  @@ -87,7 +87,7 @@
   import org.apache.geronimo.kernel.config.LocalConfigStore;
   import org.apache.geronimo.kernel.config.NoSuchConfigException;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  -import org.apache.geronimo.kernel.service.DependencyService2;
  +import org.apache.geronimo.gbean.jmx.DependencyService;
   
   /**
    * The core of a Geronimo instance.
  @@ -340,7 +340,7 @@
           log.info("Starting boot");
           mbServer = MBeanServerFactory.createMBeanServer(domainName);
           mbServer.registerMBean(this, KERNEL);
  -        mbServer.registerMBean(new DependencyService2(), DEPENDENCY_SERVICE);
  +        mbServer.registerMBean(new DependencyService(), DEPENDENCY_SERVICE);
           if (storeInfo != null) {
               storeGBean = new GBeanMBean(storeInfo);
               storeGBean.setAttribute("root", configStore);
  
  
  
  1.3       +4 -4      
incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
  
  Index: GBeanTest.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GBeanTest.java    22 Jan 2004 18:34:13 -0000      1.2
  +++ GBeanTest.java    22 Jan 2004 20:58:40 -0000      1.3
  @@ -63,8 +63,8 @@
   import junit.framework.TestCase;
   
   /**
  - * 
  - * 
  + *
  + *
    * @version $Revision$ $Date$
    */
   public class GBeanTest extends TestCase {
  @@ -85,7 +85,7 @@
           kernel.unloadGBean(name);
       }
   
  -    public void XtestEndpoint() throws Exception {
  +    public void testEndpoint() throws Exception {
           GBeanMBean gbean1 = new GBeanMBean(MockGBean.getGBeanInfo());
           gbean1.setAttribute("MutableInt", new Integer(123));
           gbean1.setAttribute("FinalInt", new Integer(123));
  
  
  

Reply via email to