geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r777951 [2/2] - in /geronimo/sandbox/blueprint: blueprint-cm/src/main/java/org/apache/geronimo/blueprint/compendium/cm/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/ blueprint-core/src/main/java/org/apache/geronimo/blueprint/c...
Date Sat, 23 May 2009 16:27:03 GMT
Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceNameRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceNameRecipe.java?rev=777951&r1=777950&r2=777951&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceNameRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceNameRecipe.java
Sat May 23 16:27:02 2009
@@ -20,6 +20,9 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
+
 /*
  * The ReferenceNameRecipe is used to inject the reference name into the object (as a String).
  * The ReferenceNameRecipe ensures the actual reference object exists before the reference
name is injected. 
@@ -38,11 +41,11 @@
 
     private Object getReference() {
         if (referenceName == null) {
-            throw new ConstructionException("Reference name has not been set");
+            throw new ComponentDefinitionException("Reference name has not been set");
         }
         ExecutionContext context = ExecutionContext.getContext();
         if (!context.containsObject(referenceName)) {
-            throw new NoSuchObjectException(referenceName);
+            throw new NoSuchComponentException(referenceName);
         }
         return context.getObject(referenceName);
     }
@@ -57,11 +60,7 @@
         }
     }
 
-    public List<Recipe> getConstructorRecipes() {
-        return getNestedRecipes();
-    }
-
-    protected Object internalCreate(boolean lazyRefAllowed) throws ConstructionException
{
+    protected Object internalCreate() throws ComponentDefinitionException {
         Object object = getReference();
         return referenceName;
     }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceRecipe.java?rev=777951&r1=777950&r2=777951&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ReferenceRecipe.java
Sat May 23 16:27:02 2009
@@ -20,6 +20,9 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
+
 public class ReferenceRecipe extends AbstractRecipe {
     private String referenceName;
 
@@ -38,7 +41,7 @@
     public List<Recipe> getNestedRecipes() {
         ExecutionContext context = ExecutionContext.getContext();
         if (!context.containsObject(referenceName)) {
-            throw new NoSuchObjectException(referenceName);
+            throw new NoSuchComponentException(referenceName);
         }
 
         Object object = ExecutionContext.getContext().getObject(referenceName);
@@ -49,83 +52,31 @@
         return Collections.emptyList();
     }
 
-    public List<Recipe> getConstructorRecipes() {
-        return getNestedRecipes();
-    }
-
-    protected Object internalCreate(boolean lazyRefAllowed) throws ConstructionException
{
+    protected Object internalCreate() throws ComponentDefinitionException {
         if (referenceName == null) {
-            throw new ConstructionException("Reference name has not been set");
+            throw new ComponentDefinitionException("Reference name has not been set");
         }
 
         ExecutionContext context = ExecutionContext.getContext();
 
         Object object;
         if (!context.containsObject(referenceName)) {
-            if (!lazyRefAllowed) {
-                throw new ConstructionException("Currently no object registered with name
" + referenceName +
-                        " and a lazy reference not allowed");
-            }
-
-            Reference reference = new Reference(referenceName);
-            context.addReference(reference);
-            object = reference;
+            throw new ComponentDefinitionException("Currently no object registered with name
" + referenceName +
+                    " and a lazy reference not allowed");
         } else {
             object = context.getObject(referenceName);
             if (object instanceof Recipe) {
-                if (lazyRefAllowed) {
-                    Reference reference = new Reference(referenceName);
-                    context.addReference(reference);
-                    object = reference;
-                } else {
-                    Recipe recipe = (Recipe) object;
-                    object = recipe.create(false);
-                }
-
+                Recipe recipe = (Recipe) object;
+                object = recipe.create();
             }
         }
 
         // add to execution container if name is specified
         if (getName() != null) {
-            if (object instanceof Reference) {
-                object = new WrapperReference(getName(), (Reference) object);
-            } else {
-                ExecutionContext.getContext().addObject(getName(), object);
-            }
+            ExecutionContext.getContext().addObject(getName(), object);
         }
 
         return object;
     }
 
-    private static class WrapperReference extends Reference {
-        private final Reference delegate;
-
-        private WrapperReference(String name, Reference delegate) {
-            super(name);
-            this.delegate = delegate;
-        }
-
-        public boolean isResolved() {
-            return delegate.isResolved();
-        }
-
-        public Object get() {
-            return delegate.get();
-        }
-
-        public void set(Object object) {
-            if (isResolved()) {
-                throw new ConstructionException("Reference has already been resolved");
-            }
-
-            // add to execution container
-            ExecutionContext.getContext().addObject(getName(), object);
-
-            delegate.set(object);
-        }
-
-        public void setAction(Action action) {
-            delegate.setAction(action);
-        }
-    }
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java?rev=777951&r1=777950&r2=777951&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/Repository.java
Sat May 23 16:27:02 2009
@@ -39,7 +39,7 @@
      *
      * @param name the unique name of the object instance
      * @param object the object instance
-     * @throws ConstructionException if another object instance is already registered with
the name
+     * @throws ComponentDefinitionException if another object instance is already registered
with the name
      */
     void add(String name, Object object);
 }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java?rev=777951&r1=777950&r2=777951&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/di/ValueRecipe.java
Sat May 23 16:27:02 2009
@@ -20,6 +20,7 @@
 
 import java.lang.reflect.Type;
 
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
 import org.osgi.service.blueprint.reflect.ValueMetadata;
 
 /**
@@ -41,7 +42,7 @@
     }
 
     @Override
-    protected Object internalCreate(boolean lazyRefAllowed) throws ConstructionException
{
+    protected Object internalCreate() throws ComponentDefinitionException {
         try {
             Type type = Object.class;
             if (this.type instanceof Type) {
@@ -51,7 +52,7 @@
             }
             return convert(value.getStringValue(), type);
         } catch (Exception e) {            
-            throw new ConstructionException(e);
+            throw new ComponentDefinitionException(e);
         }
     }
 



Mime
View raw message