geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r782992 - in /geronimo/sandbox/blueprint: blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ blueprint-core/src/main/java/org/apache/geronimo/bluepri...
Date Tue, 09 Jun 2009 13:11:28 GMT
Author: gnodet
Date: Tue Jun  9 13:11:27 2009
New Revision: 782992

URL: http://svn.apache.org/viewvc?rev=782992&view=rev
Log:
Fix various problems mostly with references and services

Modified:
    geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/DefaultExecutionContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PlaceholdersUtils.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PropertyPlaceholder.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableRefListMetadata.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableServiceReferenceMetadata.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/ComponentMetadataImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/RefListMetadataImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ConversionUtils.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/DynamicCollection.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ReflectionUtils.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContainer.java
    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java

Modified: geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java (original)
+++ geronimo/sandbox/blueprint/blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/CmNamespaceHandler.java Tue Jun  9 13:11:27 2009
@@ -380,11 +380,14 @@
         metadata.addProperty("configAdmin", createRef(context, CONFIG_ADMIN_REFERENCE_NAME));
         metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
         metadata.addProperty("persistentId", createValue(context, persistentId));
-        if (element.hasAttribute(UPDATE_STRATEGY_ATTRIBUTE)) {
-            metadata.addProperty("updateStrategy", createValue(context, element.getAttribute(UPDATE_STRATEGY_ATTRIBUTE)));
+        String updateStrategy = element.getAttribute(UPDATE_STRATEGY_ATTRIBUTE);
+        if (updateStrategy != null) {
+            metadata.addProperty("updateStrategy", createValue(context, updateStrategy));
         }
         if (element.hasAttribute(UPDATE_METHOD_ATTRIBUTE)) {
             metadata.addProperty("updateMethod", createValue(context, element.getAttribute(UPDATE_METHOD_ATTRIBUTE)));
+        } else if ("component-managed".equals(updateStrategy)) {
+            throw new ComponentDefinitionException(UPDATE_METHOD_ATTRIBUTE + " attribute must be set when " + UPDATE_STRATEGY_ATTRIBUTE + " is set to 'component-managed'");
         }
         metadata.addProperty("beanName", createIdRef(context, component.getId()));
         context.getComponentDefinitionRegistry().registerComponentDefinition(metadata);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java Tue Jun  9 13:11:27 2009
@@ -18,19 +18,20 @@
  */
 package org.apache.geronimo.blueprint.container;
 
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.lang.reflect.InvocationHandler;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import net.sf.cglib.proxy.Dispatcher;
 import net.sf.cglib.proxy.Enhancer;
@@ -67,6 +68,7 @@
     protected final ExtendedBlueprintContainer blueprintContainer;
     protected final ServiceReferenceMetadata metadata;
     protected final Recipe listenersRecipe;
+    protected final List<Recipe> explicitDependencies;
     protected final ClassLoader proxyClassLoader;
     protected final boolean optional;
     /** The OSGi filter for tracking references */
@@ -83,12 +85,14 @@
     protected AbstractServiceReferenceRecipe(String name,
                                              ExtendedBlueprintContainer blueprintContainer,
                                              ServiceReferenceMetadata metadata,
-                                             Recipe listenersRecipe) {
+                                             Recipe listenersRecipe,
+                                             List<Recipe> explicitDependencies) {
         super(name);
         this.prototype = false;
         this.blueprintContainer = blueprintContainer;
         this.metadata = metadata;
         this.listenersRecipe = listenersRecipe;
+        this.explicitDependencies = explicitDependencies;
         // Create a ClassLoader delegating to the bundle, but also being able to see our bundle classes
         // so that the created proxy can access cglib classes.
         this.proxyClassLoader = new BundleDelegatingClassLoader(blueprintContainer.getBundleContext().getBundle(),
@@ -125,7 +129,11 @@
         if (started.compareAndSet(true, false)) {
             synchronized (references) {
                 blueprintContainer.getBundleContext().removeServiceListener(this);
-                references.clear();
+                for (Iterator<ServiceReference> it = references.iterator(); it.hasNext();) {
+                    ServiceReference ref = it.next();
+                    it.remove();
+                    untrack(ref);
+                }
                 satisfied.set(false);
             }
         }
@@ -145,6 +153,9 @@
         if (listenersRecipe != null) {
             recipes.add(listenersRecipe);
         }
+        if (explicitDependencies != null) {
+            recipes.addAll(explicitDependencies);
+        }
         return recipes;
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/BlueprintContainerImpl.java Tue Jun  9 13:11:27 2009
@@ -70,7 +70,6 @@
 import org.osgi.service.blueprint.reflect.MapMetadata;
 import org.osgi.service.blueprint.reflect.Metadata;
 import org.osgi.service.blueprint.reflect.PropsMetadata;
-import org.osgi.service.blueprint.reflect.RefListMetadata;
 import org.osgi.service.blueprint.reflect.RefMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
@@ -246,7 +245,7 @@
                         break;
                     }
                     case Populated:
-                        instantiator = new BlueprintObjectInstantiator(this, new RecipeBuilder(this).createRepository());
+                        getInstantiator();
                         trackServiceReferences();
                         Runnable r = new Runnable() {
                             public void run() {
@@ -288,7 +287,7 @@
                     case Create:
                         timeoutFuture.cancel(false);
                         registerServices();
-                        instantiateEagerSingletonBeans();
+                        instantiateEagerComponents();
 
                         // Register the BlueprintContainer in the OSGi registry
                         if (registration == null) {
@@ -320,6 +319,13 @@
         }
     }
 
+    protected BlueprintObjectInstantiator getInstantiator() throws Exception {
+        if (instantiator == null) {
+            instantiator = new BlueprintObjectInstantiator(this, new RecipeBuilder(this).createRepository());
+        }
+        return instantiator;
+    }
+
     private void processTypeConverters() throws Exception {
         List<String> typeConverters = new ArrayList<String>();
         for (Target target : componentDefinitionRegistry.getTypeConverters()) {
@@ -437,9 +443,7 @@
     public void notifySatisfaction(SatisfiableRecipe satisfiable) {
         LOGGER.debug("Notified satisfaction {} in bundle {}: {}",
                 new Object[] { satisfiable.getName(), bundleContext.getBundle().getSymbolicName(), satisfiable.isSatisfied() });
-        if (state == State.WaitForInitialReferences) {
-            schedule();
-        } else if (state == State.Created) {
+        if (state == State.Create || state == State.Created ) {
             Map<String, List<SatisfiableRecipe>> dependencies = getSatisfiableDependenciesMap();
             for (String name : dependencies.keySet()) {
                 ComponentMetadata metadata = componentDefinitionRegistry.getComponentDefinition(name);
@@ -463,10 +467,12 @@
                     }
                 }
             }
+        } else {
+            schedule();
         }
     }
 
-    private void instantiateEagerSingletonBeans() {
+    private void instantiateEagerComponents() {
         List<String> components = new ArrayList<String>();
         for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
             ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java Tue Jun  9 13:11:27 2009
@@ -23,11 +23,11 @@
 import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.Collection;
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
@@ -74,6 +74,7 @@
 import org.osgi.service.blueprint.reflect.BeanProperty;
 import org.osgi.service.blueprint.reflect.CollectionMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
 import org.osgi.service.blueprint.reflect.Listener;
 import org.osgi.service.blueprint.reflect.MapEntry;
 import org.osgi.service.blueprint.reflect.MapMetadata;
@@ -82,14 +83,13 @@
 import org.osgi.service.blueprint.reflect.NullMetadata;
 import org.osgi.service.blueprint.reflect.PropsMetadata;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.osgi.service.blueprint.reflect.RegistrationListener;
 import org.osgi.service.blueprint.reflect.ServiceMetadata;
 import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
 import org.osgi.service.blueprint.reflect.Target;
-import org.osgi.service.blueprint.reflect.IdRefMetadata;
-import org.osgi.service.blueprint.reflect.RefMetadata;
 import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceMetadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.xml.sax.InputSource;
@@ -791,8 +791,19 @@
         if (element.hasAttribute(REF_ATTRIBUTE)) {
             listenerComponent = new RefMetadataImpl(element.getAttribute(REF_ATTRIBUTE));
         }
-        String registrationMethod = element.getAttribute(REGISTRATION_METHOD_ATTRIBUTE);
-        String unregistrationMethod = element.getAttribute(UNREGISTRATION_METHOD_ATTRIBUTE);
+        String registrationMethod = null;
+        if (element.hasAttribute(REGISTRATION_METHOD_ATTRIBUTE)) {
+            registrationMethod = element.getAttribute(REGISTRATION_METHOD_ATTRIBUTE);
+            listener.setRegistrationMethodName(registrationMethod);
+        }
+        String unregistrationMethod = null;
+        if (element.hasAttribute(UNREGISTRATION_METHOD_ATTRIBUTE)) {
+            unregistrationMethod = element.getAttribute(UNREGISTRATION_METHOD_ATTRIBUTE);
+            listener.setUnregistrationMethodName(unregistrationMethod);
+        }
+        if (registrationMethod == null && unregistrationMethod == null) {
+            throw new ComponentDefinitionException("One of " + REGISTRATION_METHOD_ATTRIBUTE + " or " + UNREGISTRATION_METHOD_ATTRIBUTE + " must be set");
+        }
         // Parse elements
         NodeList nl = element.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
@@ -837,14 +848,6 @@
             throw new ComponentDefinitionException("One of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element must be set");
         }
         listener.setListenerComponent((Target) listenerComponent);
-        if (registrationMethod == null || registrationMethod.length() == 0) {
-            throw new ComponentDefinitionException("Attribute " + REGISTRATION_METHOD_ATTRIBUTE + " must be set");
-        }
-        listener.setRegistrationMethodName(registrationMethod);
-        if (unregistrationMethod == null || unregistrationMethod.length() == 0) {
-            throw new ComponentDefinitionException("Attribute " + UNREGISTRATION_METHOD_ATTRIBUTE + " must be set");
-        }
-        listener.setUnregistrationMethodName(unregistrationMethod);
         return listener;
     }
 
@@ -959,8 +962,19 @@
         if (element.hasAttribute(REF_ATTRIBUTE)) {
             listenerComponent = new RefMetadataImpl(element.getAttribute(REF_ATTRIBUTE));
         }
-        listener.setBindMethodName(element.getAttribute(BIND_METHOD_ATTRIBUTE));
-        listener.setUnbindMethodName(element.getAttribute(UNBIND_METHOD_ATTRIBUTE));
+        String bindMethodName = null;
+        String unbindMethodName = null;
+        if (element.hasAttribute(BIND_METHOD_ATTRIBUTE)) {
+            bindMethodName = element.getAttribute(BIND_METHOD_ATTRIBUTE);
+            listener.setBindMethodName(bindMethodName);
+        }
+        if (element.hasAttribute(UNBIND_METHOD_ATTRIBUTE)) {
+            unbindMethodName = element.getAttribute(UNBIND_METHOD_ATTRIBUTE);
+            listener.setUnbindMethodName(unbindMethodName);
+        }
+        if (bindMethodName == null && unbindMethodName == null) {
+            throw new ComponentDefinitionException("One of " + BIND_METHOD_ATTRIBUTE + " or " + UNBIND_METHOD_ATTRIBUTE + " must be set");
+        }
         // Parse elements
         NodeList nl = element.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RecipeBuilder.java Tue Jun  9 13:11:27 2009
@@ -20,7 +20,6 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -121,10 +120,15 @@
                 listenersRecipe.add(createRecipe(listener));
             }
         }
+        List<Recipe> deps = new ArrayList<Recipe>();
+        for (String name : metadata.getDependsOn()) {
+            deps.add(new RefRecipe(getName(null), name));
+        }
         RefListRecipe recipe = new RefListRecipe(getName(metadata.getId()),
                                                  blueprintContainer,
                                                  metadata,
-                                                 listenersRecipe);
+                                                 listenersRecipe,
+                                                 deps);
         return recipe;
     }
 
