You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/05/11 05:01:39 UTC
svn commit: r773454 -
/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
Author: gawor
Date: Mon May 11 03:01:39 2009
New Revision: 773454
URL: http://svn.apache.org/viewvc?rev=773454&view=rev
Log:
handle Collection<ServiceReference> injection
Modified:
geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java?rev=773454&r1=773453&r2=773454&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/context/CollectionBasedServiceReferenceRecipe.java Mon May 11 03:01:39 2009
@@ -43,6 +43,7 @@
import org.apache.xbean.recipe.ConstructionException;
import org.apache.xbean.recipe.ExecutionContext;
import org.apache.xbean.recipe.Recipe;
+import org.apache.xbean.recipe.RecipeHelper;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.blueprint.context.BlueprintContext;
@@ -84,7 +85,7 @@
comparator = new NaturalOrderComparator();
}
boolean orderReferences = metadata.getOrderingBasis() == RefCollectionMetadata.ORDERING_BASIS_SERVICE_REFERENCE;
- boolean memberReferences = metadata.getMemberType() == RefCollectionMetadata.MEMBER_TYPE_SERVICE_REFERENCE;
+ boolean memberReferences = isReferenceCollection(expectedType) || metadata.getMemberType() == RefCollectionMetadata.MEMBER_TYPE_SERVICE_REFERENCE;
if (metadata.getCollectionType() == List.class) {
if (comparator != null) {
collection = new ManagedSortedList(memberReferences, orderReferences, comparator);
@@ -119,6 +120,20 @@
}
}
+ private boolean isReferenceCollection(Type expectedType) {
+ Class componentType = getComponentType(expectedType);
+ return ServiceReference.class.equals(componentType);
+ }
+
+ private Class getComponentType(Type expectedType) {
+ Type[] typeParameters = RecipeHelper.getTypeParameters(Collection.class, expectedType);
+ Class componentType = Object.class;
+ if (typeParameters != null && typeParameters.length == 1 && typeParameters[0] instanceof Class) {
+ componentType = (Class) typeParameters[0];
+ }
+ return componentType;
+ }
+
public void stop() {
super.stop();
List<ServiceDispatcher> dispatchers = new ArrayList<ServiceDispatcher>(collection.getDispatchers());