Author: dkulp
Date: Wed Feb  4 18:07:18 2015
New Revision: 1657355

URL: http://svn.apache.org/r1657355
Log:
[ARIES-1293] Allow bean and references in custom namespace handlers via the ext 
namespace

Added:
    
aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd
Modified:
    
aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/ext/impl/ExtNamespaceHandler.java
    
aries/trunk/blueprint/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml

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=1657355&r1=1657354&r2=1657355&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
 Wed Feb  4 18:07:18 2015
@@ -75,6 +75,7 @@ public class ExtNamespaceHandler impleme
     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 BLUEPRINT_EXT_NAMESPACE_V1_5 = 
"http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0";;
 
     public static final String PROPERTY_PLACEHOLDER_ELEMENT = 
"property-placeholder";
     public static final String DEFAULT_PROPERTIES_ELEMENT = 
"default-properties";
@@ -110,6 +111,10 @@ public class ExtNamespaceHandler impleme
     
     public static final String ADDITIONAL_INTERFACES = "additional-interfaces";
     public static final String INTERFACE_VALUE = "value";
+    
+    public static final String BEAN = "bean";
+    public static final String REFERENCE = "reference";
+    
 
     private static final Logger LOGGER = 
LoggerFactory.getLogger(ExtNamespaceHandler.class);
 
@@ -132,6 +137,8 @@ public class ExtNamespaceHandler impleme
             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 (BLUEPRINT_EXT_NAMESPACE_V1_5.equals(namespace)) {
+            return getClass().getResource("blueprint-ext-1.5.xsd");
         } else if ("http://www.w3.org/XML/1998/namespace".equals(namespace)) {
             return getClass().getResource("xml.xsd");
         }
@@ -142,7 +149,8 @@ public class ExtNamespaceHandler impleme
             || 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);            
+            || BLUEPRINT_EXT_NAMESPACE_V1_4.equals(e)
+            || BLUEPRINT_EXT_NAMESPACE_V1_5.equals(e);            
     }
 
     public Set<Class> getManagedClasses() {
@@ -155,6 +163,11 @@ public class ExtNamespaceHandler impleme
         LOGGER.debug("Parsing element {{}}{}", element.getNamespaceURI(), 
element.getLocalName());
         if (nodeNameEquals(element, PROPERTY_PLACEHOLDER_ELEMENT)) {
             return parsePropertyPlaceholder(context, element);
+        } else if (nodeNameEquals(element, BEAN)) {
+            return context.parseElement(BeanMetadata.class, 
context.getEnclosingComponent(), element);
+        } else if (nodeNameEquals(element, REFERENCE)) {
+            RefMetadata rd = context.parseElement(RefMetadata.class, 
context.getEnclosingComponent(), element);
+            return createReference(context, rd.getComponentId());
         } else {
             throw new ComponentDefinitionException("Unsupported element: " + 
element.getNodeName());
         }
@@ -173,6 +186,11 @@ public class ExtNamespaceHandler impleme
             return decorateFilter(node, component, context);
         } else if (node instanceof Element && nodeNameEquals(node, 
ADDITIONAL_INTERFACES)) {
             return decorateAdditionalInterfaces(node, component, context);
+        } else if (node instanceof Element && nodeNameEquals(node, BEAN)) {
+            return context.parseElement(BeanMetadata.class, component, 
(Element)node);
+        } else if (node instanceof Element && nodeNameEquals(node, REFERENCE)) 
{
+            RefMetadata rd = context.parseElement(RefMetadata.class, 
component, (Element)node);
+            return createReference(context, rd.getComponentId());
         } else {
             throw new ComponentDefinitionException("Unsupported node: " + 
node.getNodeName());
         }

Modified: 
aries/trunk/blueprint/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml?rev=1657355&r1=1657354&r2=1657355&view=diff
==============================================================================
--- 
aries/trunk/blueprint/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml
 (original)
+++ 
aries/trunk/blueprint/blueprint-core/src/main/resources/OSGI-INF/blueprint/blueprint-ext.xml
 Wed Feb  4 18:07:18 2015
@@ -47,6 +47,11 @@
             <entry key="osgi.service.blueprint.namespace" 
value="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.4.0"/>
         </service-properties>
     </service>
+    <service ref="ExtNamespaceHandler" 
interface="org.apache.aries.blueprint.NamespaceHandler">
+        <service-properties>
+            <entry key="osgi.service.blueprint.namespace" 
value="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0"/>
+        </service-properties>
+    </service>
     
     <!-- Also provide the "xml" namespace as a core functionality to avoid 
many bundles registering a handler for this -->
     <service ref="ExtNamespaceHandler" 
interface="org.apache.aries.blueprint.NamespaceHandler">

Added: 
aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd
URL: 
http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd?rev=1657355&view=auto
==============================================================================
--- 
aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd
 (added)
