aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1550780 - in /aries/trunk/blueprint: blueprint-core/ blueprint-core/src/main/java/org/apache/aries/blueprint/ blueprint-core/src/main/java/org/apache/aries/blueprint/container/ blueprint-core/src/main/java/org/apache/aries/blueprint/ext/im...
Date Fri, 13 Dec 2013 17:39:50 GMT
Author: dkulp
Date: Fri Dec 13 17:39:50 2013
New Revision: 1550780

URL: http://svn.apache.org/r1550780
Log:
[ARIES-1141] Allow additional interfaces for <reference> 
Pass one for review.  Testing required.

Added:
    aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd
  (with props)
Modified:
    aries/trunk/blueprint/blueprint-core/pom.xml
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
    aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/packageinfo
    aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/ExtendedReferenceMetadata.java
    aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/MutableReferenceMetadata.java
    aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/packageinfo
    aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/packageinfo
    aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java

Modified: aries/trunk/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/pom.xml?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/pom.xml (original)
+++ aries/trunk/blueprint/blueprint-core/pom.xml Fri Dec 13 17:39:50 2013
@@ -88,7 +88,7 @@
 
         <blueprint.annotation.api.version>1.0.0</blueprint.annotation.api.version>
         <blueprint.api.version>1.0.0</blueprint.api.version>
-        <blueprint.parser.version>1.1.0</blueprint.parser.version>
+        <blueprint.parser.version>1.1.1-SNAPSHOT</blueprint.parser.version>
         <proxy.api.version>1.0.0</proxy.api.version>
         <proxy.impl.version>1.0.0</proxy.impl.version>
         <quiesce.api.version>1.0.0</quiesce.api.version>

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/AbstractServiceReferenceRecipe.java
Fri Dec 13 17:39:50 2013
@@ -38,6 +38,7 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.aries.blueprint.BlueprintConstants;
+import org.apache.aries.blueprint.ExtendedReferenceMetadata;
 import org.apache.aries.blueprint.ExtendedServiceReferenceMetadata;
 import org.apache.aries.blueprint.di.AbstractRecipe;
 import org.apache.aries.blueprint.di.CollectionRecipe;
@@ -626,7 +627,22 @@ public abstract class AbstractServiceRef
             interfaceName = runtimeClass.getName();
         }
         if (interfaceName != null && interfaceName.length() > 0) {
-            members.add("(" + Constants.OBJECTCLASS + "=" + interfaceName + ")");
+            if (metadata instanceof ExtendedReferenceMetadata) {
+                ExtendedReferenceMetadata erm = (ExtendedReferenceMetadata)metadata;
+                if (!erm.getExtraInterfaces().isEmpty()) {
+                    StringBuilder sb = new StringBuilder("(&");
+                    sb.append("(" + Constants.OBJECTCLASS + "=" + interfaceName + ")");
+                    for (String s : erm.getExtraInterfaces()) {
+                        sb.append("(" + Constants.OBJECTCLASS + "=" + s + ")");         
              
+                    }
+                    sb.append(")");
+                    members.add(sb.toString());
+                } else {
+                    members.add("(" + Constants.OBJECTCLASS + "=" + interfaceName + ")");
                   
+                }
+            } else {
+                members.add("(" + Constants.OBJECTCLASS + "=" + interfaceName + ")");
+            }
         }
         // Handle component name
         String componentName = metadata.getComponentName();

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/ReferenceRecipe.java
Fri Dec 13 17:39:50 2013
@@ -98,6 +98,10 @@ public class ReferenceRecipe extends Abs
             Set<Class<?>> interfaces = new HashSet<Class<?>>();
             Class<?> clz = getInterfaceClass();
             if (clz != null) interfaces.add(clz);
+            
+            if (metadata instanceof ExtendedReferenceMetadata) {
+                interfaces.addAll(loadAllClasses(((ExtendedReferenceMetadata)metadata).getExtraInterfaces()));
+            }
 
             proxy = createProxy(new ServiceDispatcher(), interfaces);
 

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
Fri Dec 13 17:39:50 2013
@@ -74,6 +74,7 @@ public class ExtNamespaceHandler impleme
     public static final String BLUEPRINT_EXT_NAMESPACE_V1_1 = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.1.0";
     public static final String BLUEPRINT_EXT_NAMESPACE_V1_2 = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0";
     public static final String BLUEPRINT_EXT_NAMESPACE_V1_3 = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0";
