geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r384141 [1/2] - in /geronimo/branches/1.1: configs/j2ee-system/src/plan/ modules/kernel/src/java/org/apache/geronimo/gbean/ modules/kernel/src/java/org/apache/geronimo/gbean/runtime/ modules/kernel/src/java/org/apache/geronimo/kernel/ modul...
Date Wed, 08 Mar 2006 07:30:11 GMT
Author: djencks
Date: Tue Mar  7 23:30:08 2006
New Revision: 384141

URL: http://svn.apache.org/viewcvs?rev=384141&view=rev
Log:
Simplify gbean dependencies/references.  Breaks around j2ee-management.  Next step is to pre-resolve references in ConfigurationManagerImpl preprocess step.

Added:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/ReferencePatterns.java
Modified:
    geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/AbstractName.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.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/GBeanDependency.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.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/kernel/DependencyManager.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.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/LifecycleMonitorFlyweight.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationUtil.java
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/ManageableAttributeStore.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/gbean/runtime/GBeanDependencyTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/GBeanTest.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationDump.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/ConfigurationOverride.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/GBeanOverride.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/jmx/MBeanServerKernelBridge.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/CommandLine.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/Daemon.java
    geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/LocalAttributeManagerTest.java
    geronimo/branches/1.1/modules/system/src/test/org/apache/geronimo/system/configuration/ServerOverrideTest.java
    geronimo/branches/1.1/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenAttributeStore.java

Modified: geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml (original)
+++ geronimo/branches/1.1/configs/j2ee-system/src/plan/plan.xml Tue Mar  7 23:30:08 2006
@@ -37,6 +37,9 @@
     </properties>
   </environment>
 
+  <!-- MBean server service -->
+  <gbean name="MBeanServerKernelBridge" class="org.apache.geronimo.system.jmx.MBeanServerKernelBridge"/>
+
   <!-- ServerInfo service -->
   <gbean name="ServerInfo" class="org.apache.geronimo.system.serverinfo.BasicServerInfo"/>
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/AbstractName.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/AbstractName.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/AbstractName.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/AbstractName.java Tue Mar  7 23:30:08 2006
@@ -68,15 +68,15 @@
     }
 
     public String toString() {
-        StringBuffer buf = new StringBuffer();
-            buf.append("artifact=").append(artifact);
-        for (Iterator iterator = interfaceTypes.iterator(); iterator.hasNext();) {
-            String interfaceType = (String) iterator.next();
-            buf.append(",interface=").append(interfaceType);
-        }
+        StringBuffer buf = new StringBuffer("AbstractName");
         for (Iterator iterator = name.entrySet().iterator(); iterator.hasNext();) {
             Map.Entry entry = (Map.Entry) iterator.next();
             buf.append(",").append(entry.getKey()).append("=").append(entry.getValue());
+        }
+        buf.append(",artifact=").append(artifact);
+        for (Iterator iterator = interfaceTypes.iterator(); iterator.hasNext();) {
+            String interfaceType = (String) iterator.next();
+            buf.append(",interface=").append(interfaceType);
         }
         return buf.toString();
     }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/GBeanData.java Tue Mar  7 23:30:08 2006
@@ -16,8 +16,7 @@
  */
 package org.apache.geronimo.gbean;
 
-import org.apache.geronimo.kernel.repository.Artifact;
-
+import javax.management.ObjectName;
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -28,18 +27,11 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
-import java.util.Hashtable;
-import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
 
 /**
  * @version $Rev$ $Date$
  */
 public class GBeanData implements Externalizable {
-    private Map nameMap;
-    private Set omit;
-    //TODO remove
-    private ObjectName name;
     private GBeanInfo gbeanInfo;
     private final Map attributes;
     private final Map references;
@@ -47,8 +39,6 @@
     private AbstractName abstractName;
 
     public GBeanData() {
-        nameMap = new HashMap();
-        omit = new HashSet();
         attributes = new HashMap();
         references = new HashMap();
         dependencies = new HashSet();
@@ -59,33 +49,13 @@
         this.gbeanInfo = gbeanInfo;
     }
 
-    public GBeanData(ObjectName name, GBeanInfo gbeanInfo) {
-        this();
-        this.name = name;
-        this.gbeanInfo = gbeanInfo;
-    }
-
     public GBeanData(AbstractName abstractName, GBeanInfo gbeanInfo) {
         this();
         this.abstractName = abstractName;
-        this.nameMap = abstractName.getName();
-        this.omit = new HashSet();
-        this.gbeanInfo = gbeanInfo;
-    }
-
-    public GBeanData(Map nameMap, Set omitMap, GBeanInfo gbeanInfo) {
-        this();
-        this.nameMap.putAll(nameMap);
-        if (omitMap != null) {
-            this.omit.addAll(omitMap);
-        }
         this.gbeanInfo = gbeanInfo;
     }
 
     public GBeanData(GBeanData gbeanData) {
-        nameMap = new HashMap(gbeanData.nameMap);
-        omit = new HashSet(gbeanData.omit);
-        name = gbeanData.name;
         gbeanInfo = gbeanData.gbeanInfo;
         attributes = new HashMap(gbeanData.attributes);
         references = new HashMap(gbeanData.references);
@@ -94,40 +64,15 @@
     }
 
     public ObjectName getName() {
-        //TODO remove the name attribute
-        return abstractName == null? name: abstractName.getObjectName();
-    }
-
-    //TODO remove
-    public void setName(ObjectName name) {
-        this.name = name;
-    }
-
-    public void initializeName(Artifact configName, ObjectName base) throws MalformedObjectNameException {
-        String domain = base.getDomain();
-        Hashtable keys = base.getKeyPropertyList();
-        keys.keySet().removeAll(omit);
-        keys.putAll(nameMap);
-        ObjectName objectName = new ObjectName(domain, keys);
-        abstractName = new AbstractName(configName, nameMap, gbeanInfo.getInterfaces(), objectName);
+        return abstractName == null? null: abstractName.getObjectName();
     }
 
     public AbstractName getAbstractName() {
         return abstractName;
     }
 
-    public void setNameMap(Map nameMap) {
-        this.nameMap.clear();
-        this.nameMap.putAll(nameMap);
-    }
-
-    public Map getNameMap() {
-        return nameMap;
-    }
-
-    public void setOmit(Set omit) {
-        this.omit.clear();
-        this.omit.addAll(omit);
+    public void setAbstractName(AbstractName abstractName) {
+        this.abstractName = abstractName;
     }
 
     public GBeanInfo getGBeanInfo() {
@@ -162,15 +107,23 @@
         return new HashSet(references.keySet());
     }
 
-    public Set getReferencePatterns(String name) {
-        return (Set) references.get(name);
+    public ReferencePatterns getReferencePatterns(String name) {
+        return (ReferencePatterns) references.get(name);
     }
 
     public void setReferencePattern(String name, AbstractNameQuery pattern) {
         setReferencePatterns(name, Collections.singleton(pattern));
     }
 
+    public void setReferencePattern(String name, AbstractName abstractName) {
+        setReferencePatterns(name, new ReferencePatterns(abstractName));
+    }
+
     public void setReferencePatterns(String name, Set patterns) {
+        setReferencePatterns(name, new ReferencePatterns(patterns));
+    }
+
+    public void setReferencePatterns(String name, ReferencePatterns patterns) {
         references.put(name, patterns);
     }
 
@@ -182,12 +135,9 @@
         // write the gbean info
         out.writeObject(gbeanInfo);
 
-        // write the object name
-        //TODO possibly remove this
-        out.writeObject(name);
+        // write the abstract name
+        out.writeObject(abstractName);
 
-        out.writeObject(nameMap);
-        out.writeObject(omit);
         // write the attributes
         out.writeInt(attributes.size());
         for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
@@ -207,7 +157,7 @@
         for (Iterator iterator = references.entrySet().iterator(); iterator.hasNext();) {
             Map.Entry entry = (Map.Entry) iterator.next();
             String name = (String) entry.getKey();
-            Set value = (Set) entry.getValue();
+            ReferencePatterns value = (ReferencePatterns) entry.getValue();
             try {
                 out.writeObject(name);
                 out.writeObject(value);
@@ -229,14 +179,11 @@
         // read the gbean info
         gbeanInfo = (GBeanInfo) in.readObject();
 
-        // read the object name
+        // read the abstract name
         try {
-            //TODO possibly remove this
-            name = (ObjectName) in.readObject();
-            nameMap = (Map) in.readObject();
-            omit = (Set) in.readObject();
+            abstractName = (AbstractName) in.readObject();
         } catch (IOException e) {
-            throw (IOException) new IOException("Unable to deserialize ObjectName for GBeanData of type " + gbeanInfo.getClassName()).initCause(e);
+            throw (IOException) new IOException("Unable to deserialize AbstractName for GBeanData of type " + gbeanInfo.getClassName()).initCause(e);
         }
 
 
@@ -251,7 +198,7 @@
             // read the references
             int endpointCount = in.readInt();
             for (int i = 0; i < endpointCount; i++) {
-                setReferencePatterns((String) in.readObject(), (Set) in.readObject());
+                setReferencePatterns((String) in.readObject(), (ReferencePatterns) in.readObject());
             }
 
             //read the dependencies
@@ -261,9 +208,9 @@
                 dependencies.add(objectName);
             }
         } catch (IOException e) {
-            throw (IOException) new IOException("Unable to deserialize GBeanData " + name).initCause(e);
+            throw (IOException) new IOException("Unable to deserialize GBeanData " + abstractName).initCause(e);
         } catch (ClassNotFoundException e) {
-            throw new ClassNotFoundException("Unable to find class used in GBeanData " + name, e);
+            throw new ClassNotFoundException("Unable to find class used in GBeanData " + abstractName, e);
         }
     }
 }

Added: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/ReferencePatterns.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/ReferencePatterns.java?rev=384141&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/ReferencePatterns.java (added)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/ReferencePatterns.java Tue Mar  7 23:30:08 2006
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.gbean;
+
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ReferencePatterns implements Serializable {
+
+    private final Set patterns;
+    private final AbstractName abstractName;
+
+    public ReferencePatterns(Set patterns) {
+        this.patterns = patterns;
+        this.abstractName = null;
+    }
+
+    public ReferencePatterns(AbstractName abstractName) {
+        this.abstractName = abstractName;
+        this.patterns = null;
+    }
+
+    public Set getPatterns() {
+        if (patterns == null) {
+            throw new IllegalStateException("This is resolved");
+        }
+        return patterns;
+    }
+
+    public AbstractName getAbstractName() {
+        if (abstractName == null) {
+            throw new IllegalStateException("This is not resolved");
+        }
+        return abstractName;
+    }
+
+}

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=384141&r1=384140&r2=384141&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 Tue Mar  7 23:30:08 2006
@@ -23,15 +23,10 @@
 import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
 
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -63,20 +58,7 @@
      */
     private final MethodInvoker setInvoker;
 
-    /**
-     * The target objectName patterns to watch for a connection.
-     */
-    private Set patterns = Collections.EMPTY_SET;
-
-    /**
-     * Our listener for lifecycle events
-     */
-    private final LifecycleListener listener;
-
-    /**
-     * Current set of targets
-     */
-    private final Set targets = new HashSet();
+    private final boolean hasTargets;
 
     /**
      * The metadata for this reference
@@ -89,25 +71,16 @@
     private final Kernel kernel;
 
     /**
-     * The dependency manager of the kernel.
-     */
-    private final DependencyManager dependencyManager;
-
-    /**
      * Proxy for this reference
      */
     private Object proxy;
 
-    /**
-     * is this reference online
-     */
-    private boolean isOnline = false;
 
-    public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
+    public AbstractGBeanReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, boolean hasTargets) throws InvalidConfigurationException {
         this.gbeanInstance = gbeanInstance;
         this.referenceInfo = referenceInfo;
         this.kernel = kernel;
-        this.dependencyManager = dependencyManager;
+        this.hasTargets = hasTargets;
 
         this.name = referenceInfo.getName();
         try {
@@ -136,23 +109,12 @@
             setInvoker = null;
         }
 
-        listener = createLifecycleListener();
     }
 
