geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r766935 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context: Instanciator.java ModuleContextImpl.java Parser.java
Date Tue, 21 Apr 2009 00:55:13 GMT
Author: gawor
Date: Tue Apr 21 00:55:12 2009
New Revision: 766935

URL: http://svn.apache.org/viewvc?rev=766935&view=rev
Log:
support for lazy instantiation

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ModuleContextImpl.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java

Modified: 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/Instanciator.java?rev=766935&r1=766934&r2=766935&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/Instanciator.java
Tue Apr 21 00:55:12 2009
@@ -220,7 +220,6 @@
             recipe.setDestroyMethod(method);
         }
         // TODO: constructor args
-        // TODO: lazy
         // TODO: factory-method
         // TODO: factory-component
         return recipe;

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ModuleContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ModuleContextImpl.java?rev=766935&r1=766934&r2=766935&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ModuleContextImpl.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/ModuleContextImpl.java
Tue Apr 21 00:55:12 2009
@@ -113,9 +113,8 @@
 
             registerTypeConverters();
 
-            // TODO: handle scopes and such
-            Map instances = objectGraph.createAll(new ArrayList<String>(componentDefinitionRegistry.getComponentDefinitionNames()));
-            //System.out.println(instances);
+            instantiateComponents();
+
             // TODO: access to any OSGi reference proxy is currently a problem at this point,
because calling toString() will
             // TODO:      wait for a service to be available.  We may need to catch toString(),
equals() and hashCode() and make them
             // TODO:      work even if there's no service available.
@@ -143,7 +142,7 @@
     private void registerTypeConverters() {
         List<String> typeConvertersNames = componentDefinitionRegistry.getTypeConverterNames();
         Map<String, Object> typeConverters = objectGraph.createAll(typeConvertersNames);
-        System.out.println(typeConverters);
+        System.out.println("Type converters: " + typeConverters);
         for (String name : typeConvertersNames) {
             Object typeConverterInstance = typeConverters.get(name);
             if (typeConverterInstance instanceof Converter) {
@@ -155,6 +154,24 @@
         }
     }
     
+    private void instantiateComponents() {
+        List<String> components = new ArrayList<String>();
+        for (String name : componentDefinitionRegistry.getComponentDefinitionNames()) {
+            ComponentMetadata component = componentDefinitionRegistry.getComponentDefinition(name);
+            if (component instanceof LocalComponentMetadata) {
+                LocalComponentMetadata local = (LocalComponentMetadata) component;
+                String scope = local.getScope();
+                if (!local.isLazy() && 
+                    (LocalComponentMetadata.SCOPE_BUNDLE.equals(scope) || 
+                     LocalComponentMetadata.SCOPE_SINGLETON.equals(scope))) {
+                    components.add(name);
+                }
+            }
+        }
+        Map instances = objectGraph.createAll(components);
+        System.out.println("Component instances: " + instances);
+    }
+    
     private void registerAllServices() {
         for (ServiceExportComponentMetadata service : getExportedServicesMetadata()) {
             ServiceRegistrationProxy proxy = (ServiceRegistrationProxy) getComponent(service.getName());

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java?rev=766935&r1=766934&r2=766935&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Parser.java
Tue Apr 21 00:55:12 2009
@@ -71,6 +71,7 @@
 import org.osgi.service.blueprint.reflect.CollectionBasedServiceReferenceComponentMetadata;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.blueprint.reflect.ListValue;
+import org.osgi.service.blueprint.reflect.LocalComponentMetadata;
 import org.osgi.service.blueprint.reflect.MapValue;
 import org.osgi.service.blueprint.reflect.NullValue;
 import org.osgi.service.blueprint.reflect.PropertiesValue;
@@ -364,6 +365,8 @@
         }
         if (element.hasAttribute(SCOPE_ATTRIBUTE)) {
             metadata.setScope(element.getAttribute(SCOPE_ATTRIBUTE));
+        } else {
+            metadata.setScope(LocalComponentMetadata.SCOPE_SINGLETON);
         }
         String lazy = element.hasAttribute(LAZY_INIT_ATTRIBUTE) ? element.getAttribute(LAZY_INIT_ATTRIBUTE)
: defaultLazyInit;
         if (BOOLEAN_DEFAULT.equals(lazy)) {



Mime
View raw message