geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r386515 [1/2] - in /geronimo/branches/1.1: applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/ modules/kernel/src/java/org/apache/geronimo/gbean/ modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ modules/kernel...
Date Fri, 17 Mar 2006 03:10:11 GMT
Author: dain
Date: Thu Mar 16 19:10:09 2006
New Revision: 386515

URL: http://svn.apache.org/viewcvs?rev=386515&view=rev
Log:
Added getGBean method to kernel that returns the running gbean instance (no-proxy)
Added experimental org.apache.geronimo.gbean.NoProxy system property which disables proxies in GBean references
Added syntactic sugar for every method on kernel which operates on a single GBean to allow the method to be invoked with the shortName (String), type (Class), or shortName and Type
GBeanInfo factory now automatically adds all interfaces and superclasses of GBean to GBeanInfo interfaces list
Added many tests and fixed many bugs around the new GBeanInfo functionality and syntactic sugar

Modified:
    geronimo/branches/1.1/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ProxyCollection.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/KernelDelegate.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoFactoryTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/GBeanInfoTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ClassloadingTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/MockGBean.java

Modified: geronimo/branches/1.1/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java (original)
+++ geronimo/branches/1.1/applications/jmxdebug/src/java/org/apache/geronimo/jmxdebug/web/beanlib/KernelHelper.java Thu Mar 16 19:10:09 2006
@@ -25,10 +25,10 @@
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.jmxdebug.util.ObjectNameComparator;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.jmxdebug.util.ObjectNameComparator;
 
 /**
  * Little helper bean to deal w/ the mbean server

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java Thu Mar 16 19:10:09 2006
@@ -19,7 +19,6 @@
 import java.beans.Introspector;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -27,6 +26,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Arrays;
+
+import org.apache.geronimo.kernel.ClassLoading;
 
 /**
  * @version $Rev$ $Date$
@@ -193,6 +195,48 @@
         } else {
             this.j2eeType = DEFAULT_J2EE_TYPE; //NameFactory.GERONIMO_SERVICE
         }
+
+        // add all interfaces based on GBean type
+        if (gbeanType.isArray()) {
+            throw new IllegalArgumentException("GBean is an array type: gbeanType=" + gbeanType);
+        }
+        Set allTypes = ClassLoading.getAllTypes(gbeanType);
+        for (Iterator iterator = allTypes.iterator(); iterator.hasNext();) {
+            Class type = (Class) iterator.next();
+            addInterface(type);
+        }
+    }
+
+    public void setPersistentAttributes(String[] persistentAttributes) {
+        for (int i = 0; i < persistentAttributes.length; i++) {
+            String attributeName = persistentAttributes[i];
+            GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName);
+            if (attribute != null) {
+                attributes.put(attributeName,
+                        new GAttributeInfo(attributeName,
+                                attribute.getType(),
+                                true,
+                                attribute.isManageable(),
+                                attribute.getGetterName(),
+                                attribute.getSetterName()));
+            }
+        }
+    }
+
+    public void setManageableAttributes(String[] manageableAttributes) {
+        for (int i = 0; i < manageableAttributes.length; i++) {
+            String attributeName = manageableAttributes[i];
+            GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName);
+            if (attribute != null) {
+                attributes.put(attributeName,
+                        new GAttributeInfo(attributeName,
+                                attribute.getType(),
+                                attribute.isPersistent(),
+                                true,
+                                attribute.getGetterName(),
+                                attribute.getSetterName()));
+            }
+        }
     }
 
     public void addInterface(Class intf) {
@@ -204,6 +248,7 @@
     public void addInterface(Class intf, String[] persistentAttributes) {
         addInterface(intf, persistentAttributes, new String[0]);
     }
+
     public void addInterface(Class intf, String[] persistentAttributes, String[] manageableAttributes) {
         Set persistentNames = new HashSet(Arrays.asList(persistentAttributes));
         Set manageableNames = new HashSet(Arrays.asList(manageableAttributes));
@@ -229,8 +274,8 @@
                     attributes.put(attributeName,
                             new GAttributeInfo(attributeName,
                                     attributeType,
-                                    attribute.isPersistent(),
-                                    attribute.isManageable(),
+                                    attribute.isPersistent() || persistentNames.contains(attributeName),
+                                    attribute.isManageable() || manageableNames.contains(attributeName),
                                     method.getName(),
                                     attribute.getSetterName()));
                 }
@@ -253,8 +298,8 @@
                     attributes.put(attributeName,
                             new GAttributeInfo(attributeName,
                                     attributeType,
-                                    attribute.isPersistent(),
-                                    attribute.isManageable(),
+                                    attribute.isPersistent() || persistentNames.contains(attributeName),
+                                    attribute.isManageable() || manageableNames.contains(attributeName),
                                     attribute.getGetterName(),
                                     method.getName()));
                 }
@@ -262,9 +307,7 @@
                 addOperation(new GOperationInfo(method.getName(), method.getParameterTypes()));
             }
         }
-//        if(intf.isInterface()) {
-            addInterface(interfaces, intf);
-//        }
+        addInterface(interfaces, intf);
     }
 
     private static void addInterface(Set set, Class intf) {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/AbstractGBeanReference.java Thu Mar 16 19:10:09 2006
@@ -20,18 +20,30 @@
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.kernel.ClassLoading;
-import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.management.State;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 384141 $ $Date$
  */
 public abstract class AbstractGBeanReference implements GBeanReference {
+    /**
+     * Should we proxy references.
+     */
+    protected static final boolean NO_PROXY = Boolean.getBoolean("org.apache.geronimo.gbean.NoProxy");
+    static {
+        if (NO_PROXY) {
+            Log log = LogFactory.getLog(AbstractGBeanReference.class);
+            log.warn("GBean reference proxies has been disabled:  This is an experimental and untested operating mode");
+        }
+    }
+
     /**
      * Name of this reference.
      */

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanCollectionReference.java Thu Mar 16 19:10:09 2006
@@ -31,23 +31,24 @@
 import java.util.Set;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 384141 $ $Date$
  */
 public class GBeanCollectionReference extends AbstractGBeanReference {
-
-
     /**
      * is this reference online
      */
     private boolean isOnline = false;
+
     /**
      * The target objectName patterns to watch for a connection.
      */
     private Set patterns = Collections.EMPTY_SET;
+
     /**
      * Current set of targets
      */
     private final Set targets = new HashSet();
+
     /**
      * Our listener for lifecycle events
      */
@@ -65,7 +66,7 @@
         // We only need to start if there are patterns and we don't already have a proxy
         if (!patterns.isEmpty() && getProxy() == null) {
             // add a dependency on our target and create the proxy
-            setProxy(new ProxyCollection(getName(), getReferenceType(), getKernel().getProxyManager(), getTargets()));
+            setProxy(new ProxyCollection(getName(), getReferenceType(), getTargets(), getKernel()));
         }
         return true;
     }
@@ -116,11 +117,11 @@
                 };
     }
 