-    protected abstract LifecycleListener createLifecycleListener();
-
-    protected abstract void targetAdded(AbstractName target);
-
-    protected abstract void targetRemoved(AbstractName target);
-
     protected final Kernel getKernel() {
         return kernel;
     }
 
-    protected final DependencyManager getDependencyManager() {
-        return dependencyManager;
-    }
-
     public final GBeanInstance getGBeanInstance() {
         return gbeanInstance;
     }
@@ -181,89 +143,13 @@
         this.proxy = proxy;
     }
 
-    public final Set getPatterns() {
-        return patterns;
-    }
-
-    public final void setPatterns(Set patterns) {
-        if (isOnline) {
-            throw new IllegalStateException("Pattern set can not be modified while online");
-        }
-
-        if (patterns == null || patterns.isEmpty() || (patterns.size() == 1 && patterns.iterator().next() == null)) {
-            this.patterns = Collections.EMPTY_SET;
-        } else {
-            patterns = new HashSet(patterns);
-            for (Iterator iterator = this.patterns.iterator(); iterator.hasNext();) {
-                if (iterator.next() == null) {
-                    iterator.remove();
-                    //there can be at most one null value in a set.
-                    break;
-                }
-            }
-            this.patterns = Collections.unmodifiableSet(patterns);
-        }
-    }
-
-    public final synchronized void online() {
-        Set gbeans = kernel.listGBeans(patterns);
-        for (Iterator objectNameIterator = gbeans.iterator(); objectNameIterator.hasNext();) {
-            AbstractName target = (AbstractName) objectNameIterator.next();
-            if (!targets.contains(target)) {
-
-                // if the bean is running add it to the runningTargets list
-                if (isRunning(kernel, target)) {
-                    targets.add(target);
-                }
-            }
-        }
-
-        kernel.getLifecycleMonitor().addLifecycleListener(listener, patterns);
-        isOnline = true;
-    }
-
-    public final synchronized void offline() {
-        // make sure we are stoped
-        stop();
-
-        kernel.getLifecycleMonitor().removeLifecycleListener(listener);
-
-        targets.clear();
-        isOnline = false;
-    }
-
-    protected final Set getTargets() {
-        return targets;
-    }
-
-    protected final void addTarget(AbstractName abstractName) {
-        if (!targets.contains(abstractName)) {
-            targets.add(abstractName);
-            targetAdded(abstractName);
-        }
-    }
-
-    protected final void removeTarget(AbstractName abstractName) {
-        boolean wasTarget = targets.remove(abstractName);
-        if (wasTarget) {
-            targetRemoved(abstractName);
-        }
-    }
-
-    public final synchronized void inject(Object target) throws Exception {
-        // set the proxy into the instance
-        if (setInvoker != null && patterns.size() > 0) {
-            setInvoker.invoke(target, new Object[]{getProxy()});
-        }
-    }
-
     /**
      * Is the component in the Running state
      *
      * @param abstractName name of the component to check
      * @return true if the component is running; false otherwise
      */
-    private boolean isRunning(Kernel kernel, AbstractName abstractName) {
+    protected boolean isRunning(Kernel kernel, AbstractName abstractName) {
         try {
             final int state = kernel.getGBeanState(abstractName);
             return state == State.RUNNING_INDEX;
@@ -281,5 +167,12 @@
                 "\n    Reference Name: " + getName() +
                 "\n    Reference Type: " + referenceInfo.getReferenceType() +
                 "\n    Proxy Type: " + referenceInfo.getProxyType();
+    }
+
+    public final synchronized void inject(Object target) throws Exception {
+        // set the proxy into the instance
+        if (setInvoker != null && hasTargets) {
+            setInvoker.invoke(target, new Object[]{getProxy()});
+        }
     }
 }

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=384141&r1=384140&r2=384141&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 Tue Mar  7 23:30:08 2006
@@ -17,25 +17,53 @@
 
 package org.apache.geronimo.gbean.runtime;
 
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
 /**
  * @version $Rev$ $Date$
  */
 public class GBeanCollectionReference extends AbstractGBeanReference {
-    public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
-        super(gbeanInstance, referenceInfo, kernel, dependencyManager);
+
+
+    /**
+     * 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
+     */
+    private final LifecycleListener listener;
+
+    public GBeanCollectionReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, ReferencePatterns referencePatterns) throws InvalidConfigurationException {
+        super(gbeanInstance, referenceInfo, kernel, !(referencePatterns == null || referencePatterns.getPatterns().isEmpty()));
+        listener = createLifecycleListener();
+        if (referencePatterns != null) {
+            setPatterns(referencePatterns.getPatterns());
+        }
     }
 
     public synchronized boolean start() {
         // We only need to start if there are patterns and we don't already have a proxy
-        if (!getPatterns().isEmpty() && getProxy() == null) {
+        if (!patterns.isEmpty() && getProxy() == null) {
             // add a dependency on our target and create the proxy
             setProxy(new ProxyCollection(getName(), getReferenceType(), getKernel().getProxyManager(), getTargets()));
         }
@@ -87,4 +115,74 @@
                     }
                 };
     }
