You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Guillaume Nodet <gn...@gmail.com> on 2009/05/05 20:30:31 UTC

Re: svn commit: r771942 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/context/ test/java/org/apache/geronimo/blueprint/ test/resources/

Why did you get rid of the ObjectGraph ?  This is where all the
dependencies informations are used to order the creation of objects,
detect cycles and such.  I don't see anything about that in the new
one, so I suppose any cycle would lead to an infinite loop...

On Tue, May 5, 2009 at 19:44,  <ga...@apache.org> wrote:
> Author: gawor
> Date: Tue May  5 17:44:48 2009
> New Revision: 771942
>
> URL: http://svn.apache.org/viewvc?rev=771942&view=rev
> Log:
> switch to our own ObjectGraph implementation
>
> Added:
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java   (with props)
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java   (contents, props changed)
>      - copied, changed from r771533, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
> Removed:
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
> Modified:
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java
>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java
>    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
>    geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
>
> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=771942&r1=771941&r2=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java Tue May  5 17:44:48 2009
> @@ -34,7 +34,6 @@
>
>  import org.apache.geronimo.blueprint.BlueprintConstants;
>  import org.apache.geronimo.blueprint.utils.HeaderParser;
> -import org.apache.geronimo.blueprint.utils.BundleDelegatingClassLoader;
>  import org.apache.geronimo.blueprint.utils.HeaderParser.PathElement;
>  import org.apache.geronimo.blueprint.BlueprintContextEventSender;
>  import org.apache.geronimo.blueprint.NamespaceHandlerRegistry;
> @@ -44,7 +43,6 @@
>  import org.apache.geronimo.blueprint.ExtendedBlueprintContext;
>  import org.apache.geronimo.blueprint.convert.ConversionServiceImpl;
>  import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
> -import org.apache.xbean.recipe.ObjectGraph;
>  import org.apache.xbean.recipe.Repository;
>  import org.apache.xbean.recipe.Recipe;
>  import org.apache.xbean.recipe.ExecutionContext;
> @@ -100,7 +98,7 @@
>     private Set<URI> namespaces;
>     private State state = State.Unknown;
>     private Parser parser;
> -    private ObjectGraph objectGraph;
> +    private BlueprintObjectInstantiator instantiator;
>     private ServiceRegistration registration;
>     private boolean waitForNamespaceHandlersEventSent;
>     private Map<String, Destroyable> destroyables = new HashMap<String, Destroyable>();
> @@ -192,9 +190,9 @@
>                         state = State.Populated;
>                         break;
>                     case Populated:
> -                        Instanciator i = new Instanciator(this);
> +                        RecipeBuilder i = new RecipeBuilder(this);
>                         Repository repository = i.createRepository(componentDefinitionRegistry);
> -                        objectGraph = new ObjectGraph(repository);
> +                        instantiator = new BlueprintObjectInstantiator(repository);
>                         instanciateServiceReferences();
>                         if (checkAllSatisfiables()) {
>                             state = State.InitialReferencesSatisfied;
> @@ -254,10 +252,10 @@
>     }
>
>     private void processHelperSection() throws Exception {
> -        Instanciator i = new Instanciator(this);
> +        RecipeBuilder i = new RecipeBuilder(this);
>         Repository repository = i.createRepository(helperComponentDefinitionRegistry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> -        Map<String, Object> objects = graph.createAll(new ArrayList<String>(helperComponentDefinitionRegistry.getComponentDefinitionNames()));
> +        BlueprintObjectInstantiator instantiator = new BlueprintObjectInstantiator(repository);
> +        Map<String, Object> objects = instantiator.createAll(helperComponentDefinitionRegistry.getComponentDefinitionNames());
>         for (Object obj : objects.values()) {
>             if (obj instanceof Converter) {
>                 conversionService.registerConverter((Converter) obj);
> @@ -275,12 +273,12 @@
>         if (satisfiables == null) {
>             boolean createNewContext = !ExecutionContext.isContextSet();
>             if (createNewContext) {
> -                ExecutionContext.setContext(new DefaultExecutionContext(objectGraph.getRepository()));
> +                ExecutionContext.setContext(new DefaultExecutionContext(instantiator.getRepository()));
>             }
>             try {
>                 satisfiables = new HashMap<String, List<SatisfiableRecipe>>();
>                 for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
> -                    Object val = objectGraph.getRepository().get(name);
> +                    Object val = instantiator.getRepository().get(name);
>                     if (val instanceof Recipe) {
>                         Recipe r = (Recipe) val;
>                         List<SatisfiableRecipe> recipes = new ArrayList<SatisfiableRecipe>();
> @@ -325,7 +323,7 @@
>             }
>         }
>         LOGGER.debug("Instanciating service references: {}", satisfiables);
> -        objectGraph.createAll(satisfiables);
> +        instantiator.createAll(satisfiables);
>     }
>
>     private boolean checkAllSatisfiables() {
> @@ -377,19 +375,18 @@
>             if (component instanceof BeanMetadata) {
>                 BeanMetadata local = (BeanMetadata) component;
>                 String scope = local.getScope();
> -                if (!local.isLazyInit() &&
> -                    (BeanMetadata.SCOPE_BUNDLE.equals(scope) ||
> -                     BeanMetadata.SCOPE_SINGLETON.equals(scope))) {
> +                if (!local.isLazyInit() && BeanMetadata.SCOPE_SINGLETON.equals(scope)) {
>                     components.add(name);
>                 }
>             }
>         }
> -        Map instances = objectGraph.createAll(components);
> +        LOGGER.debug("Instantiating components: {}", components);
> +        instantiator.createAll(components);
>     }
>
>     private void destroyComponents() {
> -        if (objectGraph != null) {
> -            ((BlueprintObjectRepository)objectGraph.getRepository()).destroy();
> +        if (instantiator != null) {
> +            ((BlueprintObjectRepository)instantiator.getRepository()).destroy();
>         }
>
>         Map<String, Destroyable> destroyables = new HashMap<String, Destroyable>(this.destroyables);
> @@ -465,14 +462,13 @@
>     }
>
>     public Object getComponent(String name) throws NoSuchComponentException {
> -        if (objectGraph == null) {
> +        if (instantiator == null) {
>             throw new NoSuchComponentException(name);
>         }
> -        Object instance = objectGraph.create(name);
> -        if (instance == null) {
> +        try {
> +            return instantiator.create(name);
> +        } catch (org.apache.xbean.recipe.NoSuchObjectException e) {
>             throw new NoSuchComponentException(name);
> -        } else {
> -            return instance;
>         }
>     }
>
> @@ -509,8 +505,8 @@
>
>     }
>
> -    protected ObjectGraph getObjectGraph() {
> -        return objectGraph;
> +    protected Repository getRepository() {
> +        return instantiator.getRepository();
>     }
>
>     protected ConversionService getConversionService() {
>
> Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java?rev=771942&view=auto
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java (added)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java Tue May  5 17:44:48 2009
> @@ -0,0 +1,90 @@
> +/**
> + *
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You 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.blueprint.context;
> +
> +import java.util.Arrays;
> +import java.util.Collection;
> +import java.util.LinkedHashMap;
> +import java.util.List;
> +import java.util.Map;
> +import java.util.Set;
> +
> +import org.apache.xbean.recipe.ConstructionException;
> +import org.apache.xbean.recipe.DefaultExecutionContext;
> +import org.apache.xbean.recipe.ExecutionContext;
> +import org.apache.xbean.recipe.NoSuchObjectException;
> +import org.apache.xbean.recipe.Recipe;
> +import org.apache.xbean.recipe.Repository;
> +
> +/**
> + */
> +public class BlueprintObjectInstantiator  {
> +
> +    private Repository repository;
> +
> +    public BlueprintObjectInstantiator(Repository repository) {
> +        this.repository = repository;
> +    }
> +
> +    public  Repository getRepository() {
> +        return repository;
> +    }
> +
> +    public Object create(String name) throws ConstructionException {
> +        Map<String, Object> instances = createAll(Arrays.asList(name));
> +        return instances.get(name);
> +    }
> +
> +    public Map<String,Object> createAll(String... names) throws ConstructionException {
> +        return createAll(Arrays.asList(names));
> +    }
> +
> +    public Map<String, Object> createAll(Collection<String> names) throws ConstructionException {
> +        Map<String, Object> instances = new LinkedHashMap<String, Object>();
> +        for (String name : names) {
> +
> +            boolean createNewContext = !ExecutionContext.isContextSet();
> +            if (createNewContext) {
> +                ExecutionContext.setContext(new DefaultExecutionContext(repository));
> +            }
> +
> +            try {
> +                Object obj = createInstance(name);
> +                instances.put(name, obj);
> +            } finally {
> +                if (createNewContext) {
> +                    ExecutionContext.setContext(null);
> +                }
> +            }
> +        }
> +        return instances;
> +    }
> +
> +    private Object createInstance(String name) {
> +        Object recipe = repository.get(name);
> +        if (recipe == null) {
> +            throw new NoSuchObjectException(name);
> +        }
> +        Object obj = recipe;
> +        if (recipe instanceof Recipe) {
> +            obj = ((Recipe) recipe).create(Object.class, false);
> +        }
> +        return obj;
> +    }
> +
> +}
>
> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
> ------------------------------------------------------------------------------
>    svn:keywords = Date Revision
>
> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
> ------------------------------------------------------------------------------
>    svn:mime-type = text/plain
>
> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=771942&r1=771941&r2=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java Tue May  5 17:44:48 2009
> @@ -137,6 +137,15 @@
>         return recipes;
>     }
>
> +    private void instantiateExplicitDependencies() {
> +        if (explicitDependencies != null) {
> +            for (String name : explicitDependencies) {
> +                Recipe recipe = new ReferenceRecipe(name);
> +                recipe.create(Object.class, false);
> +            }
> +        }
> +    }
> +
>     private List<Object> getInitialArguments(boolean refAllowed) throws ConstructionException {
>         List<Object> args = new ArrayList<Object>();
>         for (int i = 0; beanArguments != null && i < beanArguments.size(); i++) {
> @@ -192,7 +201,7 @@
>             return null;
>         }
>         try {
> -            return Instanciator.loadClass(blueprintContext, typeName);
> +            return RecipeBuilder.loadClass(blueprintContext, typeName);
>         } catch (ClassNotFoundException e) {
>             throw new ConstructionException("Unable to load type class " + typeName);
>         }
> @@ -333,6 +342,8 @@
>     @Override
>     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException {
>
> +        instantiateExplicitDependencies();
> +
>         final Object obj = getInstance(lazyRefAllowed);
>
>         // check for init lifecycle method (if any)
> @@ -356,7 +367,7 @@
>             }
>         }
>
> -        if (getName() != null) {
> +        if (getName() != null && !keepRecipe) {
>             ExecutionContext.getContext().addObject(getName(), obj);
>         }
>
>
> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java?rev=771942&r1=771941&r2=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java Tue May  5 17:44:48 2009
> @@ -30,10 +30,7 @@
>  import org.apache.xbean.recipe.Repository;
>
>  /**
> - * By default in object repository Recipes are replaced with objects that were creating using the given Recipe.
> - * That essentially implements the 'singleton' scope. For 'prototype' scope we do not allow certain Recipes to
> - * be replaced with resulting objects in the repository. That ensures that a new instance of a object is created
> - * for such Recipes during graph instantiation.
> + *
>  */
>  public class BlueprintObjectRepository implements Repository {
>
> @@ -67,9 +64,6 @@
>         if (existingObj != null) {
>             if (existingObj instanceof BlueprintObjectRecipe) {
>                 BlueprintObjectRecipe recipe = (BlueprintObjectRecipe) existingObj;
> -                if (recipe.getKeepRecipe()) {
> -                    return;
> -                }
>                 Method method = recipe.getDestroyMethod(instance);
>                 if (method != null) {
>                     destroyList.add(new DestroyCallback(method, instance));
>
> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java?rev=771942&r1=771941&r2=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java Tue May  5 17:44:48 2009
> @@ -73,7 +73,7 @@
>     }
>
>     private Object createInstance() {
> -        Repository objectRepository = blueprintContext.getObjectGraph().getRepository();
> +        Repository objectRepository = blueprintContext.getRepository();
>         BlueprintObjectRepository repository = new BlueprintObjectRepository((BlueprintObjectRepository)objectRepository);
>         repository.set(serviceRecipe.getName(), serviceRecipe);
>         ObjectGraph graph = new ObjectGraph(repository);
>
> Copied: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java (from r771533, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java)
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java?p2=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java&p1=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java&r1=771533&r2=771942&rev=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java Tue May  5 17:44:48 2009
> @@ -64,7 +64,7 @@
>  * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
>  * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
>  */
> -public class Instanciator {
> +public class RecipeBuilder {
>
>     private static Map<String, Class> primitiveClasses = new HashMap<String, Class>();
>
> @@ -83,7 +83,7 @@
>     private BlueprintContextImpl blueprintContext;
>     private ExtendedComponentDefinitionRegistry registry;
>
> -    public Instanciator(BlueprintContextImpl blueprintContext) {
> +    public RecipeBuilder(BlueprintContextImpl blueprintContext) {
>         this.blueprintContext = blueprintContext;
>     }
>
>
> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
> ------------------------------------------------------------------------------
>    svn:mergeinfo =
>
> 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=771942&r1=771941&r2=771942&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 May  5 17:44:48 2009
> @@ -24,14 +24,14 @@
>  import java.util.Map;
>
>  import org.apache.geronimo.blueprint.CallbackTracker.Callback;
> +import org.apache.geronimo.blueprint.context.BlueprintObjectInstantiator;
>  import org.apache.geronimo.blueprint.context.BlueprintObjectRepository;
> -import org.apache.geronimo.blueprint.context.Instanciator;
> +import org.apache.geronimo.blueprint.context.RecipeBuilder;
>  import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
>  import org.apache.geronimo.blueprint.pojos.BeanD;
>  import org.apache.geronimo.blueprint.pojos.Multiple;
>  import org.apache.geronimo.blueprint.pojos.PojoA;
>  import org.apache.geronimo.blueprint.pojos.PojoB;
> -import org.apache.xbean.recipe.ObjectGraph;
>  import org.apache.xbean.recipe.Repository;
>  import org.osgi.framework.ServiceRegistration;
>
> @@ -39,9 +39,9 @@
>
>     public void testWiring() throws Exception {
>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>         BlueprintObjectRepository repository = i.createRepository(registry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>
>         Object obj1 = graph.create("pojoA");
>         assertNotNull(obj1);
> @@ -129,9 +129,9 @@
>
>     public void testCompoundProperties() throws Exception {
>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>         BlueprintObjectRepository repository = i.createRepository(registry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>
>         Object obj5 = graph.create("compound");
>         assertNotNull(obj5);
> @@ -143,9 +143,9 @@
>
>     public void testIdRefs() throws Exception {
>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>         BlueprintObjectRepository repository = i.createRepository(registry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>
>         try {
>             graph.create("badIdRef");
> @@ -167,9 +167,9 @@
>         CallbackTracker.clear();
>
>         ComponentDefinitionRegistryImpl registry = parse("/test-depends-on.xml");
> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>         BlueprintObjectRepository repository = i.createRepository(registry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>         Map instances = graph.createAll("c", "d", "e");
>
>         List<Callback> callback = CallbackTracker.getCallbacks();
> @@ -198,9 +198,9 @@
>
>     public void testConstructor() throws Exception {
>         ComponentDefinitionRegistryImpl registry = parse("/test-constructor.xml");
> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>         Repository repository = i.createRepository(registry);
> -        ObjectGraph graph = new ObjectGraph(repository);
> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>
>         Object obj1 = graph.create("pojoA");
>         assertNotNull(obj1);
>
> Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml?rev=771942&r1=771941&r2=771942&view=diff
> ==============================================================================
> --- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml (original)
> +++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml Tue May  5 17:44:48 2009
> @@ -92,4 +92,16 @@
>         <property name="bean.name" value="hello bean property" />
>     </bean>
>
> +    <bean id="badIdRef" class="org.apache.geronimo.blueprint.pojos.BeanD">
> +        <property name="name">
> +          <idref component="doesnotexist"/>
> +        </property>
> +    </bean>
> +
> +    <bean id="goodIdRef" class="org.apache.geronimo.blueprint.pojos.BeanD">
> +        <property name="name">
> +          <idref component="pojoA"/>
> +        </property>
> +    </bean>
> +
>  </blueprint>
> \ No newline at end of file
>
>
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: svn commit: r771942 - in /geronimo/sandbox/blueprint/blueprint-core/src: main/java/org/apache/geronimo/blueprint/context/ test/java/org/apache/geronimo/blueprint/ test/resources/

Posted by Jarek Gawor <jg...@gmail.com>.
I ran into a problem with ObjectGraph and 'prototype' scoped
components where it was creating too many instances unnecessarily. If
a component was in the repository, was in 'prototype' scope, and it
was referenced by some other component, an instance of it was
unnecessary pre-created by the ObjectGraph. ObjectGraph was really
designed to work with 'singleton' scoped components and the
'prototype' scope didn't really mix. Now, everything is done on
demand, in the right order, and just the right number of instances is
created.
As to circular dependencies, they are still caught but slightly later
at creation/injection time. See
org.apache.xbean.recipe.DefaultExecutionContext. Either way, we will
need to allow for some circular dependencies in the future so I'm sure
there will be more changes in this area in our or xbean-reflect code.

Jarek

On Tue, May 5, 2009 at 2:30 PM, Guillaume Nodet <gn...@gmail.com> wrote:
> Why did you get rid of the ObjectGraph ?  This is where all the
> dependencies informations are used to order the creation of objects,
> detect cycles and such.  I don't see anything about that in the new
> one, so I suppose any cycle would lead to an infinite loop...
>
> On Tue, May 5, 2009 at 19:44,  <ga...@apache.org> wrote:
>> Author: gawor
>> Date: Tue May  5 17:44:48 2009
>> New Revision: 771942
>>
>> URL: http://svn.apache.org/viewvc?rev=771942&view=rev
>> Log:
>> switch to our own ObjectGraph implementation
>>
>> Added:
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java   (with props)
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java   (contents, props changed)
>>      - copied, changed from r771533, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
>> Removed:
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
>> Modified:
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/test/java/org/apache/geronimo/blueprint/WiringTest.java
>>    geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
>>
>> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=771942&r1=771941&r2=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java Tue May  5 17:44:48 2009
>> @@ -34,7 +34,6 @@
>>
>>  import org.apache.geronimo.blueprint.BlueprintConstants;
>>  import org.apache.geronimo.blueprint.utils.HeaderParser;
>> -import org.apache.geronimo.blueprint.utils.BundleDelegatingClassLoader;
>>  import org.apache.geronimo.blueprint.utils.HeaderParser.PathElement;
>>  import org.apache.geronimo.blueprint.BlueprintContextEventSender;
>>  import org.apache.geronimo.blueprint.NamespaceHandlerRegistry;
>> @@ -44,7 +43,6 @@
>>  import org.apache.geronimo.blueprint.ExtendedBlueprintContext;
>>  import org.apache.geronimo.blueprint.convert.ConversionServiceImpl;
>>  import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
>> -import org.apache.xbean.recipe.ObjectGraph;
>>  import org.apache.xbean.recipe.Repository;
>>  import org.apache.xbean.recipe.Recipe;
>>  import org.apache.xbean.recipe.ExecutionContext;
>> @@ -100,7 +98,7 @@
>>     private Set<URI> namespaces;
>>     private State state = State.Unknown;
>>     private Parser parser;
>> -    private ObjectGraph objectGraph;
>> +    private BlueprintObjectInstantiator instantiator;
>>     private ServiceRegistration registration;
>>     private boolean waitForNamespaceHandlersEventSent;
>>     private Map<String, Destroyable> destroyables = new HashMap<String, Destroyable>();
>> @@ -192,9 +190,9 @@
>>                         state = State.Populated;
>>                         break;
>>                     case Populated:
>> -                        Instanciator i = new Instanciator(this);
>> +                        RecipeBuilder i = new RecipeBuilder(this);
>>                         Repository repository = i.createRepository(componentDefinitionRegistry);
>> -                        objectGraph = new ObjectGraph(repository);
>> +                        instantiator = new BlueprintObjectInstantiator(repository);
>>                         instanciateServiceReferences();
>>                         if (checkAllSatisfiables()) {
>>                             state = State.InitialReferencesSatisfied;
>> @@ -254,10 +252,10 @@
>>     }
>>
>>     private void processHelperSection() throws Exception {
>> -        Instanciator i = new Instanciator(this);
>> +        RecipeBuilder i = new RecipeBuilder(this);
>>         Repository repository = i.createRepository(helperComponentDefinitionRegistry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> -        Map<String, Object> objects = graph.createAll(new ArrayList<String>(helperComponentDefinitionRegistry.getComponentDefinitionNames()));
>> +        BlueprintObjectInstantiator instantiator = new BlueprintObjectInstantiator(repository);
>> +        Map<String, Object> objects = instantiator.createAll(helperComponentDefinitionRegistry.getComponentDefinitionNames());
>>         for (Object obj : objects.values()) {
>>             if (obj instanceof Converter) {
>>                 conversionService.registerConverter((Converter) obj);
>> @@ -275,12 +273,12 @@
>>         if (satisfiables == null) {
>>             boolean createNewContext = !ExecutionContext.isContextSet();
>>             if (createNewContext) {
>> -                ExecutionContext.setContext(new DefaultExecutionContext(objectGraph.getRepository()));
>> +                ExecutionContext.setContext(new DefaultExecutionContext(instantiator.getRepository()));
>>             }
>>             try {
>>                 satisfiables = new HashMap<String, List<SatisfiableRecipe>>();
>>                 for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
>> -                    Object val = objectGraph.getRepository().get(name);
>> +                    Object val = instantiator.getRepository().get(name);
>>                     if (val instanceof Recipe) {
>>                         Recipe r = (Recipe) val;
>>                         List<SatisfiableRecipe> recipes = new ArrayList<SatisfiableRecipe>();
>> @@ -325,7 +323,7 @@
>>             }
>>         }
>>         LOGGER.debug("Instanciating service references: {}", satisfiables);
>> -        objectGraph.createAll(satisfiables);
>> +        instantiator.createAll(satisfiables);
>>     }
>>
>>     private boolean checkAllSatisfiables() {
>> @@ -377,19 +375,18 @@
>>             if (component instanceof BeanMetadata) {
>>                 BeanMetadata local = (BeanMetadata) component;
>>                 String scope = local.getScope();
>> -                if (!local.isLazyInit() &&
>> -                    (BeanMetadata.SCOPE_BUNDLE.equals(scope) ||
>> -                     BeanMetadata.SCOPE_SINGLETON.equals(scope))) {
>> +                if (!local.isLazyInit() && BeanMetadata.SCOPE_SINGLETON.equals(scope)) {
>>                     components.add(name);
>>                 }
>>             }
>>         }
>> -        Map instances = objectGraph.createAll(components);
>> +        LOGGER.debug("Instantiating components: {}", components);
>> +        instantiator.createAll(components);
>>     }
>>
>>     private void destroyComponents() {
>> -        if (objectGraph != null) {
>> -            ((BlueprintObjectRepository)objectGraph.getRepository()).destroy();
>> +        if (instantiator != null) {
>> +            ((BlueprintObjectRepository)instantiator.getRepository()).destroy();
>>         }
>>
>>         Map<String, Destroyable> destroyables = new HashMap<String, Destroyable>(this.destroyables);
>> @@ -465,14 +462,13 @@
>>     }
>>
>>     public Object getComponent(String name) throws NoSuchComponentException {
>> -        if (objectGraph == null) {
>> +        if (instantiator == null) {
>>             throw new NoSuchComponentException(name);
>>         }
>> -        Object instance = objectGraph.create(name);
>> -        if (instance == null) {
>> +        try {
>> +            return instantiator.create(name);
>> +        } catch (org.apache.xbean.recipe.NoSuchObjectException e) {
>>             throw new NoSuchComponentException(name);
>> -        } else {
>> -            return instance;
>>         }
>>     }
>>
>> @@ -509,8 +505,8 @@
>>
>>     }
>>
>> -    protected ObjectGraph getObjectGraph() {
>> -        return objectGraph;
>> +    protected Repository getRepository() {
>> +        return instantiator.getRepository();
>>     }
>>
>>     protected ConversionService getConversionService() {
>>
>> Added: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java?rev=771942&view=auto
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java (added)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java Tue May  5 17:44:48 2009
>> @@ -0,0 +1,90 @@
>> +/**
>> + *
>> + * Licensed to the Apache Software Foundation (ASF) under one or more
>> + * contributor license agreements.  See the NOTICE file distributed with
>> + * this work for additional information regarding copyright ownership.
>> + * The ASF licenses this file to You 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.blueprint.context;
>> +
>> +import java.util.Arrays;
>> +import java.util.Collection;
>> +import java.util.LinkedHashMap;
>> +import java.util.List;
>> +import java.util.Map;
>> +import java.util.Set;
>> +
>> +import org.apache.xbean.recipe.ConstructionException;
>> +import org.apache.xbean.recipe.DefaultExecutionContext;
>> +import org.apache.xbean.recipe.ExecutionContext;
>> +import org.apache.xbean.recipe.NoSuchObjectException;
>> +import org.apache.xbean.recipe.Recipe;
>> +import org.apache.xbean.recipe.Repository;
>> +
>> +/**
>> + */
>> +public class BlueprintObjectInstantiator  {
>> +
>> +    private Repository repository;
>> +
>> +    public BlueprintObjectInstantiator(Repository repository) {
>> +        this.repository = repository;
>> +    }
>> +
>> +    public  Repository getRepository() {
>> +        return repository;
>> +    }
>> +
>> +    public Object create(String name) throws ConstructionException {
>> +        Map<String, Object> instances = createAll(Arrays.asList(name));
>> +        return instances.get(name);
>> +    }
>> +
>> +    public Map<String,Object> createAll(String... names) throws ConstructionException {
>> +        return createAll(Arrays.asList(names));
>> +    }
>> +
>> +    public Map<String, Object> createAll(Collection<String> names) throws ConstructionException {
>> +        Map<String, Object> instances = new LinkedHashMap<String, Object>();
>> +        for (String name : names) {
>> +
>> +            boolean createNewContext = !ExecutionContext.isContextSet();
>> +            if (createNewContext) {
>> +                ExecutionContext.setContext(new DefaultExecutionContext(repository));
>> +            }
>> +
>> +            try {
>> +                Object obj = createInstance(name);
>> +                instances.put(name, obj);
>> +            } finally {
>> +                if (createNewContext) {
>> +                    ExecutionContext.setContext(null);
>> +                }
>> +            }
>> +        }
>> +        return instances;
>> +    }
>> +
>> +    private Object createInstance(String name) {
>> +        Object recipe = repository.get(name);
>> +        if (recipe == null) {
>> +            throw new NoSuchObjectException(name);
>> +        }
>> +        Object obj = recipe;
>> +        if (recipe instanceof Recipe) {
>> +            obj = ((Recipe) recipe).create(Object.class, false);
>> +        }
>> +        return obj;
>> +    }
>> +
>> +}
>>
>> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
>> ------------------------------------------------------------------------------
>>    svn:eol-style = native
>>
>> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
>> ------------------------------------------------------------------------------
>>    svn:keywords = Date Revision
>>
>> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectInstantiator.java
>> ------------------------------------------------------------------------------
>>    svn:mime-type = text/plain
>>
>> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java?rev=771942&r1=771941&r2=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRecipe.java Tue May  5 17:44:48 2009
>> @@ -137,6 +137,15 @@
>>         return recipes;
>>     }
>>
>> +    private void instantiateExplicitDependencies() {
>> +        if (explicitDependencies != null) {
>> +            for (String name : explicitDependencies) {
>> +                Recipe recipe = new ReferenceRecipe(name);
>> +                recipe.create(Object.class, false);
>> +            }
>> +        }
>> +    }
>> +
>>     private List<Object> getInitialArguments(boolean refAllowed) throws ConstructionException {
>>         List<Object> args = new ArrayList<Object>();
>>         for (int i = 0; beanArguments != null && i < beanArguments.size(); i++) {
>> @@ -192,7 +201,7 @@
>>             return null;
>>         }
>>         try {
>> -            return Instanciator.loadClass(blueprintContext, typeName);
>> +            return RecipeBuilder.loadClass(blueprintContext, typeName);
>>         } catch (ClassNotFoundException e) {
>>             throw new ConstructionException("Unable to load type class " + typeName);
>>         }
>> @@ -333,6 +342,8 @@
>>     @Override
>>     protected Object internalCreate(Type expectedType, boolean lazyRefAllowed) throws ConstructionException {
>>
>> +        instantiateExplicitDependencies();
>> +
>>         final Object obj = getInstance(lazyRefAllowed);
>>
>>         // check for init lifecycle method (if any)
>> @@ -356,7 +367,7 @@
>>             }
>>         }
>>
>> -        if (getName() != null) {
>> +        if (getName() != null && !keepRecipe) {
>>             ExecutionContext.getContext().addObject(getName(), obj);
>>         }
>>
>>
>> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java?rev=771942&r1=771941&r2=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintObjectRepository.java Tue May  5 17:44:48 2009
>> @@ -30,10 +30,7 @@
>>  import org.apache.xbean.recipe.Repository;
>>
>>  /**
>> - * By default in object repository Recipes are replaced with objects that were creating using the given Recipe.
>> - * That essentially implements the 'singleton' scope. For 'prototype' scope we do not allow certain Recipes to
>> - * be replaced with resulting objects in the repository. That ensures that a new instance of a object is created
>> - * for such Recipes during graph instantiation.
>> + *
>>  */
>>  public class BlueprintObjectRepository implements Repository {
>>
>> @@ -67,9 +64,6 @@
>>         if (existingObj != null) {
>>             if (existingObj instanceof BlueprintObjectRecipe) {
>>                 BlueprintObjectRecipe recipe = (BlueprintObjectRecipe) existingObj;
>> -                if (recipe.getKeepRecipe()) {
>> -                    return;
>> -                }
>>                 Method method = recipe.getDestroyMethod(instance);
>>                 if (method != null) {
>>                     destroyList.add(new DestroyCallback(method, instance));
>>
>> Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java?rev=771942&r1=771941&r2=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BundleScopeServiceFactory.java Tue May  5 17:44:48 2009
>> @@ -73,7 +73,7 @@
>>     }
>>
>>     private Object createInstance() {
>> -        Repository objectRepository = blueprintContext.getObjectGraph().getRepository();
>> +        Repository objectRepository = blueprintContext.getRepository();
>>         BlueprintObjectRepository repository = new BlueprintObjectRepository((BlueprintObjectRepository)objectRepository);
>>         repository.set(serviceRecipe.getName(), serviceRecipe);
>>         ObjectGraph graph = new ObjectGraph(repository);
>>
>> Copied: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java (from r771533, geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java)
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java?p2=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java&p1=geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java&r1=771533&r2=771942&rev=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java Tue May  5 17:44:48 2009
>> @@ -64,7 +64,7 @@
>>  * @author <a href="mailto:dev@geronimo.apache.org">Apache Geronimo Project</a>
>>  * @version $Rev: 760378 $, $Date: 2009-03-31 11:31:38 +0200 (Tue, 31 Mar 2009) $
>>  */
>> -public class Instanciator {
>> +public class RecipeBuilder {
>>
>>     private static Map<String, Class> primitiveClasses = new HashMap<String, Class>();
>>
>> @@ -83,7 +83,7 @@
>>     private BlueprintContextImpl blueprintContext;
>>     private ExtendedComponentDefinitionRegistry registry;
>>
>> -    public Instanciator(BlueprintContextImpl blueprintContext) {
>> +    public RecipeBuilder(BlueprintContextImpl blueprintContext) {
>>         this.blueprintContext = blueprintContext;
>>     }
>>
>>
>> Propchange: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/RecipeBuilder.java
>> ------------------------------------------------------------------------------
>>    svn:mergeinfo =
>>
>> 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=771942&r1=771941&r2=771942&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 May  5 17:44:48 2009
>> @@ -24,14 +24,14 @@
>>  import java.util.Map;
>>
>>  import org.apache.geronimo.blueprint.CallbackTracker.Callback;
>> +import org.apache.geronimo.blueprint.context.BlueprintObjectInstantiator;
>>  import org.apache.geronimo.blueprint.context.BlueprintObjectRepository;
>> -import org.apache.geronimo.blueprint.context.Instanciator;
>> +import org.apache.geronimo.blueprint.context.RecipeBuilder;
>>  import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
>>  import org.apache.geronimo.blueprint.pojos.BeanD;
>>  import org.apache.geronimo.blueprint.pojos.Multiple;
>>  import org.apache.geronimo.blueprint.pojos.PojoA;
>>  import org.apache.geronimo.blueprint.pojos.PojoB;
>> -import org.apache.xbean.recipe.ObjectGraph;
>>  import org.apache.xbean.recipe.Repository;
>>  import org.osgi.framework.ServiceRegistration;
>>
>> @@ -39,9 +39,9 @@
>>
>>     public void testWiring() throws Exception {
>>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
>> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
>> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>>         BlueprintObjectRepository repository = i.createRepository(registry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>>
>>         Object obj1 = graph.create("pojoA");
>>         assertNotNull(obj1);
>> @@ -129,9 +129,9 @@
>>
>>     public void testCompoundProperties() throws Exception {
>>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
>> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
>> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>>         BlueprintObjectRepository repository = i.createRepository(registry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>>
>>         Object obj5 = graph.create("compound");
>>         assertNotNull(obj5);
>> @@ -143,9 +143,9 @@
>>
>>     public void testIdRefs() throws Exception {
>>         ComponentDefinitionRegistryImpl registry = parse("/test-wiring.xml");
>> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
>> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>>         BlueprintObjectRepository repository = i.createRepository(registry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>>
>>         try {
>>             graph.create("badIdRef");
>> @@ -167,9 +167,9 @@
>>         CallbackTracker.clear();
>>
>>         ComponentDefinitionRegistryImpl registry = parse("/test-depends-on.xml");
>> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
>> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>>         BlueprintObjectRepository repository = i.createRepository(registry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>>         Map instances = graph.createAll("c", "d", "e");
>>
>>         List<Callback> callback = CallbackTracker.getCallbacks();
>> @@ -198,9 +198,9 @@
>>
>>     public void testConstructor() throws Exception {
>>         ComponentDefinitionRegistryImpl registry = parse("/test-constructor.xml");
>> -        Instanciator i = new Instanciator(new TestBlueprintContext(registry));
>> +        RecipeBuilder i = new RecipeBuilder(new TestBlueprintContext(registry));
>>         Repository repository = i.createRepository(registry);
>> -        ObjectGraph graph = new ObjectGraph(repository);
>> +        BlueprintObjectInstantiator graph = new BlueprintObjectInstantiator(repository);
>>
>>         Object obj1 = graph.create("pojoA");
>>         assertNotNull(obj1);
>>
>> Modified: geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml
>> URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml?rev=771942&r1=771941&r2=771942&view=diff
>> ==============================================================================
>> --- geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml (original)
>> +++ geronimo/sandbox/blueprint/blueprint-core/src/test/resources/test-wiring.xml Tue May  5 17:44:48 2009
>> @@ -92,4 +92,16 @@
>>         <property name="bean.name" value="hello bean property" />
>>     </bean>
>>
>> +    <bean id="badIdRef" class="org.apache.geronimo.blueprint.pojos.BeanD">
>> +        <property name="name">
>> +          <idref component="doesnotexist"/>
>> +        </property>
>> +    </bean>
>> +
>> +    <bean id="goodIdRef" class="org.apache.geronimo.blueprint.pojos.BeanD">
>> +        <property name="name">
>> +          <idref component="pojoA"/>
>> +        </property>
>> +    </bean>
>> +
>>  </blueprint>
>> \ No newline at end of file
>>
>>
>>
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>