+++ 
aries/trunk/blueprint/blueprint-core/src/main/resources/org/apache/aries/blueprint/ext/impl/blueprint-ext-1.5.xsd
 Wed Feb  4 18:07:18 2015
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<xsd:schema 
xmlns="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0"; 
+       xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+       xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
+       attributeFormDefault="unqualified" elementFormDefault="qualified" 
+       
targetNamespace="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.5.0"; 
version="1.0.0">
+
+    <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
+
+    <!-- property placeholder -->
+
+    <xsd:element name="property-placeholder" type="TpropertyPlaceholder"/>
+
+    <xsd:complexType name="TpropertyPlaceholder">
+        <xsd:complexContent>
+            <xsd:extension base="bp:Tcomponent">
+                <xsd:sequence>
+                    <!-- nested properties declaration -->
+                    <xsd:element maxOccurs="1" minOccurs="0" 
name="default-properties" type="TdefaultProperties"/>
+                    <xsd:element maxOccurs="unbounded" minOccurs="0" 
name="location" type="xsd:string"/>
+                </xsd:sequence>
+                <xsd:attribute default="${" name="placeholder-prefix" 
type="xsd:string" use="optional"/>
+                <xsd:attribute default="}" name="placeholder-suffix" 
type="xsd:string" use="optional"/>
+                <xsd:attribute name="defaults-ref" type="bp:Tidref" 
use="optional"/>
+                <xsd:attribute default="false" name="ignore-missing-locations" 
type="xsd:boolean" use="optional"/>
+                <xsd:attribute default="fallback" name="system-properties" 
use="optional">
+                    <xsd:simpleType>
+                        <xsd:restriction base="xsd:NMTOKEN">
+                            <xsd:enumeration value="never"/>
+                            <xsd:enumeration value="fallback"/>
+                            <xsd:enumeration value="override"/>
+                        </xsd:restriction>
+                    </xsd:simpleType>
+                </xsd:attribute>
+                <xsd:attribute name="evaluator" type="xsd:string" 
use="optional"/>
+            </xsd:extension>
+        </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:complexType name="TdefaultProperties">
+        <xsd:sequence maxOccurs="unbounded" minOccurs="0">
+            <xsd:element name="property" type="bp:Tproperty"/>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <!-- proxy method -->
+
+    <xsd:attribute default="default" name="proxy-method">
+        <xsd:simpleType>
+            <xsd:restriction>
+                <xsd:simpleType>
+                    <xsd:list>
+                        <xsd:simpleType>
+                            <xsd:restriction base="xsd:NMTOKEN">
+                                <xsd:enumeration value="default"/>
+                                <xsd:enumeration value="classes"/>
+                                <xsd:enumeration value="greedy"/>
+                            </xsd:restriction>
+                        </xsd:simpleType>
+                    </xsd:list>
+                </xsd:simpleType>
+                <xsd:minLength value="1"/>
+            </xsd:restriction>
+        </xsd:simpleType>
+    </xsd:attribute>
+
+    <!-- role -->
+
+    <xsd:attribute name="role">
+        <xsd:simpleType>
+            <xsd:restriction>
+                <xsd:simpleType>
+                    <xsd:list>
+                        <xsd:simpleType>
+                            <xsd:restriction base="xsd:NMTOKEN">
+                                <xsd:enumeration value="processor"/>
+                            </xsd:restriction>
+                        </xsd:simpleType>
+                    </xsd:list>
+                </xsd:simpleType>
+            </xsd:restriction>
+        </xsd:simpleType>
+    </xsd:attribute>
+
+    <!-- CM property placeholder extenstion -->
+
+    <xsd:element name="location" type="xsd:string"/>
+    <xsd:attribute default="false" name="ignore-missing-locations" 
type="xsd:boolean"/>
+    <xsd:attribute default="fallback" name="system-properties">
+        <xsd:simpleType>
+            <xsd:restriction base="xsd:NMTOKEN">
+                <xsd:enumeration value="never"/>
+                <xsd:enumeration value="fallback"/>
+                <xsd:enumeration value="override"/>
+            </xsd:restriction>
+        </xsd:simpleType>
+    </xsd:attribute>
+    
+    <xsd:attribute default="false" name="field-injection" type="xsd:boolean"/>
+
+    <!-- Default reference bean -->
+    <xsd:attribute name="default" type="bp:Tidref"/>
+
+    <!-- Filter attribute -->
+    <xsd:attribute name="filter" type="xsd:normalizedString"/>
+    
+    <!-- Additional interfaces for references -->
+    <xsd:element name="additional-interfaces" type="bp:Tinterfaces"/>
+    
+    <!-- ARIES-1293, provide a way to create or reference beans from within -->
+    <!-- custom namespace handlers and other locations. (blueprint.xsd does  
-->
+    <!-- not provide top level element definitions for these) -->
+    <xsd:element name="bean" type="bp:Tinlined-bean"/>
+    <xsd:element name="reference" type="bp:Tref"/>
+    
+</xsd:schema>


Reply via email to