You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/06/18 16:45:04 UTC

svn commit: r786091 - in /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container: AbstractServiceReferenceRecipe.java Parser.java

Author: gnodet
Date: Thu Jun 18 14:45:03 2009
New Revision: 786091

URL: http://svn.apache.org/viewvc?rev=786091&view=rev
Log:
Allow custom attributes on the <blueprint/> element, and fix a class loader problem when creating proxies

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/Parser.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java?rev=786091&r1=786090&r2=786091&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/AbstractServiceReferenceRecipe.java Thu Jun 18 14:45:03 2009
@@ -21,6 +21,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -40,8 +41,11 @@
 import org.apache.geronimo.blueprint.ExtendedServiceReferenceMetadata;
 import org.apache.geronimo.blueprint.di.AbstractRecipe;
 import org.apache.geronimo.blueprint.di.Recipe;
+import org.apache.geronimo.blueprint.di.ExecutionContext;
 import org.apache.geronimo.blueprint.utils.BundleDelegatingClassLoader;
 import org.apache.geronimo.blueprint.utils.ReflectionUtils;
+import org.apache.geronimo.blueprint.utils.TypeUtils;
+import static org.apache.geronimo.blueprint.utils.TypeUtils.toClass;
 import org.osgi.framework.Constants;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
@@ -191,6 +195,22 @@
         return classes;
     }
 
+    protected Type loadType(String typeName, ClassLoader fromClassLoader) {
+        if (typeName == null) {
+            return null;
+        }
+        try {
+            // this method is overriden to use the blueprint container directly
+            // because proxies can be created outside of the recipe creation which
+            // would lead to an exception because the context is not set
+            // TODO: consider having the context as a property on the recipe rather than a thread local
+            return TypeUtils.parseJavaType(typeName, fromClassLoader != null ? fromClassLoader : blueprintContainer);
+        } catch (ClassNotFoundException e) {
+            throw new ComponentDefinitionException("Unable to load class " + typeName + " from recipe " + this, e);
+        }
+    }
+
+
     protected Object createProxy(final Callable<Object> dispatcher, Iterable<String> interfaces) throws Exception {
         return getProxyFactory().createProxy(proxyClassLoader, toClassArray(loadAllClasses(interfaces)), dispatcher);
     }

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=786091&r1=786090&r2=786091&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 Jun 18 14:45:03 2009
@@ -360,21 +360,20 @@
             }
         }
 
-        /*
-        TODO: uncomment this part as the <blueprint/> element can have custom attributes
         // Parse custom attributes
         NamedNodeMap attributes = root.getAttributes();
         if (attributes != null) {
             for (int i = 0; i < attributes.getLength(); i++) {
                 Node node = attributes.item(i);
-                if (node instanceof Attr && 
-                    node.getNamespaceURI() != null && 
-                    !isBlueprintNamespace(node.getNamespaceURI())) {
+                if (node instanceof Attr
+                        && node.getNamespaceURI() != null
+                        && !isBlueprintNamespace(node.getNamespaceURI())
+                        && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(node.getNamespaceURI())
+                        && XMLConstants.XMLNS_ATTRIBUTE.equals(node.getNodeName())) {
                     decorateCustomNode(node, null);
                 }
             }
         }
-        */
 
         // Parse elements
         NodeList nl = root.getChildNodes();