+    public static final String BLUEPRINT_EXT_NAMESPACE_V1_4 = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.4.0";
 
     public static final String PROPERTY_PLACEHOLDER_ELEMENT = "property-placeholder";
     public static final String DEFAULT_PROPERTIES_ELEMENT = "default-properties";
@@ -106,6 +107,9 @@ public class ExtNamespaceHandler impleme
     public static final String DEFAULT_REFERENCE_BEAN = "default";
 
     public static final String FILTER_ATTRIBUTE = "filter";
+    
+    public static final String ADDITIONAL_INTERFACES = "additional-interfaces";
+    public static final String INTERFACE = "interface";
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ExtNamespaceHandler.class);
 
@@ -126,11 +130,20 @@ public class ExtNamespaceHandler impleme
           return getClass().getResource("blueprint-ext-1.2.xsd");
         } else if (BLUEPRINT_EXT_NAMESPACE_V1_3.equals(namespace)) {
             return getClass().getResource("blueprint-ext-1.3.xsd");
+        } else if (BLUEPRINT_EXT_NAMESPACE_V1_4.equals(namespace)) {
+            return getClass().getResource("blueprint-ext-1.4.xsd");
         } else if ("http://www.w3.org/XML/1998/namespace".equals(namespace)) {
             return getClass().getResource("xml.xsd");
         }
         return null;
     }