@@ -136,10 +140,15 @@
                 listenersRecipe.add(createRecipe(listener));
             }
         }
+        List<Recipe> deps = new ArrayList<Recipe>();
+        for (String name : metadata.getDependsOn()) {
+            deps.add(new RefRecipe(getName(null), name));
+        }
         ReferenceRecipe recipe = new ReferenceRecipe(getName(metadata.getId()),
                                                      blueprintContainer,
                                                      metadata,
-                                                     listenersRecipe);
+                                                     listenersRecipe,
+                                                     deps);
         return recipe;
     }
 
@@ -226,8 +235,12 @@
     private Recipe createRecipe(RegistrationListener listener) throws Exception {
         BeanRecipe recipe = new BeanRecipe(getName(null), blueprintContainer, ServiceListener.class);
         recipe.setProperty("listener", getValue(listener.getListenerComponent(), null));
-        recipe.setProperty("registerMethod", listener.getRegistrationMethodName());
-        recipe.setProperty("unregisterMethod", listener.getUnregistrationMethodName());
+        if (listener.getRegistrationMethodName() != null) {
+            recipe.setProperty("registerMethod", listener.getRegistrationMethodName());
+        }
+        if (listener.getUnregistrationMethodName() != null) {
+            recipe.setProperty("unregisterMethod", listener.getUnregistrationMethodName());
+        }
         return recipe;
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/RefListRecipe.java Tue Jun  9 13:11:27 2009
@@ -24,12 +24,10 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.RandomAccess;
-import java.util.Set;
 import java.util.concurrent.Callable;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
@@ -58,28 +56,32 @@
 
     private final RefListMetadata metadata;
     private final List<ManagedCollection> collections = new ArrayList<ManagedCollection>();
-    private DynamicCollection<ServiceDispatcher> storage;
+    private final DynamicCollection<ServiceDispatcher> storage = new DynamicCollection<ServiceDispatcher>();
     private final List<ServiceDispatcher> unboundDispatchers = new ArrayList<ServiceDispatcher>();
 
     public RefListRecipe(String name,
                          ExtendedBlueprintContainer blueprintContainer,
                          RefListMetadata metadata,
-                         Recipe listenersRecipe) {
-        super(name, blueprintContainer, metadata, listenersRecipe);
+                         Recipe listenersRecipe,
+                         List<Recipe> explicitDependencies) {
+        super(name, blueprintContainer, metadata, listenersRecipe, explicitDependencies);
         this.metadata = metadata;
     }
 
     @Override
     protected Object internalCreate() throws ComponentDefinitionException {
-        Comparator comparator = null;
         try {
-            storage = new DynamicCollection<ServiceDispatcher>();
-
+            if (explicitDependencies != null) {
+                for (Recipe recipe : explicitDependencies) {
+                    recipe.create();
+                }
+            }
+            ProvidedObject object = new ProvidedObject();
+            addObject(object, true);
             // Handle initial references
             createListeners();
             retrack();
-
-            return new ProvidedObject();
+            return object;
         } catch (ComponentDefinitionException t) {
             throw t;
         } catch (Throwable t) {
@@ -224,55 +226,6 @@
             return service;
         }
 
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
-            ServiceDispatcher that = (ServiceDispatcher) o;
-            if (this.proxy != null ? !this.proxy.equals(that.proxy) : that.proxy != null) return false;
-            return true;
-        }
-
-        @Override
-        public int hashCode() {
-            return proxy != null ? proxy.hashCode() : 0;
-        }
-    }
-
-    /**
-     * A natural order comparator working on objects implementing Comparable
-     * and simply delegating to Comparable.compareTo()
-     */
-    public static class NaturalOrderComparator implements Comparator<Comparable> {
-
-        public int compare(Comparable o1, Comparable o2) {
-            return o1.compareTo(o2);
-        }
-
-    }
-
-    /**
-     * A comparator to order ServiceDispatchers, sorting on references or proxies
-     * depending of the configuration of the <ref-list/> or <ref-set/>
-     */
-    public static class DispatcherComparator implements Comparator<ServiceDispatcher> {
-
-        private final Comparator comparator;
-        private final boolean orderingReferences;
-
-        public DispatcherComparator(Comparator comparator, boolean orderingReferences) {
-            this.comparator = comparator;
-            this.orderingReferences = orderingReferences;
-        }
-
-        public int compare(ServiceDispatcher d1, ServiceDispatcher d2) {
-            return comparator.compare(getOrdering(d1), getOrdering(d2));
-        }
-
-        protected Object getOrdering(ServiceDispatcher d) {
-            return orderingReferences ? d.reference : d.proxy;
-        }
-
     }
 
     public class ProvidedObject implements ConversionUtils.Convertible {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceRecipe.java Tue Jun  9 13:11:27 2009
@@ -19,6 +19,7 @@
 package org.apache.geronimo.blueprint.container;
 
 import java.lang.reflect.Type;
+import java.util.List;
 import java.util.concurrent.Callable;
 
 import org.apache.geronimo.blueprint.ExtendedBlueprintContainer;
@@ -54,26 +55,36 @@
     public ReferenceRecipe(String name,
                            ExtendedBlueprintContainer blueprintContainer,
                            ReferenceMetadata metadata,
-                           Recipe listenersRecipe) {
-        super(name, blueprintContainer, metadata, listenersRecipe);
+                           Recipe listenersRecipe,
+                           List<Recipe> explicitDependencies) {
+        super(name, blueprintContainer, metadata, listenersRecipe, explicitDependencies);
         this.metadata = metadata;
     }
 
     @Override
     protected Object internalCreate() throws ComponentDefinitionException {
         try {
+            if (explicitDependencies != null) {
+                for (Recipe recipe : explicitDependencies) {
+                    recipe.create();
+                }
+            }
             // Create the proxy
             proxy = createProxy(new ServiceDispatcher(), this.metadata.getInterfaceNames());
 
             // Add partially created proxy to the context
-            addObject(proxy, true);
+            ServiceProxyWrapper wrapper = new ServiceProxyWrapper();
+
+            addObject(wrapper, true);
 
             // Handle initial references
             createListeners();
             retrack();
 
             // Return a ServiceProxy that can injection of references or proxies can be done correctly
-            return new ServiceProxyWrapper();
+            return wrapper;
+        } catch (ComponentDefinitionException e) {
+            throw e;
         } catch (Throwable t) {
             throw new ComponentDefinitionException(t);
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceListener.java Tue Jun  9 13:11:27 2009
@@ -62,16 +62,20 @@
         if (initialized) {
             return;
         }
-        Class[] paramTypes = new Class[] { service.getClass(), Map.class };
+        Class[] paramTypes = new Class[] { service != null ? service.getClass() : null, Map.class };
         Class listenerClass = listener.getClass();
 
-        registerMethods = ReflectionUtils.findCompatibleMethods(listenerClass, registerMethod, paramTypes);
-        if (registerMethods.size() == 0) {
-            throw new ComponentDefinitionException("No matching methods found for listener registration method: " + registerMethod);
+        if (registerMethod != null) {
+            registerMethods = ReflectionUtils.findCompatibleMethods(listenerClass, registerMethod, paramTypes);
+            if (registerMethods.size() == 0) {
+                throw new ComponentDefinitionException("No matching methods found for listener registration method: " + registerMethod);
+            }
         }
-        unregisterMethods = ReflectionUtils.findCompatibleMethods(listenerClass, unregisterMethod, paramTypes);
-        if (unregisterMethods.size() == 0) {
-            throw new ComponentDefinitionException("No matching methods found for listener unregistration method: " + unregisterMethod);
+        if (unregisterMethod != null) {
+            unregisterMethods = ReflectionUtils.findCompatibleMethods(listenerClass, unregisterMethod, paramTypes);
+            if (unregisterMethods.size() == 0) {
+                throw new ComponentDefinitionException("No matching methods found for listener unregistration method: " + unregisterMethod);
+            }
         }
         initialized = true;
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java Tue Jun  9 13:11:27 2009
@@ -30,9 +30,6 @@
 import org.apache.geronimo.blueprint.ServiceProcessor;
 import org.apache.geronimo.blueprint.di.AbstractRecipe;
 import org.apache.geronimo.blueprint.di.CollectionRecipe;
-import org.apache.geronimo.blueprint.di.DefaultExecutionContext;
-import org.apache.geronimo.blueprint.di.DefaultRepository;
-import org.apache.geronimo.blueprint.di.ExecutionContext;
 import org.apache.geronimo.blueprint.di.MapRecipe;
 import org.apache.geronimo.blueprint.di.Recipe;
 import org.apache.geronimo.blueprint.di.RefRecipe;
@@ -56,9 +53,6 @@
 /**
  * A <code>Recipe</code> to export services into the OSGi registry.
  *
- * TODO: refactor the bundle scope stuff
- * TODO: if the bean is a prototype or a ServiceFactory, a null service should be sent to listeners
- *
  * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
  * @version $Rev: 776360 $, $Date: 2009-05-19 17:40:47 +0200 (Tue, 19 May 2009) $
  */
@@ -74,11 +68,12 @@
     private List<Recipe> explicitDependencies;
 
     private Map properties;
+    private boolean registered;
     private ServiceRegistration registration;
     private Map registrationProperties;
     private List<ServiceListener> listeners;
     private Object service;
-    private boolean bundleScope;
+    private boolean prototypeService;
 
     public ServiceRecipe(String name,
                          ExtendedBlueprintContainer blueprintContainer,
@@ -121,39 +116,44 @@
                 recipe.create();
             }
         }
-        return new ServiceRegistrationProxy();
+        ServiceRegistrationProxy proxy = new ServiceRegistrationProxy();
+        addObject(proxy, true);
+        getService();
+        return proxy;
     }
 
     public synchronized void register() {
-        if (registration != null) {
-            return;
-        }
-        
-        Hashtable props = new Hashtable();
-        if (properties == null) {
-            properties = (Map) createSimpleRecipe(propertiesRecipe);
-        }
-        props.putAll(properties);
-        props.put(Constants.SERVICE_RANKING, metadata.getRanking());
-        String componentName = getComponentName();
-        if (componentName != null) {
-            props.put(BlueprintConstants.COMPONENT_NAME_PROPERTY, componentName);
-        }
-        for (ServiceProcessor processor : blueprintContainer.getProcessors(ServiceProcessor.class)) {
-            processor.updateProperties(new PropertiesUpdater(), props);
-        }
-        
-        Set<String> classes = getClasses();
-        String[] classArray = classes.toArray(new String[classes.size()]);
-        registration = blueprintContainer.getBundleContext().registerService(classArray, new TriggerServiceFactory(), props);
-        registrationProperties = props;
+        if (!isRegistered()) {
+            registered = true;
+            Hashtable props = new Hashtable();
+            if (properties == null) {
+                properties = (Map) createSimpleRecipe(propertiesRecipe);
+            }
+            props.putAll(properties);
+            props.put(Constants.SERVICE_RANKING, metadata.getRanking());
+            String componentName = getComponentName();
+            if (componentName != null) {
+                props.put(BlueprintConstants.COMPONENT_NAME_PROPERTY, componentName);
+            } else {
+                props.remove(BlueprintConstants.COMPONENT_NAME_PROPERTY);
+            }
+            for (ServiceProcessor processor : blueprintContainer.getProcessors(ServiceProcessor.class)) {
+                processor.updateProperties(new PropertiesUpdater(), props);
+            }
 
-        LOGGER.debug("Service {} registered with interfaces {} and properties {}",
-                     new Object[] { name, classes, props });
+            Set<String> classes = getClasses();
+            String[] classArray = classes.toArray(new String[classes.size()]);
+
+            LOGGER.debug("Registering service {} with interfaces {} and properties {}",
+                         new Object[] { name, classes, props });
+
+            registration = blueprintContainer.getBundleContext().registerService(classArray, new TriggerServiceFactory(), props);
+            registrationProperties = props;
+        }
     }
 
     public synchronized boolean isRegistered() {
-        return registration != null;
+        return registered;
     }
 
     public synchronized ServiceReference getReference() {
@@ -175,20 +175,23 @@
 
 
     public synchronized void unregister() {
-        if (registration != null) {
+        if (isRegistered()) {
+            registered = false;
+            LOGGER.debug("Unregistering service {}", name);
             // This method needs to allow reentrance, so if we need to make sure the registration is
             // set to null before actually unregistering the service
             ServiceRegistration reg = registration;
-            registration = null;
-            // TODO: shouldn't listeners be called before unregistering the service?
-            reg.unregister();
             if (listeners != null) {
                 LOGGER.debug("Calling listeners for service unregistration");
                 for (ServiceListener listener : listeners) {
-                    listener.unregister(getService(), registrationProperties);
+                    listener.unregister(prototypeService || service instanceof ServiceFactory ? null : service, registrationProperties);
                 }
             }
-            LOGGER.debug("Service {} unregistered", name);
+            reg.unregister();
+            // We need to do this hack in order to support reantrancy
+            if (registration == reg) {
+                registration = null;
+            }
         }
     }
     
@@ -202,9 +205,9 @@
         synchronized (this) {
             if (this.service == null) {
                 try {
-                    bundleScope = isBundleScope(metadata.getServiceComponent());
-                    LOGGER.debug("Creating service instance (bundle scope = {})", bundleScope);
-                    this.service = createInstance(false);
+                    prototypeService = isPrototypeService(metadata.getServiceComponent());
+                    LOGGER.debug("Creating service instance");
+                    this.service = createInstance();
                     LOGGER.debug("Service created: {}", this.service);
                     // When the service is first requested, we need to create listeners and call them
                     if (listeners == null) {
@@ -217,7 +220,8 @@
                         LOGGER.debug("Listeners created: {}", listeners);
                         LOGGER.debug("Calling listeners for service registration");
                         for (ServiceListener listener : listeners) {
-                            listener.register(service, registrationProperties);
+                            listener.register(prototypeService || service instanceof ServiceFactory ? null : service,
+                                              registrationProperties);
                         }
                     }
                 } catch (RuntimeException e) {
@@ -229,8 +233,8 @@
         Object service = this.service;
         if (service instanceof ServiceFactory) {
             service = ((ServiceFactory) service).getService(bundle, registration);
-        } else if (bundleScope) {
-            service = createInstance(true);
+        } else {
+            service = createInstance();
             LOGGER.debug("Created service instance for bundle: " + bundle + " " + service.hashCode());
         }
         if (service == null) {
@@ -240,7 +244,10 @@
     }
 
     public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
-        if (bundleScope) {
+        if (this.service instanceof ServiceFactory) {
+            ((ServiceFactory) this.service).ungetService(bundle, registration, service);
+        }
+        if (prototypeService) {
             destroyInstance(service);
             LOGGER.debug("Destroyed service instance for bundle: " + bundle);
         }
@@ -266,22 +273,8 @@
         return classes;
     }
 
-    private Object createInstance(boolean scoped) {
-        if (scoped) {
-            Recipe recipe = serviceRecipe;
-            Repository repo = blueprintContainer.getRepository();
-            if (recipe instanceof RefRecipe) {
-                recipe = repo.getRecipe(((RefRecipe) recipe).getIdRef());
-            }
-            DefaultRepository repository = new DefaultRepository((DefaultRepository) repo);
-            if (repository.getRecipe(recipe.getName()) != recipe) {
-                repository.putRecipe(recipe.getName(), recipe);
-            }
-            BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(blueprintContainer, repository);
-            return graph.create(recipe.getName());
-        } else {
-            return createSimpleRecipe(serviceRecipe);
-        }
+    private Object createInstance() {
+        return createSimpleRecipe(serviceRecipe);
     }
 
     private Object createSimpleRecipe(Recipe recipe) {
@@ -303,7 +296,7 @@
         ((BeanRecipe) recipe).destroyInstance(instance);
     }
 
-    private boolean isBundleScope(Metadata value) {
+    private boolean isPrototypeService(Metadata value) {
         ComponentMetadata metadata = null;
         if (value instanceof RefMetadata) {
             RefMetadata ref = (RefMetadata) value;
@@ -313,22 +306,7 @@
         }
         if (metadata instanceof BeanMetadata) {
             BeanMetadata bean = (BeanMetadata) metadata;
-            Class clazz = bean.getRuntimeClass();
-            // Try to get the class from the className attribute
-            if (clazz == null && bean.getClassName() != null) {
-                ExecutionContext oldContext = ExecutionContext.setContext(new DefaultExecutionContext(blueprintContainer, blueprintContainer.getRepository()));
-                try {
-                    clazz = loadClass(bean.getClassName());
-                } finally {
-                    ExecutionContext.setContext(oldContext);
-                }
-            }
-            // TODO: if clazz == null, we must be using a factory, just ignore it for now
-            if (clazz != null && ServiceFactory.class.isAssignableFrom(clazz)) {
-                return false;
-            } else {
-                return BeanMetadata.SCOPE_BUNDLE.equals(bean.getScope());
-            }
+            return BeanMetadata.SCOPE_PROTOTYPE.equals(bean.getScope());
         } else {
             return false;
         }
@@ -366,7 +344,7 @@
         }
 
         public void unregister() {
-            ServiceRecipe.this.unregister();
+            throw new UnsupportedOperationException();
         }
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/DefaultExecutionContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/DefaultExecutionContext.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/DefaultExecutionContext.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/DefaultExecutionContext.java Tue Jun  9 13:11:27 2009
@@ -58,6 +58,10 @@
         this.repository = repository;
     }
 
+    public Object getContextKey() {
+        return this.blueprintContainer;
+    }
+
     public void push(Recipe recipe) {
         if (stack.contains(recipe)) {
             ArrayList<Recipe> circularity = new ArrayList<Recipe>(stack.subList(stack.indexOf(recipe), stack.size()));

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ExecutionContext.java Tue Jun  9 13:11:27 2009
@@ -38,10 +38,14 @@
 
     public static ExecutionContext setContext(ExecutionContext newContext) {
         ExecutionContext oldContext = context.get();
-        context.set(newContext);
+        if (oldContext == null || newContext == null || oldContext.getContextKey() != newContext.getContextKey()) {
+            context.set(newContext);
+        }
         return oldContext;
     }
 
+    public abstract Object getContextKey();
+
     /**
      * Adds a recipe to the top of the execution stack.  If the recipe is already on
      * the stack, a CircularDependencyException is thrown.

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/AbstractPropertyPlaceholder.java Tue Jun  9 13:11:27 2009
@@ -33,7 +33,6 @@
 import org.apache.geronimo.blueprint.mutable.MutableMapEntry;
 import org.apache.geronimo.blueprint.mutable.MutableMapMetadata;
 import org.apache.geronimo.blueprint.mutable.MutablePropsMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableRefListMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableRegistrationListener;
 import org.apache.geronimo.blueprint.mutable.MutableServiceMetadata;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/ExtNamespaceHandler.java Tue Jun  9 13:11:27 2009
@@ -19,38 +19,38 @@
 package org.apache.geronimo.blueprint.ext;
 
 import java.net.URL;
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 import org.w3c.dom.Attr;
 import org.w3c.dom.CharacterData;
 import org.w3c.dom.Comment;
+import org.w3c.dom.Element;
 import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
-import org.osgi.service.blueprint.reflect.Metadata;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
-import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.reflect.RefMetadata;
-import org.osgi.service.blueprint.reflect.IdRefMetadata;
-import org.osgi.service.blueprint.reflect.CollectionMetadata;
-import org.osgi.service.blueprint.reflect.BeanProperty;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
-import org.osgi.service.blueprint.reflect.RefListMetadata;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.apache.geronimo.blueprint.ParserContext;
 import org.apache.geronimo.blueprint.ExtendedRefListMetadata;
+import org.apache.geronimo.blueprint.ParserContext;
 import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableComponentMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableValueMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableRefMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableIdRefMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableMapMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableRefMetadata;
 import org.apache.geronimo.blueprint.mutable.MutableServiceReferenceMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableValueMetadata;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.CollectionMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.IdRefMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.RefListMetadata;
+import org.osgi.service.blueprint.reflect.RefMetadata;
+import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PlaceholdersUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PlaceholdersUtils.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PlaceholdersUtils.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PlaceholdersUtils.java Tue Jun  9 13:11:27 2009
@@ -18,13 +18,13 @@
  */
 package org.apache.geronimo.blueprint.ext;
 
-import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
 import org.apache.geronimo.blueprint.ComponentDefinitionRegistry;
-import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.reflect.BeanMetadata;
 import org.osgi.service.blueprint.reflect.BeanProperty;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
 
 /**
  * Utility for placeholders parsing / validation

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PropertyPlaceholder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PropertyPlaceholder.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PropertyPlaceholder.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/ext/PropertyPlaceholder.java Tue Jun  9 13:11:27 2009
@@ -18,16 +18,15 @@
  */
 package org.apache.geronimo.blueprint.ext;
 
-import java.util.Map;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
-import java.net.URL;
-import java.io.InputStream;
-import java.io.IOException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.osgi.service.blueprint.container.ComponentDefinitionException;
 
 /**
  * Property placeholder that looks for properties in the System properties.

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableRefListMetadata.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableRefListMetadata.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableRefListMetadata.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableRefListMetadata.java Tue Jun  9 13:11:27 2009
@@ -18,7 +18,6 @@
  */
 package org.apache.geronimo.blueprint.mutable;
 
-import org.osgi.service.blueprint.reflect.Target;
 import org.apache.geronimo.blueprint.ExtendedRefListMetadata;
 
 /**

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableServiceReferenceMetadata.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableServiceReferenceMetadata.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableServiceReferenceMetadata.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/mutable/MutableServiceReferenceMetadata.java Tue Jun  9 13:11:27 2009
@@ -18,10 +18,9 @@
  */
 package org.apache.geronimo.blueprint.mutable;
 
+import org.apache.geronimo.blueprint.ExtendedServiceReferenceMetadata;
 import org.osgi.service.blueprint.reflect.Listener;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
 import org.osgi.service.blueprint.reflect.Target;
-import org.apache.geronimo.blueprint.ExtendedServiceReferenceMetadata;
 
 /**
  * A mutable version of the <code>ServiceReferenceMetadata</code> that allows modifications.

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/namespace/ComponentDefinitionRegistryImpl.java Tue Jun  9 13:11:27 2009
@@ -19,11 +19,10 @@
 package org.apache.geronimo.blueprint.namespace;
 
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.LinkedHashMap;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.geronimo.blueprint.ComponentDefinitionRegistry;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/ComponentMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/ComponentMetadataImpl.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/ComponentMetadataImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/ComponentMetadataImpl.java Tue Jun  9 13:11:27 2009
@@ -18,9 +18,9 @@
  */
 package org.apache.geronimo.blueprint.reflect;
 
-import java.util.List;
-import java.util.Collections;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 
 import org.apache.geronimo.blueprint.mutable.MutableComponentMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/RefListMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/RefListMetadataImpl.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/RefListMetadataImpl.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/RefListMetadataImpl.java Tue Jun  9 13:11:27 2009
@@ -20,7 +20,6 @@
 
 import org.apache.geronimo.blueprint.mutable.MutableRefListMetadata;
 import org.osgi.service.blueprint.reflect.RefListMetadata;
-import org.osgi.service.blueprint.reflect.Target;
 
 /**
  * Implementation of RefCollectionMetadata 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ConversionUtils.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ConversionUtils.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ConversionUtils.java Tue Jun  9 13:11:27 2009
@@ -20,7 +20,6 @@
 
 import java.lang.reflect.Array;
 import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -33,7 +32,6 @@
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.Arrays;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/DynamicCollection.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/DynamicCollection.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/DynamicCollection.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/DynamicCollection.java Tue Jun  9 13:11:27 2009
@@ -110,12 +110,8 @@
             throw new NullPointerException();
         }
         synchronized (lock) {
-            if (!storage.contains(o)) {
-                internalAdd(storage.size(), o);
-                return true;
-            } else {
-                return false;
-            }
+            internalAdd(storage.size(), o);
+            return true;
         }
     }
 

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ReflectionUtils.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ReflectionUtils.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/utils/ReflectionUtils.java Tue Jun  9 13:11:27 2009
@@ -83,7 +83,7 @@
             if (name.equals(method.getName()) && Void.TYPE.equals(method.getReturnType()) && methodParams.length == paramTypes.length) {
                 boolean assignable = true;
                 for (int i = 0; i < paramTypes.length && assignable; i++) {
-                    assignable = methodParams[i].isAssignableFrom(paramTypes[i]);
+                    assignable &= paramTypes[i] == null || methodParams[i].isAssignableFrom(paramTypes[i]);
                 }
                 if (assignable) {
                     methods.add(method);

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/resources/org/apache/geronimo/blueprint/blueprint.xsd Tue Jun  9 13:11:27 2009
@@ -131,8 +131,8 @@
                 <xsd:documentation>
                   <![CDATA[
                   Specifies the default initialization setting that will be defined
-                  for <bean> components.  If not specified, the global
-                  default is "eager".  Individual <bean> components may
+                  for components.  If not specified, the global
+                  default is "eager".  Individual components may
                   override the default
                   ]]>
                 </xsd:documentation>

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContainer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContainer.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContainer.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/TestBlueprintContainer.java Tue Jun  9 13:11:27 2009
@@ -19,6 +19,7 @@
 package org.apache.geronimo.blueprint;
 
 import org.apache.geronimo.blueprint.container.BlueprintContainerImpl;
+import org.apache.geronimo.blueprint.container.BlueprintObjectInstantiator;
 import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
 
 public class TestBlueprintContainer extends BlueprintContainerImpl {
@@ -39,5 +40,9 @@
     public ComponentDefinitionRegistryImpl getComponentDefinitionRegistry() {
         return registry;
     }
+
+    public BlueprintObjectInstantiator getInstantiator() throws Exception {
+        return super.getInstantiator();
+    }
     
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java?rev=782992&r1=782991&r2=782992&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java Tue Jun  9 13:11:27 2009
@@ -46,9 +46,7 @@
 
     public void testWiring() throws Exception {
         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
         
         Object obj1 = graph.create("pojoA");
         assertNotNull(obj1);
@@ -128,17 +126,15 @@
         
         assertTrue(obj4 != graph.create("pojoC"));
         
-        repository.destroy();       
+        graph.getRepository().destroy();
         
         // test destroy-method
         assertEquals(true, pojob.getDestroyCalled());
     }
     
     public void testCompoundProperties() throws Exception {
-        ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
+        ComponentDefinitionRegistryImpl registry = parse("/test-wiring-on.xml");
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
         
         Object obj5 = graph.create("compound");
         assertNotNull(obj5);
@@ -173,9 +169,7 @@
         CallbackTracker.clear();
 
         ComponentDefinitionRegistryImpl registry = parse("/test-depends-on.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
         Map instances = graph.createAll("c", "d", "e");
         
         List<Callback> callback = CallbackTracker.getCallbacks();
@@ -184,7 +178,7 @@
         checkInitCallback(instances.get("c"), callback.get(1));
         checkInitCallback(instances.get("e"), callback.get(2));
                 
-        repository.destroy();
+        graph.getRepository().destroy();
         
         assertEquals(6, callback.size());
         checkDestroyCallback(instances.get("e"), callback.get(3));
@@ -204,9 +198,7 @@
     
     public void testConstructor() throws Exception {
         ComponentDefinitionRegistryImpl registry = parse("/test-constructor.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
 
         Object obj1 = graph.create("pojoA");
         assertNotNull(obj1);
@@ -296,10 +288,8 @@
 
     public void testGenerics() throws Exception {
         ComponentDefinitionRegistryImpl registry = parse("/test-generics.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
-        
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
+
         List<Integer> expectedList = new ArrayList<Integer>();
         expectedList.add(new Integer(10));
         expectedList.add(new Integer(20));
@@ -347,9 +337,7 @@
     
     public void testCircular() throws Exception {
         ComponentDefinitionRegistryImpl registry = parse("/test-circular.xml");
-        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContainer(registry));
-        Repository repository = i.createRepository();
-        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(new TestBlueprintContainer(registry), repository);
+        BlueprintObjectInstantiator graph = new TestBlueprintContainer(registry).getInstantiator();
 
         // this should pass (we allow circular dependencies for components without init method)
         Object obj1 = graph.create("a");



Mime
View raw message