geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r767490 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java
Date Wed, 22 Apr 2009 12:36:59 GMT
Author: gnodet
Date: Wed Apr 22 12:36:59 2009
New Revision: 767490

URL: http://svn.apache.org/viewvc?rev=767490&view=rev
Log:
Extract methods for recipe creation

Modified:
    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/Instanciator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/Instanciator.java?rev=767490&r1=767489&r2=767490&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
Wed Apr 22 12:36:59 2009
@@ -133,46 +133,54 @@
         } else if (component instanceof ServiceExportComponentMetadata) {
             return createServiceRecipe( (ServiceExportComponentMetadata) component);
         } else if (component instanceof UnaryServiceReferenceComponentMetadata) {
-            UnaryServiceReferenceComponentMetadata metadata = (UnaryServiceReferenceComponentMetadata)
component;
-            CollectionRecipe listenersRecipe = null;
-            if (metadata.getBindingListeners() != null) {
-                listenersRecipe = new CollectionRecipe(ArrayList.class);
-                for (BindingListenerMetadata listener : (Collection<BindingListenerMetadata>)
metadata.getBindingListeners()) {
-                    listenersRecipe.add(createRecipe(listener));
-                }
-            }
-            UnaryServiceReferenceRecipe recipe = new UnaryServiceReferenceRecipe(moduleContext,
-                                                                       moduleContext.getSender(),
-                                                                       metadata,
-                                                                       listenersRecipe);
-            recipe.setName(component.getName());
-            return recipe;
+            return createUnaryServiceReferenceRecipe(component);
         } else if (component instanceof CollectionBasedServiceReferenceComponentMetadata)
{
-            CollectionBasedServiceReferenceComponentMetadata metadata = (CollectionBasedServiceReferenceComponentMetadata)
component;
-            CollectionRecipe listenersRecipe = null;
-            if (metadata.getBindingListeners() != null) {
-                listenersRecipe = new CollectionRecipe(ArrayList.class);
-                for (BindingListenerMetadata listener : (Collection<BindingListenerMetadata>)
metadata.getBindingListeners()) {
-                    listenersRecipe.add(createRecipe(listener));
-                }
-            }
-            Recipe comparatorRecipe = null;
-            if (metadata.getComparator() != null) {
-                comparatorRecipe = (Recipe) getValue(metadata.getComparator(), Comparator.class);
-            }
-            CollectionBasedServiceReferenceRecipe recipe = new CollectionBasedServiceReferenceRecipe(
-                                                                       moduleContext,
-                                                                       moduleContext.getSender(),
-                                                                       metadata,
-                                                                       listenersRecipe,
-                                                                       comparatorRecipe);
-            recipe.setName(component.getName());
-            return recipe;
+            return createCollectionBasedServiceReferenceRecipe(component);
         } else {
             throw new IllegalStateException("Unsupported component type " + component.getClass());
         }
     }
 
+    private Recipe createCollectionBasedServiceReferenceRecipe(ComponentMetadata component)
throws Exception {
+        CollectionBasedServiceReferenceComponentMetadata metadata = (CollectionBasedServiceReferenceComponentMetadata)
component;
+        CollectionRecipe listenersRecipe = null;
+        if (metadata.getBindingListeners() != null) {
+            listenersRecipe = new CollectionRecipe(ArrayList.class);
+            for (BindingListenerMetadata listener : (Collection<BindingListenerMetadata>)
metadata.getBindingListeners()) {
+                listenersRecipe.add(createRecipe(listener));
+            }
+        }
+        Recipe comparatorRecipe = null;
+        if (metadata.getComparator() != null) {
+            comparatorRecipe = (Recipe) getValue(metadata.getComparator(), Comparator.class);
+        }
+        CollectionBasedServiceReferenceRecipe recipe = new CollectionBasedServiceReferenceRecipe(
+                                                                   moduleContext,
+                                                                   moduleContext.getSender(),
+                                                                   metadata,
+                                                                   listenersRecipe,
+                                                                   comparatorRecipe);
+        recipe.setName(component.getName());
+        return recipe;
+    }
+
+    private UnaryServiceReferenceRecipe createUnaryServiceReferenceRecipe(ComponentMetadata
component) throws Exception {
+        UnaryServiceReferenceComponentMetadata metadata = (UnaryServiceReferenceComponentMetadata)
component;
+        CollectionRecipe listenersRecipe = null;
+        if (metadata.getBindingListeners() != null) {
+            listenersRecipe = new CollectionRecipe(ArrayList.class);
+            for (BindingListenerMetadata listener : (Collection<BindingListenerMetadata>)
metadata.getBindingListeners()) {
+                listenersRecipe.add(createRecipe(listener));
+            }
+        }
+        UnaryServiceReferenceRecipe recipe = new UnaryServiceReferenceRecipe(moduleContext,
+                                                                   moduleContext.getSender(),
+                                                                   metadata,
+                                                                   listenersRecipe);
+        recipe.setName(component.getName());
+        return recipe;
+    }
+
     private ObjectRecipe createServiceRecipe(ServiceExportComponentMetadata serviceExport)
throws Exception {
         ObjectRecipe recipe = new ObjectRecipe(ServiceRegistrationProxy.class);
         recipe.allow(Option.PRIVATE_PROPERTIES);



Mime
View raw message