geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r770887 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context: BlueprintContextImpl.java Instanciator.java Parser.java
Date Sat, 02 May 2009 02:52:02 GMT
Author: gawor
Date: Sat May  2 02:52:01 2009
New Revision: 770887

URL: http://svn.apache.org/viewvc?rev=770887&view=rev
Log:
inner components should not have names but our recipes will

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/Instanciator.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/BlueprintContextImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/BlueprintContextImpl.java?rev=770887&r1=770886&r2=770887&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
Sat May  2 02:52:01 2009
@@ -193,8 +193,10 @@
                     case WaitForInitialReferences:
                         if (checkAllSatisfiables()) {
                             state = State.InitialReferencesSatisfied;
+                            break;
+                        } else {
+                            return;
                         }
-                        return;
                     case InitialReferencesSatisfied:
                         instantiateComponents();
                         registerAllServices();

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=770887&r1=770886&r2=770887&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
Sat May  2 02:52:01 2009
@@ -80,6 +80,7 @@
         primitiveClasses.put("boolean", boolean.class);
     }
     
+    private int nameCounter;
     private BlueprintContextImpl blueprintContext;
     private ExtendedComponentDefinitionRegistry registry;
 
@@ -143,7 +144,7 @@
                                                                    metadata,
                                                                    listenersRecipe,
                                                                    comparatorRecipe);
-        recipe.setName(metadata.getId());
+        recipe.setName(getName(metadata.getId()));
         return recipe;
     }
 
@@ -159,14 +160,14 @@
                                                                    blueprintContext.getSender(),
                                                                    metadata,
                                                                    listenersRecipe);
-        recipe.setName(metadata.getId());
+        recipe.setName(getName(metadata.getId()));
         return recipe;
     }
 
     private ObjectRecipe createServiceRecipe(ServiceMetadata serviceExport) throws Exception
{
         BlueprintObjectRecipe recipe = new BlueprintObjectRecipe(blueprintContext, ServiceRegistrationProxy.class);
         recipe.allow(Option.PRIVATE_PROPERTIES);
-        recipe.setName(serviceExport.getId());
+        recipe.setName(getName(serviceExport.getId()));
         recipe.setExplicitDependencies(serviceExport.getExplicitDependencies());
         recipe.setProperty("blueprintContext", blueprintContext);
         BeanMetadata exportedComponent = getLocalServiceComponent(serviceExport.getServiceComponent());
@@ -197,9 +198,7 @@
     private BlueprintObjectRecipe createBeanRecipe(BeanMetadata local) throws Exception {
         Class clazz = local.getRuntimeClass() != null ? local.getRuntimeClass() : loadClass(local.getClassName());
         BlueprintObjectRecipe recipe = new BlueprintObjectRecipe(blueprintContext, clazz);
-        if (local.getId() != null) {
-            recipe.setName(local.getId());
-        }
+        recipe.setName(getName(local.getId()));
         recipe.setExplicitDependencies(local.getExplicitDependencies());
         for (BeanProperty property : local.getProperties()) {
             Object value = getValue(property.getValue(), null);
@@ -330,6 +329,14 @@
         return loadClass(blueprintContext, typeName);
     }
     
+    private String getName(String name) {
+        if (name == null) {
+            return "recipe-" + ++nameCounter;
+        } else {
+            return name;
+        }
+    }
+        
     public static Class loadClass(BlueprintContextImpl context, String typeName) throws ClassNotFoundException
{
         if (typeName == null) {
             return null;
@@ -346,5 +353,5 @@
         }
         return clazz;
     }
-                  
+            
 }

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=770887&r1=770886&r2=770887&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
Sat May  2 02:52:01 2009
@@ -406,21 +406,21 @@
         } else if (nodeNameEquals(element, TYPE_CONVERTERS_ELEMENT)) {
             parseTypeConverters(element);
         } else if (nodeNameEquals(element, BEAN_ELEMENT)) {
-            ComponentMetadata component = parseBeanMetadata(element);
+            ComponentMetadata component = parseBeanMetadata(element, true);
             registry.registerComponentDefinition(component);
         } else if (nodeNameEquals(element, REF_ELEMENT)) {
             // TODO: what about those top-level refs elements
         } else if (nodeNameEquals(element, SERVICE_ELEMENT)) {
-            ComponentMetadata service = parseService(element);
+            ComponentMetadata service = parseService(element, true);
             registry.registerComponentDefinition(service);
         } else if (nodeNameEquals(element, REFERENCE_ELEMENT)) {
-            ComponentMetadata reference = parseReference(element);
+            ComponentMetadata reference = parseReference(element, true);
             registry.registerComponentDefinition(reference);
         } else if (nodeNameEquals(element, REFLIST_ELEMENT) ) {
-            ComponentMetadata references = parseRefCollection(element, List.class);
+            ComponentMetadata references = parseRefCollection(element, List.class, true);
             registry.registerComponentDefinition(references);
         } else if (nodeNameEquals(element, REFSET_ELEMENT)) {
-            ComponentMetadata references = parseRefCollection(element, Set.class);
+            ComponentMetadata references = parseRefCollection(element, Set.class, true);
             registry.registerComponentDefinition(references);
         } else {
             throw new ComponentDefinitionException("Unknown element " + element.getNodeName()
+ " in namespace " + BLUEPRINT_NAMESPACE);
@@ -445,9 +445,11 @@
         }
     }
 