+
+    public final Set getPatterns() {
+        return patterns;
+    }
+
+    public final void setPatterns(Set patterns) {
+        if (isOnline) {
+            throw new IllegalStateException("Pattern set can not be modified while online");
+        }
+
+        if (patterns == null || patterns.isEmpty() || (patterns.size() == 1 && patterns.iterator().next() == null)) {
+            this.patterns = Collections.EMPTY_SET;
+        } else {
+            patterns = new HashSet(patterns);
+            for (Iterator iterator = this.patterns.iterator(); iterator.hasNext();) {
+                if (iterator.next() == null) {
+                    iterator.remove();
+                    //there can be at most one null value in a set.
+                    break;
+                }
+            }
+            this.patterns = Collections.unmodifiableSet(patterns);
+        }
+    }
+
+    public final synchronized void online() {
+        Set gbeans = getKernel().listGBeans(patterns);
+        for (Iterator objectNameIterator = gbeans.iterator(); objectNameIterator.hasNext();) {
+            AbstractName target = (AbstractName) objectNameIterator.next();
+            if (!targets.contains(target)) {
+
+                // if the bean is running add it to the runningTargets list
+                if (isRunning(getKernel(), target)) {
+                    targets.add(target);
+                }
+            }
+        }
+
+        getKernel().getLifecycleMonitor().addLifecycleListener(listener, patterns);
+        isOnline = true;
+    }
+
+    public final synchronized void offline() {
+        // make sure we are stoped
+        stop();
+
+        getKernel().getLifecycleMonitor().removeLifecycleListener(listener);
+
+        targets.clear();
+        isOnline = false;
+    }
+
+    protected final Set getTargets() {
+        return targets;
+    }
+
+    protected final void addTarget(AbstractName abstractName) {
+        if (!targets.contains(abstractName)) {
+            targets.add(abstractName);
+            targetAdded(abstractName);
+        }
+    }
+
+    protected final void removeTarget(AbstractName abstractName) {
+        boolean wasTarget = targets.remove(abstractName);
+        if (wasTarget) {
+            targetRemoved(abstractName);
+        }
+    }
+
 }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanDependency.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanDependency.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanDependency.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanDependency.java Tue Mar  7 23:30:08 2006
@@ -21,31 +21,29 @@
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
 
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
 /**
  * @version $Rev$ $Date$
  */