-    public final Set getPatterns() {
+    public final synchronized Set getPatterns() {
         return patterns;
     }
 
-    public final void setPatterns(Set patterns) {
+    public final synchronized void setPatterns(Set patterns) {
         if (isOnline) {
             throw new IllegalStateException("Pattern set can not be modified while online");
         }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanReference.java Thu Mar 16 19:10:09 2006
@@ -16,12 +16,10 @@
  */
 package org.apache.geronimo.gbean.runtime;
 
-import java.util.Set;
-
 import org.apache.geronimo.gbean.GReferenceInfo;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 384141 $ $Date$
  */
 public interface GBeanReference {
     String getName();

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanSingleReference.java Thu Mar 16 19:10:09 2006
@@ -24,9 +24,10 @@
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 384141 $ $Date$
  */
 public class GBeanSingleReference extends AbstractGBeanReference {
     private static final Log log = LogFactory.getLog(GBeanSingleReference.class);
@@ -51,15 +52,30 @@
 
     public synchronized boolean start() {
         // We only need to start if there are patterns and we don't already have a proxy
-        if (proxyTarget != null) {
-            AbstractName abstractName = getGBeanInstance().getAbstractName();
-            if (!isRunning(getKernel(), proxyTarget)) {
+        if (proxyTarget == null) {
+            return true;
+        }
+
+        // assure the gbean is running
+        AbstractName abstractName = getGBeanInstance().getAbstractName();
+        if (!isRunning(getKernel(), proxyTarget)) {
+            log.debug("Waiting to start " + abstractName + " because no targets are running for reference " + getName() +" matching the patterns " + proxyTarget);
+            return false;
+        }
+
+        if (getProxy() != null) {
+            return true;
+        }
+
+        if (NO_PROXY) {
+            try {
+                setProxy(getKernel().getGBean(proxyTarget));
+            } catch (GBeanNotFoundException e) {
+                // gbean disappeard on us
                 log.debug("Waiting to start " + abstractName + " because no targets are running for reference " + getName() +" matching the patterns " + proxyTarget);
-                return false;
-            }
-            if (getProxy() == null) {
-                setProxy(getKernel().getProxyManager().createProxy(proxyTarget, getReferenceType()));
             }
+        } else {
+            setProxy(getKernel().getProxyManager().createProxy(proxyTarget, getReferenceType()));
         }
 
         return true;

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ProxyCollection.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ProxyCollection.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ProxyCollection.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ProxyCollection.java Thu Mar 16 19:10:09 2006
@@ -23,7 +23,8 @@
 import org.apache.geronimo.gbean.ReferenceCollectionEvent;
 import org.apache.geronimo.gbean.ReferenceCollectionListener;
 import org.apache.geronimo.kernel.proxy.ProxyFactory;
-import org.apache.geronimo.kernel.proxy.ProxyManager;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 
 import javax.management.ObjectName;
 import java.util.ArrayList;
@@ -36,21 +37,25 @@
 import java.util.Set;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 383682 $ $Date$
  */
 class ProxyCollection implements ReferenceCollection {
     private static final Log log = LogFactory.getLog(ProxyCollection.class);
     private final String name;
-    private final ProxyManager proxyManager;
+    private final Kernel kernel;
     private final ProxyFactory factory;
     private final Map proxies = new HashMap();
     private final Set listeners = new HashSet();
     private boolean stopped = false;
 
-    public ProxyCollection(String name, Class type, ProxyManager proxyManager, Set targets) {
+    public ProxyCollection(String name, Class type, Set targets, Kernel kernel) {
         this.name = name;
-        this.proxyManager = proxyManager;
-        factory = proxyManager.createProxyFactory(type);
+        this.kernel = kernel;
+        if (AbstractGBeanReference.NO_PROXY) {
+            factory = null;
+        } else {
+            factory = kernel.getProxyManager().createProxyFactory(type);
+        }
 
         for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
             addTarget((AbstractName) iterator.next());
@@ -59,8 +64,10 @@
 
     synchronized void destroy() {
         stopped = true;
-        for (Iterator iterator = proxies.values().iterator(); iterator.hasNext();) {
-            proxyManager.destroyProxy(iterator.next());
+        if (!AbstractGBeanReference.NO_PROXY) {
+            for (Iterator iterator = proxies.values().iterator(); iterator.hasNext();) {
+                kernel.getProxyManager().destroyProxy(iterator.next());
+            }
         }
         proxies.clear();
         listeners.clear();
@@ -76,7 +83,17 @@
             }
 
             // create and add the proxy
-            proxy = factory.createProxy(target);
+            if (AbstractGBeanReference.NO_PROXY) {
+                try {
+                    proxy = kernel.getGBean(target);
+                } catch (GBeanNotFoundException e) {
+                    // gbean disappeard on us
+                    log.debug("GBean was unloaded before it could be added to reference collections: " + target);
+                    return;
+                }
+            } else {
+                proxy = factory.createProxy(target);
+            }
             proxies.put(target, proxy);
 
             // make a snapshot of the listeners
@@ -121,7 +138,9 @@
         }
 
         // destroy the proxy
-        proxyManager.destroyProxy(proxy);
+        if (!AbstractGBeanReference.NO_PROXY) {
+            kernel.getProxyManager().destroyProxy(proxy);
+        }
     }
 
     public synchronized ObjectName[] getMemberObjectNames() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/ClassLoading.java Thu Mar 16 19:10:09 2006
@@ -19,6 +19,12 @@
 
 import java.lang.reflect.Array;
 import java.util.HashMap;
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * Utility class for loading classes by a variety of name variations.
@@ -256,6 +262,103 @@
         int dimensions[] = new int[dimension];
         // create an instance and return the associated class object.
         return Array.newInstance(type, dimensions).getClass();
+    }
+
+    public static Set getAllTypes(Class type) {
+        Set allTypes = new LinkedHashSet();
+        allTypes.add(type);
+        allTypes.addAll(getAllSuperClasses(type));
+        allTypes.addAll(getAllInterfaces(type));
+        return allTypes;
+    }
+
+    private static Set getAllSuperClasses(Class clazz) {
+        Set allSuperClasses = new LinkedHashSet();
+        for (Class superClass = clazz.getSuperclass(); superClass != null; superClass = superClass.getSuperclass()) {
+            allSuperClasses.add(superClass);
+        }
+        return allSuperClasses;
+    }
+
+    private static Set getAllInterfaces(Class clazz) {
+        Set allInterfaces = new LinkedHashSet();
+        LinkedList stack = new LinkedList();
+        stack.addAll(Arrays.asList(clazz.getInterfaces()));
+        while (!stack.isEmpty()) {
+            Class intf = (Class) stack.removeFirst();
+            if (!allInterfaces.contains(intf)) {
+                allInterfaces.add(intf);
+                stack.addAll(Arrays.asList(intf.getInterfaces()));
+            }
+        }
+        return allInterfaces;
+    }
+
+    public static Set reduceInterfaces(Set source) {
+        Class[] classes = (Class[]) source.toArray(new Class[source.size()]);
+        classes = reduceInterfaces(classes);
+        return new LinkedHashSet(Arrays.asList(classes));
+    }
+
+    /**
+     * If there are multiple interfaces, and some of them extend each other,
+     * eliminate the superclass in favor of the subclasses that extend them.
+     *
+     * If one of the entries is a class (not an interface), make sure it's
+     * the first one in the array.  If more than one of the entries is a
+     * class, throws an IllegalArgumentException
+     *
+     * @param source the original list of interfaces
+     * @return the equal or smaller list of interfaces
+     */
+    public static Class[] reduceInterfaces(Class[] source) {
+        // use a copy of the sorce array
+        source = (Class[]) source.clone();
+
+        for (int leftIndex = 0; leftIndex < source.length-1; leftIndex++) {
+            Class left = source[leftIndex];
+            if(left == null) {
+                continue;
+            }
+
+            for (int rightIndex = leftIndex +1; rightIndex < source.length; rightIndex++) {
+                Class right = source[rightIndex];
+                if(right == null) {
+                    continue;
+                }
+
+                if(left == right || right.isAssignableFrom(left)) {
+                    // right is the same as class or a sub class of left
+                    source[rightIndex] = null;
+                } else if(left.isAssignableFrom(right)) {
+                    // left is the same as class or a sub class of right
+                    source[leftIndex] = null;
+
+                    // the left has been eliminated; move on to the next left
+                    break;
+                }
+            }
+        }
+
+        Class clazz = null;
+        for (int i = 0; i < source.length; i++) {
+            if (source[i] != null && !source[i].isInterface()) {
+                if (clazz != null) {
+                    throw new IllegalArgumentException("Source contains two classes which are not subclasses of each other: " + clazz.getName() + ", " + source[i].getName());
+                }
+                clazz = source[i];
+                source[i] = null;
+            }
+        }
+
+        List list = new ArrayList(source.length);
+        if (clazz != null) list.add(clazz);
+        for (int i = 0; i < source.length; i++) {
+            if(source[i] != null) {
+                list.add(source[i]);
+            }
+        }
+        return (Class[]) list.toArray(new Class[list.size()]);
     }
 }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java Thu Mar 16 19:10:09 2006
@@ -32,7 +32,7 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 386505 $ $Date$
  */
 public interface Kernel {
     /**
@@ -90,6 +90,22 @@
      */
     boolean isLoaded(ObjectName name);
     boolean isLoaded(AbstractName name);
+    boolean isLoaded(String shortName);
+    boolean isLoaded(Class type);
+    boolean isLoaded(String shortName, Class type);
+
+    /**
+     * Gets the specified GBean instance.
+     *
+     * @param name the GBean instance to get
+     * @throws org.apache.geronimo.kernel.GBeanNotFoundException if the GBean could not be found
+     * @throws InternalKernelException if there is a general error
+     * @throws IllegalStateException If the gbean is disabled
+     */
+    Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Start a specific GBean.
@@ -101,6 +117,9 @@
      */
     void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
     void startGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Start a specific GBean and its children.
@@ -112,6 +131,19 @@
      */
     void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
     void startRecursiveGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startRecursiveGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startRecursiveGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void startRecursiveGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+
+    /**
+     * Is there a GBean registered with the kernel under the specified name and is it running?
+     * @param name the name to check
+     * @return true if there is a gbean registered under the specified name and is it running; false otherwise
+     */
+    boolean isRunning(AbstractName name);
+    boolean isRunning(String shortName);
+    boolean isRunning(Class type);
+    boolean isRunning(String shortName, Class type);
 
     /**
      * Stop a specific GBean.
@@ -123,6 +155,9 @@
      */
     void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
     void stopGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void stopGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void stopGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void stopGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Unload a specific GBean.
@@ -134,6 +169,9 @@
      */
     void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
     void unloadGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void unloadGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void unloadGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
+    void unloadGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException;
 
     /**
      * Gets the state of the specified GBean.
@@ -143,6 +181,9 @@
      */
     int getGBeanState(ObjectName name) throws GBeanNotFoundException;
     int getGBeanState(AbstractName name) throws GBeanNotFoundException;
+    int getGBeanState(String shortName) throws GBeanNotFoundException;
+    int getGBeanState(Class type) throws GBeanNotFoundException;
+    int getGBeanState(String shortName, Class type) throws GBeanNotFoundException;
 
     /**
      * Gets the time the specified GBean was started
@@ -152,14 +193,19 @@
      */
     long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException;
     long getGBeanStartTime(AbstractName name) throws GBeanNotFoundException;
+    long getGBeanStartTime(String shortName) throws GBeanNotFoundException;
+    long getGBeanStartTime(Class type) throws GBeanNotFoundException;
+    long getGBeanStartTime(String shortName, Class type) throws GBeanNotFoundException;
 
     /**
      * Is the specified GBean enabled?
      * @param name the name if the GBean
      * @return true if the gbean is enabled
      * @throws GBeanNotFoundException if the GBean could not be found
+     * @deprecated Use attribute store instead of disabling gbeans
      */
     boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException;
+    /** @deprecated Use attribute store instead of disabling gbeans */
     boolean isGBeanEnabled(AbstractName name) throws GBeanNotFoundException;
 
     /**
@@ -168,8 +214,10 @@
      * @param name the name if the GBean
      * @param enabled the new enabled status
      * @throws GBeanNotFoundException if the GBean could not be found
+     * @deprecated Use attribute store instead of disabling gbeans
      */
     void setGBeanEnabled(ObjectName name, boolean enabled) throws GBeanNotFoundException;
+    /** @deprecated Use attribute store instead of disabling gbeans */
     void setGBeanEnabled(AbstractName name, boolean enabled) throws GBeanNotFoundException;
 
     /**
@@ -179,6 +227,10 @@
      * @throws GBeanNotFoundException if the specified GBean is not registered with the kernel
      */
     ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException;
+    ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException;
+    ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException;
+    ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException;
+    ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException;
 
     /**
      * Return the GBeanInfo for a registered GBean instance.
@@ -188,6 +240,9 @@
      */
     GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException;
     GBeanInfo getGBeanInfo(AbstractName name) throws GBeanNotFoundException;
+    GBeanInfo getGBeanInfo(String shortName) throws GBeanNotFoundException;
+    GBeanInfo getGBeanInfo(Class type) throws GBeanNotFoundException;
+    GBeanInfo getGBeanInfo(String shortName, Class type) throws GBeanNotFoundException;
 
     /**
      * Return the GBeanData for a GBean instance.
@@ -197,6 +252,9 @@
      */
     GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException;
     GBeanData getGBeanData(AbstractName name) throws GBeanNotFoundException, InternalKernelException;
+    GBeanData getGBeanData(String shortName) throws GBeanNotFoundException, InternalKernelException;
+    GBeanData getGBeanData(Class type) throws GBeanNotFoundException, InternalKernelException;
+    GBeanData getGBeanData(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException;
 
     /**
      * Returns a Set of all GBeans matching the object name pattern
@@ -227,6 +285,9 @@
      */
     Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
     Object getAttribute(AbstractName abstractName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    Object getAttribute(String shortName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    Object getAttribute(Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    Object getAttribute(String shortName, Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
 
     /**
      * Sets the value of an attribute on the specified gbean
@@ -239,6 +300,9 @@
      */
     void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
     void setAttribute(AbstractName abstractName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    void setAttribute(String shortName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    void setAttribute(Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
+    void setAttribute(String shortName, Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception;
 
     /**
      * Invokes a no-argument method on the specified GBean
@@ -252,6 +316,9 @@
      */
     Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
     Object invoke(AbstractName abstractName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(String shortName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(String shortName, Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
 
     /**
      * Invokes a method on the specified GBean with the specified arguments
@@ -267,6 +334,9 @@
      */
     Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
     Object invoke(AbstractName abstractName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(String shortName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
+    Object invoke(String shortName, Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception;
 
     /**
      * Assuming the argument represents a service running in the kernel,
@@ -274,6 +344,12 @@
      * kernel cannot produce an ObjectName for it, returns null.
      */
     AbstractName getAbstractNameFor(Object service);
+
+    /**
+     * Assuming the argument represents a service running in the kernel,
+     * returns the short name of the service.  If the argument is not a service, returns null.
+     */
+    String getShortNameFor(Object service);
 
     /**
      * Brings the kernel online

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/KernelGBean.java Thu Mar 16 19:10:09 2006
@@ -39,6 +39,14 @@
         this.kernel = kernel;
     }
 
+    public String getKernelName() {
+        return kernel.getKernelName();
+    }
+
+    public Naming getNaming() {
+        return kernel.getNaming();
+    }
+
     public DependencyManager getDependencyManager() {
         return kernel.getDependencyManager();
     }
@@ -51,24 +59,44 @@
         return kernel.getProxyManager();
     }
 
-    public void boot() throws Exception {
-        throw new UnsupportedOperationException();
+    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
+        kernel.loadGBean(gbeanData, classLoader);
     }
 
-    public Naming getNaming() {
-        throw new UnsupportedOperationException();
+    public boolean isLoaded(ObjectName name) {
+        return kernel.isLoaded(name);
     }
 
-    public Date getBootTime() {
-        return kernel.getBootTime();
+    public boolean isLoaded(AbstractName name) {
+        return kernel.isLoaded(name);
     }
 
-    public String getKernelName() {
-        return kernel.getKernelName();
+    public boolean isLoaded(String shortName) {
+        return kernel.isLoaded(shortName);
     }
 
-    public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
-        kernel.loadGBean(gbeanData, classLoader);
+    public boolean isLoaded(Class type) {
+        return kernel.isLoaded(type);
+    }
+
+    public boolean isLoaded(String shortName, Class type) {
+        return kernel.isLoaded(shortName, type);
+    }
+
+    public Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return kernel.getGBean(name);
+    }
+
+    public Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return kernel.getGBean(shortName);
+    }
+
+    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return kernel.getGBean(type);
+    }
+
+    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return kernel.getGBean(shortName, type);
     }
 
     public void startGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
@@ -79,6 +107,18 @@
         kernel.startGBean(name);
     }
 
+    public void startGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startGBean(shortName);
+    }
+
+    public void startGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startGBean(type);
+    }
+
+    public void startGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startGBean(shortName, type);
+    }
+
     public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         kernel.startRecursiveGBean(name);
     }
@@ -87,6 +127,34 @@
         kernel.startRecursiveGBean(name);
     }
 
+    public void startRecursiveGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startRecursiveGBean(shortName);
+    }
+
+    public void startRecursiveGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startRecursiveGBean(type);
+    }
+
+    public void startRecursiveGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.startRecursiveGBean(shortName, type);
+    }
+
+    public boolean isRunning(AbstractName name) {
+        return kernel.isRunning(name);
+    }
+
+    public boolean isRunning(String shortName) {
+        return kernel.isRunning(shortName);
+    }
+
+    public boolean isRunning(Class type) {
+        return kernel.isRunning(type);
+    }
+
+    public boolean isRunning(String shortName, Class type) {
+        return kernel.isRunning(shortName, type);
+    }
+
     public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         kernel.stopGBean(name);
     }
@@ -95,7 +163,19 @@
         kernel.stopGBean(name);
     }
 
-    public void unloadGBean(ObjectName name) throws GBeanNotFoundException {
+    public void stopGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.stopGBean(shortName);
+    }
+
+    public void stopGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.stopGBean(type);
+    }
+
+    public void stopGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.stopGBean(shortName, type);
+    }
+
+    public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         kernel.unloadGBean(name);
     }
 
@@ -103,6 +183,18 @@
         kernel.unloadGBean(name);
     }
 
+    public void unloadGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.unloadGBean(shortName);
+    }
+
+    public void unloadGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.unloadGBean(type);
+    }
+
+    public void unloadGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        kernel.unloadGBean(shortName, type);
+    }
+
     public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
         return kernel.getGBeanState(name);
     }
@@ -111,6 +203,18 @@
         return kernel.getGBeanState(name);
     }
 
+    public int getGBeanState(String shortName) throws GBeanNotFoundException {
+        return kernel.getGBeanState(shortName);
+    }
+
+    public int getGBeanState(Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanState(type);
+    }
+
+    public int getGBeanState(String shortName, Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanState(shortName, type);
+    }
+
     public long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException {
         return kernel.getGBeanStartTime(name);
     }
@@ -119,6 +223,18 @@
         return kernel.getGBeanStartTime(name);
     }
 
+    public long getGBeanStartTime(String shortName) throws GBeanNotFoundException {
+        return kernel.getGBeanStartTime(shortName);
+    }
+
+    public long getGBeanStartTime(Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanStartTime(type);
+    }
+
+    public long getGBeanStartTime(String shortName, Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanStartTime(shortName, type);
+    }
+
     public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
         return kernel.isGBeanEnabled(name);
     }
@@ -135,16 +251,44 @@
         kernel.setGBeanEnabled(name, enabled);
     }
 
-    public boolean isRunning() {
-        return kernel.isRunning();
+    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
+        return kernel.getClassLoaderFor(name);
     }
 
-    public Set listGBeans(AbstractNameQuery refInfoQuery) {
-        return kernel.listGBeans(refInfoQuery);
+    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
+        return kernel.getClassLoaderFor(name);
     }
 
-    public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
-        return kernel.getClassLoaderFor(name);
+    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
+        return kernel.getClassLoaderFor(shortName);
+    }
+
+    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
+        return kernel.getClassLoaderFor(type);
+    }
+
+    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
+        return kernel.getClassLoaderFor(shortName, type);
+    }
+
+    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(name);
+    }
+
+    public GBeanInfo getGBeanInfo(AbstractName name) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(name);
+    }
+
+    public GBeanInfo getGBeanInfo(String shortName) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(shortName);
+    }
+
+    public GBeanInfo getGBeanInfo(Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(type);
+    }
+
+    public GBeanInfo getGBeanInfo(String shortName, Class type) throws GBeanNotFoundException {
+        return kernel.getGBeanInfo(shortName, type);
     }
 
     public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
@@ -155,7 +299,31 @@
         return kernel.getGBeanData(name);
     }
 
-    public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
+    public GBeanData getGBeanData(String shortName) throws GBeanNotFoundException, InternalKernelException {
+        return kernel.getGBeanData(shortName);
+    }
+
+    public GBeanData getGBeanData(Class type) throws GBeanNotFoundException, InternalKernelException {
+        return kernel.getGBeanData(type);
+    }
+
+    public GBeanData getGBeanData(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException {
+        return kernel.getGBeanData(shortName, type);
+    }
+
+    public Set listGBeans(ObjectName pattern) {
+        return kernel.listGBeans(pattern);
+    }
+
+    public Set listGBeans(Set patterns) {
+        return kernel.listGBeans(patterns);
+    }
+
+    public Set listGBeans(GBeanQuery query) {
+        return kernel.listGBeans(query);
+    }
+
+    public Object getAttribute(ObjectName objectName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
         return kernel.getAttribute(objectName, attributeName);
     }
 
@@ -163,7 +331,19 @@
         return kernel.getAttribute(abstractName, attributeName);
     }
 
-    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws Exception {
+    public Object getAttribute(String shortName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return kernel.getAttribute(shortName, attributeName);
+    }
+
+    public Object getAttribute(Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return kernel.getAttribute(type, attributeName);
+    }
+
+    public Object getAttribute(String shortName, Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return kernel.getAttribute(shortName, type, attributeName);
+    }
+
+    public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
         kernel.setAttribute(objectName, attributeName, attributeValue);
     }
 
@@ -171,7 +351,19 @@
         kernel.setAttribute(abstractName, attributeName, attributeValue);
     }
 
-    public Object invoke(ObjectName objectName, String methodName) throws Exception {
+    public void setAttribute(String shortName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        kernel.setAttribute(shortName, attributeName, attributeValue);
+    }
+
+    public void setAttribute(Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        kernel.setAttribute(type, attributeName, attributeValue);
+    }
+
+    public void setAttribute(String shortName, Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        kernel.setAttribute(shortName, type, attributeName, attributeValue);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
         return kernel.invoke(objectName, methodName);
     }
 
@@ -179,7 +371,19 @@
         return kernel.invoke(abstractName, methodName);
     }
 
-    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws Exception {
+    public Object invoke(String shortName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(shortName, methodName);
+    }
+
+    public Object invoke(Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(type, methodName);
+    }
+
+    public Object invoke(String shortName, Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(shortName, type, methodName);
+    }
+
+    public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
         return kernel.invoke(objectName, methodName, args, types);
     }
 
@@ -187,32 +391,32 @@
         return kernel.invoke(abstractName, methodName, args, types);
     }
 
-    public boolean isLoaded(ObjectName name) {
-        return kernel.isLoaded(name);
+    public Object invoke(String shortName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(shortName, methodName, args, types);
     }
 
-    public boolean isLoaded(AbstractName name) {
-        return kernel.isLoaded(name);
+    public Object invoke(Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(type, methodName, args, types);
     }
 
-    public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
-        return kernel.getGBeanInfo(name);
+    public Object invoke(String shortName, Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return kernel.invoke(shortName, type, methodName, args, types);
     }
 
-    public GBeanInfo getGBeanInfo(AbstractName name) throws GBeanNotFoundException {
-        return kernel.getGBeanInfo(name);
+    public AbstractName getAbstractNameFor(Object service) {
+        return kernel.getAbstractNameFor(service);
     }
 
-    public Set listGBeans(ObjectName pattern) throws InternalKernelException {
-        return kernel.listGBeans(pattern);
+    public String getShortNameFor(Object service) {
+        return kernel.getShortNameFor(service);
     }
 
-    public Set listGBeans(Set patterns) throws InternalKernelException {
-        return kernel.listGBeans(patterns);
+    public void boot() throws Exception {
+        kernel.boot();
     }
 
-    public Set listGBeans(GBeanQuery query) {
-        return kernel.listGBeans(query);
+    public Date getBootTime() {
+        return kernel.getBootTime();
     }
 
     public void registerShutdownHook(Runnable hook) {
@@ -227,8 +431,12 @@
         kernel.shutdown();
     }
 
-    public AbstractName getAbstractNameFor(Object service) {
-        return kernel.getAbstractNameFor(service);
+    public boolean isRunning() {
+        return kernel.isRunning();
+    }
+
+    public Set listGBeans(AbstractNameQuery refInfoQuery) {
+        return kernel.listGBeans(refInfoQuery);
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicKernel.java Thu Mar 16 19:10:09 2006
@@ -45,6 +45,7 @@
 import org.apache.geronimo.kernel.NoSuchOperationException;
 import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
 
@@ -179,6 +180,19 @@
         return gbeanInstance.getAttribute(attributeName);
     }
 
+    public Object getAttribute(String shortName, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return getAttribute(shortName, null, attributeName);
+    }
+
+    public Object getAttribute(Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        return getAttribute(null, type, attributeName);
+    }
+
+    public Object getAttribute(String shortName, Class type, String attributeName) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.getAttribute(attributeName);
+    }
+
     public void setAttribute(ObjectName objectName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(objectName));
         gbeanInstance.setAttribute(attributeName, attributeValue);
@@ -189,6 +203,19 @@
         gbeanInstance.setAttribute(attributeName, attributeValue);
     }
 
+    public void setAttribute(String shortName, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        setAttribute(shortName, null, attributeName, attributeValue);
+    }
+
+    public void setAttribute(Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        setAttribute(null, type, attributeName, attributeValue);
+    }
+
+    public void setAttribute(String shortName, Class type, String attributeName, Object attributeValue) throws GBeanNotFoundException, NoSuchAttributeException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        gbeanInstance.setAttribute(attributeName, attributeValue);
+    }
+
     public Object invoke(ObjectName objectName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
         return invoke(objectName, methodName, NO_ARGS, NO_TYPES);
     }
@@ -197,6 +224,18 @@
         return invoke(abstractName, methodName, NO_ARGS, NO_TYPES);
     }
 
+    public Object invoke(String shortName, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(shortName, null, methodName, NO_ARGS, NO_TYPES);
+    }
+
+    public Object invoke(Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(null, type, methodName, NO_ARGS, NO_TYPES);
+    }
+
+    public Object invoke(String shortName, Class type, String methodName) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(shortName, type, methodName, NO_ARGS, NO_TYPES);
+    }
+
     public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(objectName));
         return gbeanInstance.invoke(methodName, args, types);
@@ -207,6 +246,19 @@
         return gbeanInstance.invoke(methodName, args, types);
     }
 
+    public Object invoke(String shortName, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(shortName, null, methodName, args, types);
+    }
+
+    public Object invoke(Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        return invoke(null, type,methodName, args, types);
+    }
+
+    public Object invoke(String shortName, Class type, String methodName, Object[] args, String[] types) throws GBeanNotFoundException, NoSuchOperationException, InternalKernelException, Exception {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.invoke(methodName, args, types);
+    }
+
     public boolean isLoaded(ObjectName name) {
         return registry.isRegistered(createGBeanName(name));
     }
@@ -215,6 +267,48 @@
         return registry.isRegistered(name);
     }
 
+    public boolean isLoaded(String shortName) {
+        return isLoaded(shortName, null);
+    }
+
+    public boolean isLoaded(Class type) {
+        return isLoaded(null, type);
+    }
+
+    public boolean isLoaded(String shortName, Class type) {
+        try {
+            registry.getGBeanInstance(shortName, type);
+            return true;
+        } catch (GBeanNotFoundException e) {
+            // Dain: yes this is flow control using exceptions, but I'm too lazy to add another isRegistered method to the basic registry
+            return false;
+        }
+    }
+
+    public Object getGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return getGBean(shortName, null);
+    }
+
+    public Object getGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        return getGBean(null, type);
+    }
+
+    public Object getGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        if (gbeanInstance.getState() != State.RUNNING_INDEX) {
+            throw new IllegalStateException("GBean is not running: " + gbeanInstance.getAbstractName());
+        }
+        return gbeanInstance.getTarget();
+    }
+
+    public Object getGBean(AbstractName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException  {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(name);
+        if (gbeanInstance.getState() != State.RUNNING_INDEX) {
+            throw new IllegalStateException("GBean is not running: " + name);
+        }
+        return gbeanInstance.getTarget();
+    }
+
     public GBeanInfo getGBeanInfo(ObjectName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         return gbeanInstance.getGBeanInfo();
@@ -225,6 +319,19 @@
         return gbeanInstance.getGBeanInfo();
     }
 
+    public GBeanInfo getGBeanInfo(String shortName) throws GBeanNotFoundException {
+        return getGBeanInfo(shortName, null);
+    }
+
+    public GBeanInfo getGBeanInfo(Class type) throws GBeanNotFoundException {
+        return getGBeanInfo(null, type);
+    }
+
+    public GBeanInfo getGBeanInfo(String shortName, Class type) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.getGBeanInfo();
+    }
+
     public GBeanData getGBeanData(ObjectName name) throws GBeanNotFoundException, InternalKernelException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         return gbeanInstance.getGBeanData();
@@ -235,6 +342,19 @@
         return gbeanInstance.getGBeanData();
     }
 
+    public GBeanData getGBeanData(String shortName) throws GBeanNotFoundException, InternalKernelException {
+        return getGBeanData(shortName, null);
+    }
+
+    public GBeanData getGBeanData(Class type) throws GBeanNotFoundException, InternalKernelException {
+        return getGBeanData(null, type);
+    }
+
+    public GBeanData getGBeanData(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.getGBeanData();
+    }
+
     public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
         AbstractName abstractName = gbeanData.getAbstractName();
         Set interfaces = gbeanData.getGBeanInfo().getInterfaces();
@@ -252,6 +372,19 @@
         gbeanInstance.start();
     }
 
+    public void startGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        startGBean(shortName, null);
+    }
+
+    public void startGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        startGBean(null, type);
+    }
+
+    public void startGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        gbeanInstance.start();
+    }
+
     public void startRecursiveGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         gbeanInstance.startRecursive();
@@ -262,6 +395,45 @@
         gbeanInstance.startRecursive();
     }
 
+    public void startRecursiveGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        startRecursiveGBean(shortName, null);
+    }
+
+    public void startRecursiveGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        startRecursiveGBean(null, type);
+    }
+
+    public void startRecursiveGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        gbeanInstance.startRecursive();
+    }
+
+    public boolean isRunning(AbstractName name) {
+        try {
+            GBeanInstance gbeanInstance = registry.getGBeanInstance(name);
+            return gbeanInstance.getState() == State.RUNNING_INDEX;
+        } catch (GBeanNotFoundException e) {
+            return false;
+        }
+    }
+
+    public boolean isRunning(String shortName) {
+        return isRunning(shortName, null);
+    }
+
+    public boolean isRunning(Class type) {
+        return isRunning(null, type);
+    }
+
+    public boolean isRunning(String shortName, Class type) {
+        try {
+            GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+            return gbeanInstance.getState() == State.RUNNING_INDEX;
+        } catch (GBeanNotFoundException e) {
+            return false;
+        }
+    }
+
     public void stopGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         gbeanInstance.stop();
@@ -272,6 +444,19 @@
         gbeanInstance.stop();
     }
 
+    public void stopGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        stopGBean(shortName, null);
+    }
+
+    public void stopGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        stopGBean(null, type);
+    }
+
+    public void stopGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        gbeanInstance.stop();
+    }
+
     public void unloadGBean(ObjectName name) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
         GBeanName gbeanName = createGBeanName(name);
         GBeanInstance gbeanInstance = registry.getGBeanInstance(gbeanName);
@@ -285,6 +470,21 @@
         registry.unregister(name);
     }
 
+    public void unloadGBean(String shortName) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        unloadGBean(shortName, null);
+    }
+
+    public void unloadGBean(Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        unloadGBean(null, type);
+    }
+
+    public void unloadGBean(String shortName, Class type) throws GBeanNotFoundException, InternalKernelException, IllegalStateException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        AbstractName name = gbeanInstance.getAbstractName();
+        gbeanInstance.die();
+        registry.unregister(name);
+    }
+
     public int getGBeanState(ObjectName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         return gbeanInstance.getState();
@@ -295,6 +495,19 @@
         return gbeanInstance.getState();
     }
 
+    public int getGBeanState(String shortName) throws GBeanNotFoundException {
+        return getGBeanState(shortName, null);
+    }
+
+    public int getGBeanState(Class type) throws GBeanNotFoundException {
+        return getGBeanState(null, type);
+    }
+
+    public int getGBeanState(String shortName, Class type) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.getState();
+    }
+
     public long getGBeanStartTime(ObjectName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         return gbeanInstance.getStartTime();
@@ -305,6 +518,19 @@
         return gbeanInstance.getStartTime();
     }
 
+    public long getGBeanStartTime(String shortName) throws GBeanNotFoundException {
+        return getGBeanStartTime(shortName, null);
+    }
+
+    public long getGBeanStartTime(Class type) throws GBeanNotFoundException {
+        return getGBeanStartTime(null, type);
+    }
+
+    public long getGBeanStartTime(String shortName, Class type) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
+        return gbeanInstance.getStartTime();
+    }
+
     public boolean isGBeanEnabled(ObjectName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
         return gbeanInstance.isEnabled();
@@ -418,10 +644,17 @@
     }
 
     public AbstractName getAbstractNameFor(Object service) {
+        // todo we need to keep an identity map for non proxied references
         if(!running) {return null;}
         return proxyManager.getProxyTarget(service);
     }
 
+    public String getShortNameFor(Object service) {
+        // todo we need to keep an identity map for non proxied references
+        AbstractName name = getAbstractNameFor(service);
+        return (String) name.getName().get("name");
+    }
+
     /**
      * Boot this Kernel, triggering the instantiation of the MBeanServer and DependencyManager,
      * and the registration of ConfigurationStore
@@ -519,6 +752,24 @@
 
     public ClassLoader getClassLoaderFor(ObjectName name) throws GBeanNotFoundException {
         GBeanInstance gbeanInstance = registry.getGBeanInstance(createGBeanName(name));
+        return gbeanInstance.getClassLoader();
+    }
+
+    public ClassLoader getClassLoaderFor(AbstractName name) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(name);
+        return gbeanInstance.getClassLoader();
+    }
+
+    public ClassLoader getClassLoaderFor(String shortName) throws GBeanNotFoundException {
+        return getClassLoaderFor(shortName, null);
+    }
+
+    public ClassLoader getClassLoaderFor(Class type) throws GBeanNotFoundException {
+        return getClassLoaderFor(null, type);
+    }
+
+    public ClassLoader getClassLoaderFor(String shortName, Class type) throws GBeanNotFoundException {
+        GBeanInstance gbeanInstance = registry.getGBeanInstance(shortName, type);
         return gbeanInstance.getClassLoader();
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicProxyManager.java Thu Mar 16 19:10:09 2006
@@ -27,6 +27,7 @@
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.kernel.proxy.ProxyFactory;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
 import org.apache.geronimo.kernel.proxy.ProxyCreationException;
@@ -212,7 +213,7 @@
         public ManagedProxyFactory(Class[] type, ClassLoader classLoader) {
             Enhancer enhancer = new Enhancer();
             if(type.length > 1) { // shrink first -- may reduce from many to one
-                type = reduceInterfaces(type);
+                type = ClassLoading.reduceInterfaces(type);
             }
             if(type.length == 0) {
                 throw new IllegalArgumentException("Cannot generate proxy for 0 interfaces!");
@@ -287,81 +288,6 @@
                   throw new ProxyCreationException(e);
                 }
             }
-        }
-
-        /**
-         * If there are multiple interfaces, and some of them extend each other,
-         * eliminate the superclass in favor of the subclasses that extend them.
-         *
-         * If one of the entries is a class (not an interface), make sure it's
-         * the first one in the array.  If more than one of the entries is a
-         * class, throws an IllegalArgumentException
-         *
-         * @param source the original list of interfaces
-         * @return the equal or smaller list of interfaces
-         */
-        private Class[] reduceInterfaces(Class[] source) {
-            boolean changed = false;
-            Class cls = null;
-            for (int i = 0; i < source.length-1; i++) {
-                Class original = source[i];
-                if(original == null) {
-                    continue;
-                }
-                if(!original.isInterface()) {
-                    if(cls != null) {
-                        throw new IllegalArgumentException(original.getName()+" is not an interface (already have "+cls.getName()+"); can only have one non-interface class for proxy");
-                    } else {
-                        cls = original;
-                    }
-                }
-                for (int j = i+1; j < source.length; j++) {
-                    Class other = source[j];
-                    if(other == null) {
-                        continue;
-                    }
-                    if(!other.isInterface()) {
-                        if(cls != null) {
-                            throw new IllegalArgumentException(other.getName()+" is not an interface (already have "+cls.getName()+"); can only have one non-interface class for proxy");
-                        } else {
-                            cls = other;
-                        }
-                    }
-                    if(other.isAssignableFrom(original)) {
-                        source[j] = null; // clear out "other"
-                        changed = true;
-                    } else if(original.isAssignableFrom(other)) {
-                        source[i] = null; // clear out "original"
-                        changed = true;
-                        break; // the original has been eliminated; move on to the next original
-                    }
-                }
-            }
-
-            if(cls != null) {
-                if(cls != source[0]) {
-                    for (int i = 0; i < source.length; i++) {
-                        if(cls == source[i]) {
-                            Class temp = source[0];
-                            source[0] = source[i];
-                            source[i] = temp;
-                            break;
-                        }
-                    }
-                    changed = true;
-                }
-            }
-
-            if(!changed) {
-                return source;
-            }
-            List list = new ArrayList(source.length);
-            for (int i = 0; i < source.length; i++) {
-                if(source[i] != null) {
-                    list.add(source[i]);
-                }
-            }
-            return (Class[]) list.toArray(new Class[list.size()]);
         }
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java?rev=386515&r1=386514&r2=386515&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicRegistry.java Thu Mar 16 19:10:09 2006
@@ -21,6 +21,7 @@
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Collections;
 
 import javax.management.ObjectName;
 import javax.management.MalformedObjectNameException;
@@ -32,11 +33,10 @@
 import org.apache.geronimo.gbean.GBeanName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.runtime.GBeanInstance;
 
 /**
- * @version $Rev$ $Date$
+ * @version $Rev: 386505 $ $Date$
  */
 public class BasicRegistry {
     private final Map objectNameRegistry = new HashMap();
@@ -140,6 +140,38 @@
         if (instance == null) {
             throw new GBeanNotFoundException(abstractName);
         }
+        return instance;
+    }
+
+
+    public synchronized GBeanInstance getGBeanInstance(String shortName, Class type) throws GBeanNotFoundException {
+        if (shortName == null && type == null) throw new IllegalArgumentException("shortName and type are both null");
+
+        AbstractNameQuery nameQuery;
+        if (type == null) {
+            nameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", shortName));
+        } else if (shortName == null) {
+            nameQuery = new AbstractNameQuery(null, Collections.EMPTY_MAP, type.getName());
+        } else {
+            nameQuery = new AbstractNameQuery(null, Collections.singletonMap("name", shortName), type.getName());
+        }
+        Set instances = listGBeans(nameQuery);
+
+        if (instances.size() == 0) {
+            throw new GBeanNotFoundException("No GBeans found", Collections.singleton(nameQuery));
+        }
+
+        if (instances.size() > 1) {
+            if (type == null) {
+                throw new GBeanNotFoundException("More then one GBean was found with shortName '" + shortName + "'", Collections.singleton(nameQuery));
+            }
+            if (shortName == null) {
+                throw new GBeanNotFoundException("More then one GBean was found with type '" + type.getName()+ "'", Collections.singleton(nameQuery));
+            }
+            throw new GBeanNotFoundException("More then one GBean was found with shortName '" + shortName + "' and type '" + type.getName()+ "'", Collections.singleton(nameQuery));
+        }
+
+        GBeanInstance instance = (GBeanInstance) instances.iterator().next();
         return instance;
     }
 



Mime
View raw message