-    private ComponentMetadata parseBeanMetadata(Element element) {
+    private ComponentMetadata parseBeanMetadata(Element element, boolean topElement) {
         BeanMetadataImpl metadata = new BeanMetadataImpl();
-        metadata.setId(getName(element));
+        if (topElement) {
+            metadata.setId(getName(element));
+        }
         if (element.hasAttribute(CLASS_ATTRIBUTE)) {
             metadata.setClassName(element.getAttribute(CLASS_ATTRIBUTE));
         }
@@ -536,10 +538,12 @@
         return new BeanArgumentImpl(value, type, index);
     }
 
-    private ComponentMetadata parseService(Element element) {
+    private ComponentMetadata parseService(Element element, boolean topElement) {
         ServiceMetadataImpl service = new ServiceMetadataImpl();
         boolean hasInterfaceNameAttribute = false;
-        service.setId(getName(element));
+        if (topElement) {
+            service.setId(getName(element));
+        }
         if (element.hasAttribute(INTERFACE_ATTRIBUTE)) {
             service.setInterfaceNames(Collections.singletonList(element.getAttribute(INTERFACE_ATTRIBUTE)));
             hasInterfaceNameAttribute = true;
@@ -588,7 +592,7 @@
                         if (service.getServiceComponent() != null) {
                             throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE
+ " attribute, " + BEAN_ELEMENT + " element or custom inner element can be set");
                         }
-                        service.setServiceComponent((Target) parseBeanMetadata(e));
+                        service.setServiceComponent((Target) parseBeanMetadata(e, false));
                     } else {
                         // TODO: can be ref, reference or a custom element
                     }
@@ -759,11 +763,11 @@
                     }
                     listenerComponent = new RefMetadataImpl(component);
                 } else if (nodeNameEquals(e, BEAN_ELEMENT)) {
-                    listenerComponent = parseBeanMetadata(e);
+                    listenerComponent = parseBeanMetadata(e, false);
                 } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) {
-                    listenerComponent = parseReference(e);
+                    listenerComponent = parseReference(e, false);
                 } else if (nodeNameEquals(e, SERVICE_ELEMENT)) {
-                    listenerComponent = parseService(e);
+                    listenerComponent = parseService(e, false);
                 }
             }
         }
@@ -785,9 +789,11 @@
         return listener;
     }
 
