geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r794737 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint: container/ reflect/
Date Thu, 16 Jul 2009 16:30:39 GMT
Author: gawor
Date: Thu Jul 16 16:30:38 2009
New Revision: 794737

URL: http://svn.apache.org/viewvc?rev=794737&view=rev
Log:
beanMetadata.getScope() should return null when scope attribute not explicitly specified in
xml

Modified:
    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/ServiceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/BeanMetadataImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java

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=794737&r1=794736&r2=794737&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
Thu Jul 16 16:30:38 2009
@@ -44,6 +44,7 @@
 import org.apache.geronimo.blueprint.NamespaceHandler;
 import org.apache.geronimo.blueprint.Processor;
 import org.apache.geronimo.blueprint.reflect.EnvironmentMetadataImpl;
+import org.apache.geronimo.blueprint.reflect.MetadataUtil;
 import org.apache.geronimo.blueprint.di.Recipe;
 import org.apache.geronimo.blueprint.di.Repository;
 import org.apache.geronimo.blueprint.namespace.ComponentDefinitionRegistryImpl;
@@ -506,8 +507,7 @@
             boolean eager = component.getActivation() == ComponentMetadata.ACTIVATION_EAGER;
             if (component instanceof BeanMetadata) {
                 BeanMetadata local = (BeanMetadata) component;
-                String scope = local.getScope();
-                eager &= BeanMetadata.SCOPE_SINGLETON.equals(scope);
+                eager &= MetadataUtil.isSingletonScope(local);
             }
             if (eager) {
                 components.add(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=794737&r1=794736&r2=794737&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
Thu Jul 16 16:30:38 2009
@@ -437,11 +437,9 @@
                     metadata.setActivation(parseActivation(element));
                 }
             } else {
-                metadata.setScope(BeanMetadata.SCOPE_SINGLETON);
                 metadata.setActivation(parseActivation(element));
             }
         } else {
-            metadata.setScope(BeanMetadata.SCOPE_PROTOTYPE);
             metadata.setActivation(ComponentMetadata.ACTIVATION_LAZY);
         }
         if (element.hasAttribute(CLASS_ATTRIBUTE)) {
@@ -471,7 +469,7 @@
         if (metadata.getFactoryComponent() != null && metadata.getFactoryMethod()
== null) {
             throw new ComponentDefinitionException("factory-method is required when factory-component
is set");
         }
-        if (metadata.getScope().equals(BeanMetadata.SCOPE_PROTOTYPE) && metadata.getDestroyMethod()
!= null) {
+        if (MetadataUtil.isPrototypeScope(metadata) && metadata.getDestroyMethod()
!= null) {
             throw new ComponentDefinitionException("destroy-method must not be set for a
<bean> with a prototype scope");
         }
 

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=794737&r1=794736&r2=794737&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
Thu Jul 16 16:30:38 2009
@@ -205,9 +205,7 @@
             deps.add(new RefRecipe(getName(null), name));
         }
         recipe.setExplicitDependencies(deps);
-        if (!BeanMetadata.SCOPE_PROTOTYPE.equals(beanMetadata.getScope())) {
-            recipe.setPrototype(false);
-        }
+        recipe.setPrototype(MetadataUtil.isPrototypeScope(beanMetadata));
         recipe.setInitMethod(beanMetadata.getInitMethod());
         recipe.setDestroyMethod(beanMetadata.getDestroyMethod());
         List<BeanArgument> beanArguments = beanMetadata.getArguments();

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=794737&r1=794736&r2=794737&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
Thu Jul 16 16:30:38 2009
@@ -35,6 +35,7 @@
 import org.apache.geronimo.blueprint.di.Recipe;
 import org.apache.geronimo.blueprint.di.RefRecipe;
 import org.apache.geronimo.blueprint.di.Repository;
+import org.apache.geronimo.blueprint.reflect.MetadataUtil;
 import org.apache.geronimo.blueprint.utils.JavaUtils;
 import org.apache.geronimo.blueprint.utils.ReflectionUtils;
 import org.osgi.framework.Bundle;
@@ -363,7 +364,7 @@
         }
         if (metadata instanceof BeanMetadata) {
             BeanMetadata bean = (BeanMetadata) metadata;
-            return BeanMetadata.SCOPE_PROTOTYPE.equals(bean.getScope());
+            return MetadataUtil.isPrototypeScope(bean);
         } else {
             return false;
         }

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/BeanMetadataImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/BeanMetadataImpl.java?rev=794737&r1=794736&r2=794737&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/BeanMetadataImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/BeanMetadataImpl.java
Thu Jul 16 16:30:38 2009
@@ -51,7 +51,6 @@
     private boolean processor;
 
     public BeanMetadataImpl() {
-        scope = SCOPE_SINGLETON;
     }
 
     public BeanMetadataImpl(BeanMetadata source) {

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java?rev=794737&r1=794736&r2=794737&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/reflect/MetadataUtil.java
Thu Jul 16 16:30:38 2009
@@ -185,11 +185,21 @@
         return arguments;
     }
     
+    public static boolean isPrototypeScope(BeanMetadata metadata) {
+        return (BeanMetadata.SCOPE_PROTOTYPE.equals(metadata.getScope()) || 
+                (metadata.getScope() == null && metadata.getId() == null));
+    }
+    
+    public static boolean isSingletonScope(BeanMetadata metadata) {
+        return (BeanMetadata.SCOPE_SINGLETON.equals(metadata.getScope())  ||
+                (metadata.getScope() == null && metadata.getId() != null));
+    }
+    
     private static class BeanArgumentComparator implements Comparator<BeanArgument>,
Serializable {
         public int compare(BeanArgument object1, BeanArgument object2) {
             return object1.getIndex() - object2.getIndex();
         }        
     }
-        
+       
 }
 



Mime
View raw message