-public class GBeanDependency {
+public final class GBeanDependency {
+
+
+    private static final Log log = LogFactory.getLog(GBeanSingleReference.class);
+
     /**
      * The GBeanInstance to which this reference belongs.
      */
     private final GBeanInstance gbeanInstance;
 
     /**
-     * The target objectName patterns to watch for a connection.
+     * The target objectName targetName to watch for a connection.
      */
-    private Set patterns = Collections.EMPTY_SET;
+    private final AbstractName targetName;
 
     /**
      * Our listener for lifecycle events
@@ -53,134 +51,68 @@
     private final LifecycleListener listener;
 
     /**
-     * Current set of targets
-     */
-    private final Set targets = new HashSet();
-
-    /**
      * The kernel to which the reference is bound.
      */
     private final Kernel kernel;
 
     /**
-     * The dependency manager of the kernel.
-     */
-    private final DependencyManager dependencyManager;
-
-    /**
-     * is this reference online
+     * Is the GBean waitng for me to start?
      */
-    private boolean isOnline = false;
+//    private boolean waitingForMe = false;
+    private boolean targetRunning = false;
+    private boolean dependencyRegistered = false;
 
-    public GBeanDependency(GBeanInstance gbeanInstance, AbstractNameQuery pattern, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
+    public GBeanDependency(GBeanInstance gbeanInstance, AbstractName targetName, Kernel kernel) throws InvalidConfigurationException {
         this.gbeanInstance = gbeanInstance;
         this.kernel = kernel;
-        this.dependencyManager = dependencyManager;
-        patterns = Collections.singleton(pattern);
+        this.targetName = targetName;
         listener = createLifecycleListener();
     }
 
-    private static final Log log = LogFactory.getLog(GBeanSingleReference.class);
-
-    /**
-     * Is the GBeanMBean waitng for me to start?
-     */
-    private boolean waitingForMe = false;
-
-    /**
-     * The object to which the proxy is bound
-     */
-    private AbstractName proxyTarget;
-
+    public final synchronized void online() {
+        AbstractNameQuery query = new AbstractNameQuery(targetName);
+        kernel.getLifecycleMonitor().addLifecycleListener(listener, query);
+        targetRunning = isRunning(kernel, targetName);
+    }
 
     public synchronized boolean start() {
-        // We only need to start if there are patterns and we don't already have a proxy
-        if (proxyTarget == null) {
-            //
-            // We must have exactally one running target
-            //
-            AbstractName abstractName = getGBeanInstance().getAbstractName();
-            Set targets = getTargets();
-            if (targets.size() == 0) {
-                waitingForMe = true;
-                log.debug("Waiting to start " + abstractName + " because no targets are running for the dependency matching the patternspatterns " + getPatternsText());
-                return false;
-            } else if (targets.size() > 1) {
-                waitingForMe = true;
-                log.debug("Waiting to start " + abstractName + " because more then one targets are running for the dependency matching the patternspatterns " + getPatternsText());
-                return false;
-            }
-            waitingForMe = false;
-
-            // stop all gbeans that would match our patterns from starting
-            DependencyManager dependencyManager = getDependencyManager();
-            dependencyManager.addStartHolds(abstractName, getPatterns());
-
-            // add a dependency on our target and create the proxy
-            AbstractName target = (AbstractName) targets.iterator().next();
-            proxyTarget = target;
-            dependencyManager.addDependency(abstractName, target);
-        }
+        if (targetRunning && !dependencyRegistered) {
+            AbstractName abstractName = gbeanInstance.getAbstractName();
+            kernel.getDependencyManager().addDependency(abstractName, targetName);
+            dependencyRegistered = true;
+        }
+        // We only need to start if there are targetName and we don't already have a proxy
+//        if (waitingForMe) {
+//            if (isRunning(kernel, targetName)) {
+//                AbstractName abstractName = gbeanInstance.getAbstractName();
+//                kernel.getDependencyManager().addDependency(abstractName, targetName);
+//                waitingForMe = false;
+//            }
+//        }
 
-        return true;
+        return targetRunning;
     }
 
-    private String getPatternsText() {
-        StringBuffer buf = new StringBuffer();
-        Set patterns = getPatterns();
-        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
-            AbstractNameQuery objectName = (AbstractNameQuery) iterator.next();
-            buf.append(objectName).append(" ");
-        }
-        return buf.toString();
-    }
 
     public synchronized void stop() {
-        waitingForMe = false;
-        AbstractName abstractName = getGBeanInstance().getAbstractName();
-        Set patterns = getPatterns();
-        DependencyManager dependencyManager = getDependencyManager();
-        if (!patterns.isEmpty()) {
-            dependencyManager.removeStartHolds(abstractName, patterns);
-        }
-
-        if (proxyTarget != null) {
-            dependencyManager.removeDependency(abstractName, proxyTarget);
-            proxyTarget = null;
-        }
+        if (dependencyRegistered) {
+            AbstractName abstractName = gbeanInstance.getAbstractName();
+            kernel.getDependencyManager().removeDependency(abstractName, targetName);
+            dependencyRegistered = false;
+        }
+//        waitingForMe = true;
+//        AbstractName abstractName = gbeanInstance.getAbstractName();
+//
+//            kernel.getDependencyManager().removeDependency(abstractName, targetName);
     }
 
-    protected synchronized void targetAdded(AbstractName target) {
-        // if we are running, and we now have two valid targets, which is an illegal state so we need to fail
-        GBeanInstance gbeanInstance = getGBeanInstance();
-        if (gbeanInstance.getStateInstance() == State.RUNNING) {
-            log.error("Illegal state: two or more targets are not running for a signle valued reference: " + getDescription() +
-                    ", currentTarget=" + proxyTarget +
-                    ", newTarget=" + target);
-            gbeanInstance.referenceFailed();
-        } else if (waitingForMe) {
-            Set targets = getTargets();
-            if (targets.size() == 1) {
-                // the gbean was waiting for me and not there is now just one target
-                attemptFullStart();
-            }
-        }
-    }
+    public final synchronized void offline() {
+        // make sure we are stopped
+        stop();
 
-    protected synchronized void targetRemoved(AbstractName target) {
-        GBeanInstance gbeanInstance = getGBeanInstance();
-        if (gbeanInstance.getStateInstance() == State.RUNNING) {
-            // we no longer have a valid target, which is an illegal state so we need to fail
-            log.error("Illegal state: current target for a signle valued reference stopped: " + getDescription() +
-                    ", currentTarget=" + target);
-            gbeanInstance.referenceFailed();
-        } else if (waitingForMe) {
-            Set targets = getTargets();
-            if (targets.size() == 1) {
-                // the gbean was waiting for me and not there is now just one target
-                attemptFullStart();
-            }
-        }
+        kernel.getLifecycleMonitor().removeLifecycleListener(listener);
+        targetRunning = false;
+//        waitingForMe = true;
     }
 
     private synchronized void attemptFullStart() {
@@ -188,111 +120,60 @@
             // there could be an issue with really badly written components holding up a stop when the
             // component never reached the starting phase... then a target registers and we automatically
             // attempt to restart
-            waitingForMe = false;
-            getGBeanInstance().start();
+//            waitingForMe = false;
+            gbeanInstance.start();
         } catch (Exception e) {
-            log.warn("Exception occured while attempting to fully start: objectName=" + getGBeanInstance().getObjectName(), e);
+            log.warn("Exception occured while attempting to fully start: objectName=" + gbeanInstance.getObjectName(), e);
         }
     }
 
     protected LifecycleListener createLifecycleListener() {
         return new LifecycleAdapter() {
-                    public void running(AbstractName abstractName) {
-                        addTarget(abstractName);
-                    }
-
-                    public void stopped(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-
-                    public void failed(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-
-                    public void unloaded(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-                };
-    }
-
-    protected final Kernel getKernel() {
-        return kernel;
-    }
-
-    protected final DependencyManager getDependencyManager() {
-        return dependencyManager;
-    }
-
-    public final GBeanInstance getGBeanInstance() {
-        return gbeanInstance;
-    }
-
-    public final Set getPatterns() {
-        return patterns;
-    }
-
-    public final void setPatterns(Set patterns) {
-        if (isOnline) {
-            throw new IllegalStateException("Pattern set can not be modified while online");
-        }
-
-        if (patterns == null || patterns.isEmpty() || (patterns.size() == 1 && patterns.iterator().next() == null)) {
-            this.patterns = Collections.EMPTY_SET;
-        } else {
-            patterns = new HashSet(patterns);
-            for (Iterator iterator = this.patterns.iterator(); iterator.hasNext();) {
-                if (iterator.next() == null) {
-                    iterator.remove();
-                    //there can be at most one null value in a set.
-                    break;
-                }
+            public void running(AbstractName abstractName) {
+                addTarget(abstractName);
             }
-            this.patterns = Collections.unmodifiableSet(patterns);
-        }
-    }
 
-    public final synchronized void online() {
-        Set gbeans = kernel.listGBeans(patterns);
-        for (Iterator objectNameIterator = gbeans.iterator(); objectNameIterator.hasNext();) {
-            AbstractName target = (AbstractName) objectNameIterator.next();
-            if (!targets.contains(target)) {
-
-                // if the bean is running add it to the runningTargets list
-                if (isRunning(kernel, target)) {
-                    targets.add(target);
-                }
+            public void stopped(AbstractName abstractName) {
+                removeTarget(abstractName);
             }
-        }
-
-        kernel.getLifecycleMonitor().addLifecycleListener(listener, patterns);
-        isOnline = true;
-    }
 
-    public final synchronized void offline() {
-        // make sure we are stoped
-        stop();
-
-        kernel.getLifecycleMonitor().removeLifecycleListener(listener);
-
-        targets.clear();
-        isOnline = false;
-    }
+            public void failed(AbstractName abstractName) {
+                removeTarget(abstractName);
+            }
 
-    protected final Set getTargets() {
-        return targets;
+            public void unloaded(AbstractName abstractName) {
+                removeTarget(abstractName);
+            }
+        };
     }
 
     protected final void addTarget(AbstractName abstractName) {
-        if (!targets.contains(abstractName)) {
-            targets.add(abstractName);
-            targetAdded(abstractName);
+        // if we are running, and we now have two valid targets, which is an illegal state so we need to fail
+        synchronized (this) {
+            targetRunning = true;
+            GBeanInstance gbeanInstance1 = gbeanInstance;
+            if (gbeanInstance1.getStateInstance() == State.RUNNING) {
+                log.error("Illegal state: two or more targets are running for a single valued reference: " + getDescription() +
+                        ", currentTarget=" + targetName +
+                        ", newTarget=" + abstractName);
+//                gbeanInstance1.referenceFailed();
+            } //else if (waitingForMe) {
+                // the gbean was waiting for me and not there is now just one target
+                attemptFullStart();
+//            }
         }
     }
 
     protected final void removeTarget(AbstractName abstractName) {
-        boolean wasTarget = targets.remove(abstractName);
-        if (wasTarget) {
-            targetRemoved(abstractName);
+        synchronized (this) {
+            targetRunning = false;
+            GBeanInstance gbeanInstance1 = gbeanInstance;
+            if (gbeanInstance1.getStateInstance() == State.RUNNING) {
+                // we no longer have a valid target, which is an illegal state so we need to fail
+                log.error("Illegal state: current target for a single valued reference stopped: " + getDescription() +
+                        ", currentTarget=" + abstractName);
+                gbeanInstance1.referenceFailed();
+            }
         }
     }
 
@@ -308,16 +189,35 @@
             final int state = kernel.getGBeanState(objectName);
             return state == State.RUNNING_INDEX;
         } catch (GBeanNotFoundException e) {
-            // mbean is no longer registerd
+            // gbean is no longer registerd
             return false;
         } catch (Exception e) {
-            // problem getting the attribute, mbean has most likely failed
+            // problem getting the attribute, gbean has most likely failed
             return false;
         }
     }
 
     protected final String getDescription() {
         return "\n    GBeanInstance: " + gbeanInstance.getName() +
-                "\n    Pattern Name: " + getPatterns();
+                "\n    Pattern Name: " + targetName;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final GBeanDependency that = (GBeanDependency) o;
+
+        if (gbeanInstance != null ? !gbeanInstance.equals(that.gbeanInstance) : that.gbeanInstance != null)
+            return false;
+        return !(targetName != null ? !targetName.equals(that.targetName) : that.targetName != null);
+
+    }
+
+    public int hashCode() {
+        int result;
+        result = (gbeanInstance != null ? gbeanInstance.hashCode() : 0);
+        result = 29 * result + (targetName != null ? targetName.hashCode() : 0);
+        return result;
     }
 }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java Tue Mar  7 23:30:08 2006
@@ -55,7 +55,9 @@
     private static final int RUNNING = 2;
     private static final int DESTROYING = 3;
 
-    /** Attribute name used to retrieve the RawInvoker for the GBean */
+    /**
+     * Attribute name used to retrieve the RawInvoker for the GBean
+     */
     public static final String RAW_INVOKER = "$$RAW_INVOKER$$";
 
     /**
@@ -189,10 +191,11 @@
     /**
      * Construct a GBeanMBean using the supplied GBeanData and class loader
      *
-     * @param gbeanData the data for the new GBean including GBeanInfo, intial attribute values, and reference patterns
+     * @param gbeanData   the data for the new GBean including GBeanInfo, intial attribute values, and reference patterns
      * @param classLoader the class loader used to load the gbean instance and attribute/reference types
-     * @throws org.apache.geronimo.gbean.InvalidConfigurationException if the gbeanInfo is inconsistent with the actual java classes, such as
-     * mismatched attribute types or the intial data cannot be set
+     * @throws org.apache.geronimo.gbean.InvalidConfigurationException
+     *          if the gbeanInfo is inconsistent with the actual java classes, such as
+     *          mismatched attribute types or the intial data cannot be set
      */
     public GBeanInstance(GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException {
         this.abstractName = gbeanData.getAbstractName();
@@ -205,7 +208,7 @@
         try {
             type = classLoader.loadClass(gbeanInfo.getClassName());
         } catch (ClassNotFoundException e) {
-            throw new InvalidConfigurationException("Could not load GBeanInfo class from classloader: " + classLoader + 
+            throw new InvalidConfigurationException("Could not load GBeanInfo class from classloader: " + classLoader +
                     " className=" + gbeanInfo.getClassName());
         }
 
@@ -231,27 +234,40 @@
 
         // references
         Set referencesSet = new HashSet();
+        Set dependencySet = new HashSet();
+        // add the references
+        Map dataReferences = gbeanData.getReferences();
         for (Iterator iterator = gbeanInfo.getReferences().iterator(); iterator.hasNext();) {
             GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next();
+            String referenceName = referenceInfo.getName();
+            ReferencePatterns referencePatterns = (ReferencePatterns) dataReferences.remove(referenceName);
             if (referenceInfo.getProxyType().equals(Collection.class.getName())) {
-                referencesSet.add(new GBeanCollectionReference(this, referenceInfo, kernel, dependencyManager));
+                referencesSet.add(new GBeanCollectionReference(this, referenceInfo, kernel, referencePatterns));
+
             } else {
-                referencesSet.add(new GBeanSingleReference(this, referenceInfo, kernel, dependencyManager));
+                referencesSet.add(new GBeanSingleReference(this, referenceInfo, kernel, referencePatterns));
+                if (referencePatterns != null) {
+                    dependencySet.add(new GBeanDependency(this, referencePatterns.getAbstractName(), kernel));
+                }
             }
         }
-        references = (GBeanReference[]) referencesSet.toArray(new GBeanReference[gbeanInfo.getReferences().size()]);
+        if (!dataReferences.isEmpty()) {
+            throw new IllegalStateException("Attempting to set unknown references: " + dataReferences.keySet());
+        }
+
+        references = (GBeanReference[]) referencesSet.toArray(new GBeanReference[referencesSet.size()]);
         for (int i = 0; i < references.length; i++) {
             referenceIndex.put(references[i].getName(), new Integer(i));
         }
 
-        dependencies = new GBeanDependency[gbeanData.getDependencies().size()];
-        int j = 0;
+        //dependencies
         for (Iterator iterator = gbeanData.getDependencies().iterator(); iterator.hasNext();) {
-            AbstractNameQuery dependencyName = (AbstractNameQuery) iterator.next();
-            GBeanDependency dependency = new GBeanDependency(this, dependencyName, kernel, dependencyManager);
-            dependencies[j++] = dependency;
+            AbstractName dependencyName = (AbstractName) iterator.next();
+            dependencySet.add(new GBeanDependency(this, dependencyName, kernel));
         }
 
+        dependencies = (GBeanDependency[]) dependencySet.toArray(new GBeanDependency[dependencySet.size()]);
+
         // framework operations -- all framework operations have currently been removed
 
         // operations
@@ -332,32 +348,24 @@
                 String attributeName = (String) entry.getKey();
                 Object attributeValue = entry.getValue();
                 if ("gbeanEnabled".equals(attributeName)) {
-                    enabled = ((Boolean)attributeValue).booleanValue();
+                    enabled = ((Boolean) attributeValue).booleanValue();
                 } else {
-                    if(entry.getValue() != null) {
+                    if (entry.getValue() != null) {
                         setAttribute(attributeName, attributeValue, false);
                     }
                 }
             }
 
-            // add the references
-            Map dataReferences = gbeanData.getReferences();
-            for (Iterator iterator = dataReferences.entrySet().iterator(); iterator.hasNext();) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String referenceName = (String) entry.getKey();
-                Set referencePattern = (Set) entry.getValue();
-                getReferenceByName(referenceName).setPatterns(referencePattern);
-            }
         } catch (Exception e) {
             throw new InvalidConfigurationException("Could not inject configuration data into the GBean " + abstractName, e);
         }
 
-        for (int i = 0; i < references.length; i++) {
-            references[i].online();
-        }
         for (int i = 0; i < dependencies.length; i++) {
             dependencies[i].online();
         }
+        for (int i = 0; i < references.length; i++) {
+            references[i].online();
+        }
         lifecycleBroadcaster.fireLoadedEvent();
     }
 
@@ -388,7 +396,7 @@
         // tell everyone we are done
         lifecycleBroadcaster.fireUnloadedEvent();
 
-        if(manageableStore != null) {
+        if (manageableStore != null) {
             kernel.getProxyManager().destroyProxy(manageableStore);
             manageableStore = null;
         }
@@ -595,12 +603,13 @@
         }
 
         // add the references
-        for (int i = 0; i < references.length; i++) {
-            GBeanReference reference = references[i];
-            String name = reference.getName();
-            Set patterns = reference.getPatterns();
-            gbeanData.setReferencePatterns(name, patterns);
-        }
+        //TODO is it possible to extract the references?
+//        for (int i = 0; i < references.length; i++) {
+//            GBeanReference reference = references[i];
+//            String name = reference.getName();
+//            Set patterns = reference.getPatterns();
+//            gbeanData.setReferencePatterns(name, patterns);
+//        }
         //TODO copy the dependencies??
         return gbeanData;
     }
@@ -611,7 +620,7 @@
      *
      * @param index the index of the attribute
      * @return the attribute value
-     * @throws Exception if a target instance throws and exception
+     * @throws Exception                 if a target instance throws and exception
      * @throws IndexOutOfBoundsException if the index is invalid
      */
     public Object getAttribute(int index) throws Exception {
@@ -628,10 +637,10 @@
         if (state != DESTROYED || attribute.isFramework()) {
             return attribute.getValue(instance);
         } else {
-            if(attribute.isPersistent()) {
+            if (attribute.isPersistent()) {
                 return attribute.getPersistentValue();
             } else {
-                throw new IllegalStateException("Cannot retrieve the value for non-persistent attribute "+attribute.getName()+" when GBeanInstance is DESTROYED");
+                throw new IllegalStateException("Cannot retrieve the value for non-persistent attribute " + attribute.getName() + " when GBeanInstance is DESTROYED");
             }
         }
     }
@@ -642,7 +651,7 @@
      *
      * @param attributeName the name of the attribute to retrieve
      * @return the attribute value
-     * @throws Exception if a problem occurs while getting the value
+     * @throws Exception                if a problem occurs while getting the value
      * @throws NoSuchAttributeException if the attribute name is not found in the map
      */
     public Object getAttribute(String attributeName) throws NoSuchAttributeException, Exception {
@@ -667,10 +676,10 @@
         if (state != DESTROYED || attribute.isFramework()) {
             return attribute.getValue(instance);
         } else {
-            if(attribute.isPersistent()) {
+            if (attribute.isPersistent()) {
                 return attribute.getPersistentValue();
             } else {
-                throw new IllegalStateException("Cannot retrieve the value for non-persistent attribute "+attributeName+" when GBeanInstance is DESTROYED");
+                throw new IllegalStateException("Cannot retrieve the value for non-persistent attribute " + attributeName + " when GBeanInstance is DESTROYED");
             }
         }
     }
@@ -681,7 +690,7 @@
      *
      * @param index the index of the attribute
      * @param value the new value of attribute value
-     * @throws Exception if a target instance throws and exception
+     * @throws Exception                 if a target instance throws and exception
      * @throws IndexOutOfBoundsException if the index is invalid
      */
     public void setAttribute(int index, Object value) throws Exception, IndexOutOfBoundsException {
@@ -704,7 +713,7 @@
         } else {
             attribute.setPersistentValue(value);
         }
-        if(manage && attribute.isManageable()) {
+        if (manage && attribute.isManageable()) {
             updateManageableAttribute(attribute, value);
         }
     }
@@ -714,8 +723,8 @@
      * first be looked up in a HashMap.
      *
      * @param attributeName the name of the attribute to retrieve
-     * @param value the new attribute value
-     * @throws Exception if a target instance throws and exception
+     * @param value         the new attribute value
+     * @throws Exception                if a target instance throws and exception
      * @throws NoSuchAttributeException if the attribute name is not found in the map
      */
     public void setAttribute(String attributeName, Object value) throws Exception, NoSuchAttributeException {
@@ -738,33 +747,33 @@
         } else {
             attribute.setPersistentValue(value);
         }
-        if(manage && attribute.isManageable()) {
+        if (manage && attribute.isManageable()) {
             updateManageableAttribute(attribute, value);
         }
     }
 
     private void updateManageableAttribute(GBeanAttribute attribute, Object value) {
-        if(manageableStore == null) {
+        if (manageableStore == null) {
             Set set = kernel.listGBeans(new GBeanQuery(null, ManageableAttributeStore.class.getName()));
-            if(set.size() == 0) {
+            if (set.size() == 0) {
                 return;
             }
             manageableStore = (ManageableAttributeStore) kernel.getProxyManager().createProxy((ObjectName) set.iterator().next(),
-                                                                                              ManageableAttributeStore.class);
+                    ManageableAttributeStore.class);
         }
         String configName = null;
         Set set = kernel.getDependencyManager().getParents(abstractName);
         for (Iterator iterator = set.iterator(); iterator.hasNext();) {
             ObjectName name = (ObjectName) iterator.next();
-            if(Configuration.isConfigurationObjectName(name)) {
+            if (Configuration.isConfigurationObjectName(name)) {
                 configName = ObjectName.unquote(name.getKeyProperty("name"));
                 break;
             }
         }
-        if(configName != null) {
+        if (configName != null) {
             manageableStore.setValue(configName, abstractName.getObjectName(), attribute.getAttributeInfo(), value);
         } else {
-            log.error("Unable to identify Configuration for GBean "+abstractName.getObjectName()+".  Manageable attribute "+attribute.getName()+" was not updated in persistent store.");
+            log.error("Unable to identify Configuration for GBean " + abstractName.getObjectName() + ".  Manageable attribute " + attribute.getName() + " was not updated in persistent store.");
         }
     }
 
@@ -773,20 +782,19 @@
         if (index == null) {
             throw new NoSuchAttributeException("Unknown attribute " + name + " in gbean " + abstractName.getObjectName());
         }
-        GBeanAttribute attribute = attributes[index.intValue()];
-        return attribute;
+        return attributes[index.intValue()];
     }
 
     /**
      * Invokes an opreation using the operation index.  This is the most efficient way to invoke
      * an operation as it avoids a HashMap lookup.
      *
-     * @param index the index of the attribute
+     * @param index     the index of the attribute
      * @param arguments the arguments to the operation
      * @return the result of the operation
-     * @throws Exception if a target instance throws and exception
+     * @throws Exception                 if a target instance throws and exception
      * @throws IndexOutOfBoundsException if the index is invalid
-     * @throws IllegalStateException if the gbean instance has been destroyed
+     * @throws IllegalStateException     if the gbean instance has been destroyed
      */
     public Object invoke(int index, Object[] arguments) throws Exception {
         GBeanOperation operation = operations[index];
@@ -811,12 +819,12 @@
      * GOperationSignature object.
      *
      * @param operationName the name of the operation to invoke
-     * @param arguments arguments to the operation
-     * @param types types of the operation arguemtns
+     * @param arguments     arguments to the operation
+     * @param types         types of the operation arguemtns
      * @return the result of the operation
-     * @throws Exception if a target instance throws and exception
+     * @throws Exception                if a target instance throws and exception
      * @throws NoSuchOperationException if the operation signature is not found in the map
-     * @throws IllegalStateException if the gbean instance has been destroyed
+     * @throws IllegalStateException    if the gbean instance has been destroyed
      */
     public Object invoke(String operationName, Object[] arguments, String[] types) throws Exception, NoSuchOperationException {
         GOperationSignature signature = new GOperationSignature(operationName, types);
@@ -845,8 +853,7 @@
         if (index == null) {
             throw new IllegalArgumentException("Unknown reference " + name);
         }
-        GBeanReference reference = references[index.intValue()];
-        return reference;
+        return references[index.intValue()];
     }
 
     boolean createInstance() throws Exception {
@@ -864,12 +871,12 @@
 
             // Call all start on every reference.  This way the dependecies are held until we can start
             boolean allStarted = true;
-            for (int i = 0; i < references.length; i++) {
-                allStarted = references[i].start() && allStarted;
-            }
             for (int i = 0; i < dependencies.length; i++) {
                 allStarted = dependencies[i].start() && allStarted;
             }
+            for (int i = 0; i < references.length; i++) {
+                allStarted = references[i].start() && allStarted;
+            }
             if (!allStarted) {
                 return false;
             }
@@ -1044,7 +1051,7 @@
                     GBeanAttribute attribute = attributes[i];
                     if (attribute.isPersistent() && attribute.isReadable()) {
                         // copy the current attribute value to the persistent value
-                        Object value = null;
+                        Object value;
                         try {
                             value = attribute.getValue(instance);
                         } catch (Throwable e) {
@@ -1179,7 +1186,7 @@
     public boolean equals(Object obj) {
         if (obj == this) return true;
         if (obj instanceof GBeanInstance == false) return false;
-        return abstractName.equals(((GBeanInstance)obj).abstractName);
+        return abstractName.equals(((GBeanInstance) obj).abstractName);
     }
 
     public int hashCode() {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/gbean/runtime/GBeanInstanceState.java Tue Mar  7 23:30:08 2006
@@ -16,20 +16,17 @@
  */
 package org.apache.geronimo.gbean.runtime;
 
-import java.util.Iterator;
-import java.util.Set;
-import javax.management.ObjectName;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
-import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
+
+import javax.management.ObjectName;
+import java.util.Iterator;
+import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -62,12 +59,6 @@
      */
     private final LifecycleBroadcaster lifecycleBroadcaster;
 
-    /**
-     * The listener for the of the object blocking the start of this gbean.
-     * When the blocker dies we attempt to start.
-     */
-    private LifecycleListener blockerListener;
-
     // This must be volatile otherwise getState must be synchronized which will result in deadlock as dependent
     // objects check if each other are in one state or another (i.e., classic A calls B while B calls A)
     private volatile State state = State.STOPPED;
@@ -244,53 +235,6 @@
         synchronized (this) {
             // if we are still trying to start and can start now... start
             if (getStateInstance() != State.STARTING) {
-                return;
-            }
-
-            if (blockerListener != null) {
-                log.trace("Cannot run because gbean is still being blocked");
-                return;
-            }
-
-            // check if an gbean is blocking us from starting
-            final AbstractName blocker = dependencyManager.checkBlocker(abstractName);
-            if (blocker != null) {
-                blockerListener = new LifecycleAdapter() {
-
-                    public void stopped(AbstractName abstractName) {
-                        checkBlocker(abstractName);
-                    }
-
-                    public void failed(AbstractName abstractName) {
-                        checkBlocker(abstractName);
-                    }
-
-                    public void unloaded(AbstractName abstractName) {
-                        checkBlocker(abstractName);
-                    }
-
-                    private void checkBlocker(AbstractName abstractName) {
-                        synchronized (GBeanInstanceState.this) {
-                            if (!abstractName.equals(blocker)) {
-                                // it did not start so just exit this method
-                                return;
-                            }
-
-                            // it started, so remove the blocker and attempt a full start
-                            kernel.getLifecycleMonitor().removeLifecycleListener(this);
-                            GBeanInstanceState.this.blockerListener = null;
-                        }
-
-                        try {
-                            attemptFullStart();
-                        } catch (Exception e) {
-                            log.warn("A problem occured while attempting to start", e);
-                        }
-                    }
-                };
-                // register the listener and return
-                AbstractNameQuery blockerPattern = new AbstractNameQuery(blocker.getArtifact(), blocker.getName(), blocker.getInterfaceTypes());
-                kernel.getLifecycleMonitor().addLifecycleListener(blockerListener, blockerPattern);
                 return;
             }
 

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=384141&r1=384140&r2=384141&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 Tue Mar  7 23:30:08 2006
@@ -32,10 +32,6 @@
 
     Class getProxyType();
 
-    Set getPatterns();
-
-    void setPatterns(Set patterns);
-
     void online();
 
     void offline();

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=384141&r1=384140&r2=384141&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 Tue Mar  7 23:30:08 2006
@@ -21,16 +21,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GReferenceInfo;
-import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
-import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
-import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
-import org.apache.geronimo.kernel.management.State;
-
-import java.util.Iterator;
-import java.util.Set;
 
 /**
  * @version $Rev$ $Date$
@@ -39,142 +32,46 @@
     private static final Log log = LogFactory.getLog(GBeanSingleReference.class);
 
     /**
-     * Is the GBeanMBean waitng for me to start?
-     */
-    private boolean waitingForMe = false;
-
-    /**
      * The object to which the proxy is bound
      */
-    private AbstractName proxyTarget;
+    private final AbstractName proxyTarget;
+
+    public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, ReferencePatterns referencePatterns) throws InvalidConfigurationException {
+        super(gbeanInstance, referenceInfo, kernel, referencePatterns != null && referencePatterns.getAbstractName() != null);
+        proxyTarget = referencePatterns != null? referencePatterns.getAbstractName(): null;
+    }
+
+    public final synchronized void online() {
+    }
 
-    public GBeanSingleReference(GBeanInstance gbeanInstance, GReferenceInfo referenceInfo, Kernel kernel, DependencyManager dependencyManager) throws InvalidConfigurationException {
-        super(gbeanInstance, referenceInfo, kernel, dependencyManager);
+    public final synchronized void offline() {
+        stop();
     }
 
+
     public synchronized boolean start() {
         // We only need to start if there are patterns and we don't already have a proxy
-        if (!getPatterns().isEmpty() && getProxy() == null) {
-            //
-            // We must have exactly one running target
-            //
+        if (proxyTarget != null) {
             AbstractName abstractName = getGBeanInstance().getAbstractName();
-            Set targets = getTargets();
-            if (targets.size() == 0) {
-                waitingForMe = true;
-                log.debug("Waiting to start " + abstractName + " because no targets are running for reference " + getName() +" matching the patterns " + getPatternsText());
-                return false;
-            } else if (targets.size() > 1) {
-                waitingForMe = true;
-                log.debug("Waiting to start " + abstractName + " because more then one targets are running for the single valued reference " + getName() +" matching the patterns " + getPatternsText());
+            if (!isRunning(getKernel(), proxyTarget)) {
+                log.debug("Waiting to start " + abstractName + " because no targets are running for reference " + getName() +" matching the patterns " + proxyTarget);
                 return false;
             }
-            waitingForMe = false;
-
-            // stop all gbeans that would match our patterns from starting
-            DependencyManager dependencyManager = getDependencyManager();
-            dependencyManager.addStartHolds(abstractName, getPatterns());
-
-            // add a dependency on our target and create the proxy
-            AbstractName target = (AbstractName) targets.iterator().next();
-            setProxy(getKernel().getProxyManager().createProxy(target, getReferenceType()));
-            proxyTarget = target;
-            dependencyManager.addDependency(abstractName, target);
+            if (getProxy() == null) {
+                setProxy(getKernel().getProxyManager().createProxy(proxyTarget, getReferenceType()));
+            }
         }
 
         return true;
     }
 
-    private String getPatternsText() {
-        StringBuffer buf = new StringBuffer();
-        Set patterns = getPatterns();
-        for (Iterator iterator = patterns.iterator(); iterator.hasNext();) {
-            AbstractNameQuery refInfo = (AbstractNameQuery) iterator.next();
-            buf.append(refInfo).append(" ");
-        }
-        return buf.toString();
-    }
-
     public synchronized void stop() {
-        waitingForMe = false;
-        AbstractName abstractName = getGBeanInstance().getAbstractName();
-        Set patterns = getPatterns();
-        DependencyManager dependencyManager = getDependencyManager();
-        if (!patterns.isEmpty()) {
-            dependencyManager.removeStartHolds(abstractName, patterns);
-        }
-
         Object proxy = getProxy();
         if (proxy != null) {
-            dependencyManager.removeDependency(abstractName, proxyTarget);
             getKernel().getProxyManager().destroyProxy(proxy);
             setProxy(null);
-            proxyTarget = null;
-        }
-    }
-
-    protected synchronized void targetAdded(AbstractName target) {
-        // if we are running, and we now have two valid targets, which is an illegal state so we need to fail
-        GBeanInstance gbeanInstance = getGBeanInstance();
-        if (gbeanInstance.getStateInstance() == State.RUNNING) {
-            log.error("Illegal state: two or more targets are not running for a single valued reference: " + getDescription() +
-                    ", currentTarget=" + proxyTarget +
-                    ", newTarget=" + target);
-            gbeanInstance.referenceFailed();
-        } else if (waitingForMe) {
-            Set targets = getTargets();
-            if (targets.size() == 1) {
-                // the gbean was waiting for me and not there is now just one target
-                attemptFullStart();
-            }
         }
     }
 
-    protected synchronized void targetRemoved(AbstractName target) {
-        GBeanInstance gbeanInstance = getGBeanInstance();
-        if (gbeanInstance.getStateInstance() == State.RUNNING) {
-            // we no longer have a valid target, which is an illegal state so we need to fail
-            log.error("Illegal state: current target for a single valued reference stopped: " + getDescription() +
-                    ", currentTarget=" + target);
-            gbeanInstance.referenceFailed();
-        } else if (waitingForMe) {
-            Set targets = getTargets();
-            if (targets.size() == 1) {
-                // the gbean was waiting for me and not there is now just one target
-                attemptFullStart();
-            }
-        }
-    }
 
-    private synchronized void attemptFullStart() {
-        try {
-            // there could be an issue with really badly written components holding up a stop when the
-            // component never reached the starting phase... then a target registers and we automatically
-            // attempt to restart
-            waitingForMe = false;
-            getGBeanInstance().start();
-        } catch (Exception e) {
-            log.warn("Exception occured while attempting to fully start: objectName=" + getGBeanInstance().getObjectName(), e);
-        }
-    }
-
-    protected LifecycleListener createLifecycleListener() {
-        return new LifecycleAdapter() {
-                    public void running(AbstractName abstractName) {
-                        addTarget(abstractName);
-                    }
-
-                    public void stopped(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-
-                    public void failed(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-
-                    public void unloaded(AbstractName abstractName) {
-                        removeTarget(abstractName);
-                    }
-                };
-    }
 }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/DependencyManager.java Tue Mar  7 23:30:08 2006
@@ -19,9 +19,7 @@
 
 import org.apache.geronimo.gbean.AbstractName;
 
-import java.util.Collection;
 import java.util.Set;
-import javax.management.ObjectName;
 
 /**
  * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
@@ -86,35 +84,4 @@
      */
     public Set getChildren(AbstractName 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 abstractName
-     * @param holds a collection of object name patterns which should not start
-     */
-    public void addStartHolds(AbstractName abstractName, Collection holds);
-
-    /**
-     * Removes a collection of holds.
-     *
-     * @param abstractName
-     * @param holds a collection of the holds to remove
-     */
-    public void removeStartHolds(AbstractName abstractName, Collection holds);
-
-    /**
-     * Removes all of the holds owned by a component.
-     *
-     * @param abstractName
-     */
-    public void removeAllStartHolds(AbstractName abstractName);
-
-    /**
-     * Gets the object name of the bean blocking the start specified bean.
-     *
-     * @param abstractName
-     * @return the bean blocking the specified bean, or null if there are no blockers
-     */
-    public AbstractName checkBlocker(AbstractName abstractName);
 }

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/BasicDependencyManager.java Tue Mar  7 23:30:08 2006
@@ -17,23 +17,20 @@
 
 package org.apache.geronimo.kernel.basic;
 
-import java.util.Collection;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
+import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
+import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
+
+import javax.management.ObjectName;
 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.ObjectName;
-
-import org.apache.geronimo.kernel.lifecycle.LifecycleAdapter;
-import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
-import org.apache.geronimo.kernel.lifecycle.LifecycleMonitor;
-import org.apache.geronimo.kernel.DependencyManager;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.AbstractNameQuery;
 
 /**
  * DependencyManager is the record keeper of the dependencies in Geronimo.  The DependencyManager
@@ -69,12 +66,6 @@
      */
     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 BasicDependencyManager(LifecycleMonitor lifecycleMonitor) throws Exception {
         assert lifecycleMonitor != null;
         this.lifecycleMonitor = lifecycleMonitor;
@@ -85,7 +76,6 @@
         lifecycleMonitor.removeLifecycleListener(lifecycleListener);
         childToParentMap.clear();
         parentToChildMap.clear();
-        startHoldsMap.clear();
     }
 
     /**
@@ -202,71 +192,11 @@
         return new HashSet(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 abstractName
-     * @param holds a collection of object name patterns which should not start
-     */
-    public synchronized void addStartHolds(AbstractName abstractName, Collection holds) {
-        Collection currentHolds = (Collection) startHoldsMap.get(abstractName);
-        if (currentHolds == null) {
-            currentHolds = new LinkedList(holds);
-            startHoldsMap.put(abstractName, currentHolds);
-        } else {
-            currentHolds.addAll(holds);
-        }
-    }
-
-    /**
-     * Removes a collection of holds.
-     *
-     * @param abstractName
-     * @param holds a collection of the holds to remove
-     */
-    public synchronized void removeStartHolds(AbstractName abstractName, Collection holds) {
-        Collection currentHolds = (Collection) startHoldsMap.get(abstractName);
-        if (currentHolds != null) {
-            currentHolds.removeAll(holds);
-        }
-    }
-
-    /**
-     * Removes all of the holds owned by a component.
-     *
-     * @param abstractName
-     */
-    public synchronized void removeAllStartHolds(AbstractName abstractName) {
-        startHoldsMap.remove(abstractName);
-    }
-
-    /**
-     * Gets the object name of the mbean blocking the start specified mbean.
-     *
-     * @param abstractName
-     * @return the mbean blocking the specified mbean, or null if there are no blockers
-     */
-    public synchronized AbstractName checkBlocker(AbstractName abstractName) {
-        // check if objectName name is on one of the hold lists
-        for (Iterator iterator = startHoldsMap.keySet().iterator(); iterator.hasNext();) {
-            AbstractName blocker = (AbstractName) iterator.next();
-            List holds = (List) startHoldsMap.get(blocker);
-            for (Iterator holdsIterator = holds.iterator(); holdsIterator.hasNext();) {
-                AbstractNameQuery pattern = (AbstractNameQuery) holdsIterator.next();
-                if (pattern.matches(abstractName)) {
-                    return blocker;
-                }
-            }
-        }
-        return null;
-    }
 
     private class DependencyManagerLifecycleListener extends LifecycleAdapter {
         public void unloaded(AbstractName abstractName) {
             synchronized (BasicDependencyManager.this) {
                 removeAllDependencies(abstractName);
-                removeAllStartHolds(abstractName);
             }
 
         }

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=384141&r1=384140&r2=384141&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 Tue Mar  7 23:30:08 2006
@@ -228,8 +228,8 @@
     }
 
     public void loadGBean(GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException {
-        AbstractName objectName = gbeanData.getAbstractName();
-        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleMonitor.createLifecycleBroadcaster(objectName), classLoader);
+        AbstractName abstractName = gbeanData.getAbstractName();
+        GBeanInstance gbeanInstance = new GBeanInstance(gbeanData, this, dependencyManager, lifecycleMonitor.createLifecycleBroadcaster(abstractName), classLoader);
         registry.register(gbeanInstance);
     }
 

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/basic/LifecycleMonitorFlyweight.java Tue Mar  7 23:30:08 2006
@@ -32,7 +32,8 @@
         this.lifecycleMonitor = lifecycleMonitor;
     }
 
-    public void addLifecycleListener(LifecycleListener listener, AbstractNameQuery pattern) {
+    public void addLifecycleListener(LifecycleListener listener, AbstractNameQuery query) {
+        lifecycleMonitor.addLifecycleListener(listener, query);
     }
 
     public void addLifecycleListener(LifecycleListener listener, Set patterns) {

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=384141&r1=384140&r2=384141&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Tue Mar  7 23:30:08 2006
@@ -279,9 +279,7 @@
                     while (true) {
                         GBeanData gbeanData = new GBeanData();
                         gbeanData.readExternal(ois);
-                        gbeanData.initializeName(id, baseName);
-
-                        gbeans.put(gbeanData.getNameMap(), gbeanData);
+                        gbeans.put(gbeanData.getAbstractName(), gbeanData);
                     }
                 } catch (EOFException e) {
                     // ok
@@ -436,26 +434,13 @@
     }
 
     /**
-     * Gets an unmodifiable map of the GBeanDatas for the GBeans in this configuration by ObjectName.
+     * Gets an unmodifiable collection of the GBeanDatas for the GBeans in this configuration.
      * @return the GBeans in this configuration
      */
     public Map getGBeans() {
         return Collections.unmodifiableMap(gbeans);
     }
 
-    /**
-     * Determines of this configuration constains the specified GBean.
-     * @param gbean the name of the GBean
-     * @return true if this configuration contains the specified GBean; false otherwise
-     */
-    public synchronized boolean containsGBean(ObjectName gbean) {
-        //TODO does not work
-        if (true) {
-            throw new IllegalArgumentException("does not work");
-        }
-        return gbeans.containsKey(gbean);
-    }
-
     public synchronized void addGBean(GBeanData beanData, boolean start) throws InvalidConfigException, GBeanAlreadyExistsException {
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         try {
@@ -464,7 +449,7 @@
             log.trace("Registering GBean " + beanData.getName());
 
             // add a dependency on this configuration
-            beanData.getDependencies().add(new AbstractNameQuery(abstractName));
+            beanData.getDependencies().add(abstractName);
 
             // register the bean with the kernel
             kernel.loadGBean(beanData, configurationClassLoader);
@@ -481,25 +466,9 @@
             Thread.currentThread().setContextClassLoader(oldCl);
         }
 
-        gbeans.put(beanData.getNameMap(), beanData);
+        gbeans.put(beanData.getAbstractName(), beanData);
     }
 
-    public synchronized void removeGBean(ObjectName name) throws GBeanNotFoundException {
-        //TODO does not work
-        if (!gbeans.containsKey(name)) {
-            throw new GBeanNotFoundException(name);
-        }
-        try {
-            if (kernel.getGBeanState(name) == State.RUNNING_INDEX) {
-                kernel.stopGBean(name);
-            }
-            kernel.unloadGBean(name);
-        } catch (GBeanNotFoundException e) {
-            // Bean is no longer loaded
-        }
-
-        gbeans.remove(name);
-    }
 
     public void doStart() throws Exception {
         assert objectName != null;
@@ -538,9 +507,8 @@
 
     private void shutdown() {
         // unregister all GBeans
-        for (Iterator i = gbeans.values().iterator(); i.hasNext();) {
-            GBeanData gbeanData = (GBeanData) i.next();
-            AbstractName name = gbeanData.getAbstractName();
+        for (Iterator i = gbeans.keySet().iterator(); i.hasNext();) {
+            AbstractName name = (AbstractName) i.next();
             try {
                 if (kernel.isLoaded(name)) {
                     log.trace("Unregistering GBean " + name);



Mime
View raw message