+    public boolean isExtNamespace(String e) {
+        return BLUEPRINT_EXT_NAMESPACE_V1_0.equals(e)
+            || BLUEPRINT_EXT_NAMESPACE_V1_1.equals(e)
+            || BLUEPRINT_EXT_NAMESPACE_V1_2.equals(e)
+            || BLUEPRINT_EXT_NAMESPACE_V1_3.equals(e)
+            || BLUEPRINT_EXT_NAMESPACE_V1_4.equals(e);            
+    }
 
     public Set<Class> getManagedClasses() {
         return new HashSet<Class>(Arrays.asList(
@@ -158,11 +171,31 @@ public class ExtNamespaceHandler impleme
             return decorateDefaultBean(node, component, context);
         } else if (node instanceof Attr && nodeNameEquals(node, FILTER_ATTRIBUTE))
{
             return decorateFilter(node, component, context);
+        } else if (node instanceof Element && nodeNameEquals(node, ADDITIONAL_INTERFACES))
{
+            return decorateAdditionalInterfaces(node, component, context);
         } else {
             throw new ComponentDefinitionException("Unsupported node: " + node.getNodeName());
         }
     }
     
+    private ComponentMetadata decorateAdditionalInterfaces(Node node, ComponentMetadata component,
+                                                           ParserContext context) {
+        if (!(component instanceof MutableReferenceMetadata)) {
+            throw new ComponentDefinitionException("Expected an instanceof MutableReferenceMetadata");
+        }
+        MutableReferenceMetadata mrm = (MutableReferenceMetadata)component;
+        List<String> list = new ArrayList<String>();
+        Node nd = node.getFirstChild();
+        while (nd != null) {
+            if (node instanceof Element && nodeNameEquals(node, INTERFACE)) {
+                list.add(((Element)nd).getNodeValue());
+            }
+            nd = nd.getNextSibling();
+        }
+        mrm.setExtraInterfaces(list);
+        return component;
+    }
+
     private ComponentMetadata decorateDefaultBean(Node node,
         ComponentMetadata component, ParserContext context) 
     {
@@ -296,10 +329,7 @@ public class ExtNamespaceHandler impleme
             Node node = nl.item(i);
             if (node instanceof Element) {
                 Element e = (Element) node;
-                if (BLUEPRINT_EXT_NAMESPACE_V1_0.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_1.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_2.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_3.equals(e.getNamespaceURI())) {
+                if (isExtNamespace(e.getNamespaceURI())) {
                     if (nodeNameEquals(e, DEFAULT_PROPERTIES_ELEMENT)) {
                         if (defaultsRef != null) {
                             throw new ComponentDefinitionException("Only one of " + DEFAULTS_REF_ATTRIBUTE
+ " attribute or " + DEFAULT_PROPERTIES_ELEMENT + " element is allowed");
@@ -328,10 +358,7 @@ public class ExtNamespaceHandler impleme
             Node node = nl.item(i);
             if (node instanceof Element) {
                 Element e = (Element) node;
-                if (BLUEPRINT_EXT_NAMESPACE_V1_0.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_1.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_2.equals(e.getNamespaceURI())
-                        || BLUEPRINT_EXT_NAMESPACE_V1_3.equals(e.getNamespaceURI())) {
+                if (isExtNamespace(e.getNamespaceURI())) {
                     if (nodeNameEquals(e, PROPERTY_ELEMENT)) {
                         BeanProperty prop = context.parseElement(BeanProperty.class, enclosingComponent,
e);
                         props.addEntry(createValue(context, prop.getName(), String.class.getName()),
prop.getValue());

Modified: aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/packageinfo?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/packageinfo
(original)
+++ aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/packageinfo
Fri Dec 13 17:39:50 2013
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 1.2.0
+version 1.3.0

Added: aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd?rev=1550780&view=auto
==============================================================================
Binary file - no diff available.

Propchange: aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.4.xsd
------------------------------------------------------------------------------
    svn:mime-type = application/xml

Modified: aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/ExtendedReferenceMetadata.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/ExtendedReferenceMetadata.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/ExtendedReferenceMetadata.java
(original)
+++ aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/ExtendedReferenceMetadata.java
Fri Dec 13 17:39:50 2013
@@ -27,4 +27,6 @@ public interface ExtendedReferenceMetada
     public String getDefaultBean();
     
     public Collection<Class<?>> getProxyChildBeanClasses();
+    
+    public Collection<String> getExtraInterfaces();
 }
\ No newline at end of file

Modified: aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/MutableReferenceMetadata.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/MutableReferenceMetadata.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/MutableReferenceMetadata.java
(original)
+++ aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/MutableReferenceMetadata.java
Fri Dec 13 17:39:50 2013
@@ -35,4 +35,5 @@ public interface MutableReferenceMetadat
     
     void setProxyChildBeanClasses(Collection<Class<?>> classes);
 
+    void setExtraInterfaces(Collection<String> interfaces);
 }
\ No newline at end of file

Modified: aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/packageinfo?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/packageinfo
(original)
+++ aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/mutable/packageinfo
Fri Dec 13 17:39:50 2013
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 1.1.0
+version 1.2.0

Modified: aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/packageinfo
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/packageinfo?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/packageinfo
(original)
+++ aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/packageinfo
Fri Dec 13 17:39:50 2013
@@ -16,4 +16,4 @@
 # specific language governing permissions and limitations
 # under the License.
 #
-version 1.1.0
+version 1.2.0

Modified: aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java?rev=1550780&r1=1550779&r2=1550780&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java
(original)
+++ aries/trunk/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/reflect/ReferenceMetadataImpl.java
Fri Dec 13 17:39:50 2013
@@ -19,6 +19,7 @@
 package org.apache.aries.blueprint.reflect;
 
 import java.util.Collection;
+import java.util.Collections;
 
 import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
 import org.osgi.service.blueprint.reflect.ReferenceMetadata;
@@ -33,6 +34,7 @@ public class ReferenceMetadataImpl exten
     private long timeout;
     private String defaultBeanId;
     private Collection<Class<?>> proxyChildBeanClasses;
+    private Collection<String> extraInterfaces;
 
     public ReferenceMetadataImpl() {
     }
@@ -70,6 +72,7 @@ public class ReferenceMetadataImpl exten
                 ", filter='" + filter + '\'' +
                 ", referenceListeners=" + referenceListeners +
                 ", timeout=" + timeout +
+                ", additonalInterfaces=" + getExtraInterfaces() +
                 ']';
     }
 
@@ -80,4 +83,15 @@ public class ReferenceMetadataImpl exten
     public void setProxyChildBeanClasses(Collection<Class<?>> c) {
         proxyChildBeanClasses = c;
     }
+
+    public Collection<String> getExtraInterfaces() {
+        if (extraInterfaces == null) {
+            return Collections.emptyList();
+        }
+        return extraInterfaces;
+    }
+
+    public void setExtraInterfaces(Collection<String> interfaces) {
+        extraInterfaces = interfaces;
+    }
 }



Mime
View raw message