-    private ComponentMetadata parseReference(Element element) {
+    private ComponentMetadata parseReference(Element element, boolean topElement) {     
 
         ReferenceMetadataImpl reference = new ReferenceMetadataImpl();
-        reference.setId(getName(element));
+        if (topElement) {
+            reference.setId(getName(element));
+        }
         parseReference(element, reference);
         String timeout = element.hasAttribute(TIMEOUT_ATTRIBUTE) ? element.getAttribute(TIMEOUT_ATTRIBUTE)
: this.defaultTimeout;
         try {
@@ -804,9 +810,11 @@
         return r;
     }
 
-    private ComponentMetadata parseRefCollection(Element element, Class collectionType) {
+    private ComponentMetadata parseRefCollection(Element element, Class collectionType, boolean
topElement) {
         RefCollectionMetadataImpl references = new RefCollectionMetadataImpl();
-        references.setId(getName(element));
+        if (topElement) {
+            references.setId(getName(element));
+        }
         references.setCollectionType(collectionType);
 
         if (element.hasAttribute(COMPARATOR_REF_ATTRIBUTE)) {
@@ -868,11 +876,11 @@
                         }
                         comparator = new RefMetadataImpl(component);
                     } else if (nodeNameEquals(e, BEAN_ELEMENT)) {
-                        comparator = parseBeanMetadata(e);
+                        comparator = parseBeanMetadata(e, false);
                     } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) {
-                        comparator = parseReference(e);
+                        comparator = parseReference(e, false);
                     } else if (nodeNameEquals(e, SERVICE_ELEMENT)) {
-                        comparator = parseService(e);
+                        comparator = parseService(e, false);
                     }
                 } else {
                     comparator = parseCustomElement(e, references);
@@ -952,19 +960,19 @@
                         if (listener.getListenerComponent() != null) {
                             throw new ComponentDefinitionException("Attribute " + REF_ATTRIBUTE
+ " can not be set in addition to a child element");
                         }
-                        ComponentMetadata component = parseBeanMetadata(e);
+                        ComponentMetadata component = parseBeanMetadata(e, false);
                         listener.setListenerComponent((Target) component);
                     } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) {
                         if (listener.getListenerComponent() != null) {
                             throw new ComponentDefinitionException("Attribute " + REF_ATTRIBUTE
+ " can not be set in addition to a child element");
                         }
-                        ComponentMetadata reference = parseReference(e);
+                        ComponentMetadata reference = parseReference(e, false);
                         listener.setListenerComponent((Target) reference);
                     } else if (nodeNameEquals(e, SERVICE_ELEMENT)) {
                         if (listener.getListenerComponent() != null) {
                             throw new ComponentDefinitionException("Attribute " + REF_ATTRIBUTE
+ " can not be set in addition to a child element");
                         }
-                        ComponentMetadata service = parseService(e);
+                        ComponentMetadata service = parseService(e, false);
                         listener.setListenerComponent((Target) service);
                     }
                 } else {
@@ -1021,15 +1029,15 @@
     private Metadata parseValueElement(Element element, ComponentMetadata enclosingComponent,
boolean allowNull) {
         if (isBlueprintNamespace(element.getNamespaceURI())) {
             if (nodeNameEquals(element, BEAN_ELEMENT)) {
-                return parseBeanMetadata(element);
+                return parseBeanMetadata(element, false);
             } else if (nodeNameEquals(element, REFERENCE_ELEMENT)) {
-                return parseReference(element);
+                return parseReference(element, false);
             } else if (nodeNameEquals(element, SERVICE_ELEMENT)) {
-                return parseService(element);
+                return parseService(element, false);
             } else if (nodeNameEquals(element, REFLIST_ELEMENT) ) {
-                return parseRefCollection(element, List.class);
+                return parseRefCollection(element, List.class, false);
             } else if (nodeNameEquals(element, REFSET_ELEMENT)) {
-                return parseRefCollection(element, Set.class);
+                return parseRefCollection(element, Set.class, false);
             } else if (nodeNameEquals(element, NULL_ELEMENT) && allowNull) {
                 return NullMetadata.NULL;
             } else if (nodeNameEquals(element, VALUE_ELEMENT)) {



Mime
View raw message