You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by li...@apache.org on 2010/07/20 19:58:14 UTC

svn commit: r965932 - in /incubator/aries/sandbox/linsun/mds/mds-blueprint/src: ./ main/ main/java/ main/java/org/ main/java/org/apache/ main/java/org/apache/aries/ main/java/org/apache/aries/mds/ main/java/org/apache/aries/mds/blueprint/ main/resource...

Author: linsun
Date: Tue Jul 20 17:58:13 2010
New Revision: 965932

URL: http://svn.apache.org/viewvc?rev=965932&view=rev
Log:
[message-driven-service]add message-driven blueprint project which allows user to easily mark message driven bean and service in blueprint definition XML using custom message-driven namespace

Added:
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java   (with props)
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java   (with props)
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml   (with props)
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd   (with props)
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java   (with props)
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/
    incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml   (with props)

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java Tue Jul 20 17:58:13 2010
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.aries.mds.blueprint;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.Interceptor;
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.ParserContext;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class MessageDrivenElementHandler implements NamespaceHandler {
+    private static final Logger LOGGER =
+        LoggerFactory.getLogger(MessageDrivenElementHandler.class);
+
+    private Interceptor interceptor = null;
+
+
+    public ComponentMetadata decorate(Node node, ComponentMetadata cm, ParserContext pc)
+    {
+        // nothing to decorate here because everything will be processed in parse
+        return cm;
+    }
+
+    /**
+     * message driven name space handler will parse the message-driven element into bean and service elements
+     * and register them in component definition registry
+     */
+    public Metadata parse(Element elt, ParserContext pc)
+    {
+        LOGGER.info("Start parsing message-driven element");
+        parseElement(elt, pc, null);
+        return null;
+    }
+    
+    private void parseElement(Element elt, ParserContext pc, ComponentMetadata cm) {
+        MessageDrivenParser parser = new MessageDrivenParser();
+        List<ComponentMetadata> cms = parser.parseMessageDriven(elt, pc, cm);
+        ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
+        for (ComponentMetadata compMetadata : cms) {
+            cdr.registerComponentDefinition(compMetadata);
+        }
+        
+    }
+
+    public URL getSchemaLocation(String arg0)
+    {
+        return this.getClass().getResource("mds.xsd");
+    }
+
+    public Set<Class> getManagedClasses()
+    {
+        return null;
+    }
+}

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenElementHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java Tue Jul 20 17:58:13 2010
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ */
+package org.apache.aries.mds.blueprint;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.aries.blueprint.ParserContext;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class MessageDrivenParser {
+
+    private static final Logger LOGGER =
+        LoggerFactory.getLogger(MessageDrivenParser.class);
+
+    private static final String BLUEPRINT_NS = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+    
+    private static final String MESSAGE_DRIVEN_TAG = "message-driven";
+    private static final String BEAN_TAG = "bean";
+    private static final String SERVICE_TAG = "service";
+    private static final String SERVICE_PROPERTIES_TAG = "service-properties";
+    private static final String ENTRY_TAG = "entry";
+    
+    private static final String ID_ATTR = "id";
+    private static final String INTERFACE_ATTR = "interface";
+    private static final String REF_ATTR = "ref";
+    
+    private static final String ACTIVATION_CONFIG_TAG = "activationConfig";
+    
+    public List<ComponentMetadata> parseMessageDriven(Element root, ParserContext pc, ComponentMetadata parent) {
+        if (MESSAGE_DRIVEN_TAG.equals(root.getNodeName()) || MESSAGE_DRIVEN_TAG.equals(root.getLocalName())) {
+            Element beanElement = root.getOwnerDocument().createElementNS(BLUEPRINT_NS, BEAN_TAG);
+            Element serviceElement = root.getOwnerDocument().createElementNS(BLUEPRINT_NS, SERVICE_TAG);
+            Element servicepropElement = serviceElement.getOwnerDocument().createElementNS(BLUEPRINT_NS, SERVICE_PROPERTIES_TAG);
+            serviceElement.appendChild(servicepropElement);
+
+            NamedNodeMap attrs = root.getAttributes();
+            String beanId = null;
+            for (int i = 0; i < attrs.getLength(); i++) {
+              Node cur = attrs.item(i);
+              if (cur.getNodeType() == Node.ATTRIBUTE_NODE) {
+                Attr a = (Attr) cur;
+                // let's assume only interface attribute is for service, other attributes are for bean
+                if (a.getName().equals(INTERFACE_ATTR)) {
+                    serviceElement.setAttribute(a.getName(), a.getValue());
+                } else {
+                    beanElement.setAttribute(a.getName(), a.getValue());
+                    if (a.getName().equals(ID_ATTR)) {
+                        beanId = a.getValue();
+                    }
+                }
+              }
+            }
+            
+
+            NodeList nodes = root.getChildNodes();
+            for (int i = 0; i< nodes.getLength(); i++) {
+              Node cur = nodes.item(i);
+              
+              if (cur.getNodeType() == Node.ELEMENT_NODE) {
+                Element elem = (Element) cur;
+                if (elem.getLocalName().equals(ACTIVATION_CONFIG_TAG)) {
+                    NodeList acNodes = elem.getChildNodes();
+                    for (int j = 0; j < acNodes.getLength(); j++) {
+                        Node current = acNodes.item(j);
+                        
+                        if (current.getNodeType() == Node.ELEMENT_NODE) {
+                            Element element = (Element) current;
+                            if (element.getLocalName().equals(ENTRY_TAG)) {
+                                // create element using blueprint ns and use this instead
+                                Element entryElement = createElement(serviceElement, element);
+                                servicepropElement.appendChild(entryElement);
+                                
+                            }
+                            
+                        } 
+                    }
+                } else {
+                    // when it is not activation config tag, such as argument, etc
+                    Element element = createElement(beanElement, elem);
+                    beanElement.appendChild(element);
+                }
+                
+              } 
+            }
+            
+            serviceElement.setAttribute(REF_ATTR, beanId);
+            serviceElement.setAttribute(ID_ATTR, pc.generateId());
+            
+   
+            List<ComponentMetadata> cms = new ArrayList<ComponentMetadata>();
+            BeanMetadata beanMetadata = pc.parseElement(BeanMetadata.class, parent, beanElement);
+            
+            ServiceMetadata serviceMetadata = pc.parseElement(ServiceMetadata.class, parent, serviceElement);
+            
+            cms.add(beanMetadata);
+            cms.add(serviceMetadata);
+            return cms;
+        } else {
+            LOGGER.warn("Unexpected top element in message-driven");
+
+            return null;
+        }
+        
+
+
+    }
+    
+    /**
+     * this method create an element based onoldElement passed in but using blueprint ns instead of the message-driven ns
+     * 
+     * @param serviceElement
+     * @param oldElement
+     * @return
+     */
+    private Element createElement(Element ele, Element oldElement) {
+        Element element = ele.getOwnerDocument().createElementNS(BLUEPRINT_NS, oldElement.getLocalName());
+        NamedNodeMap attrs = oldElement.getAttributes();
+        for (int i = 0; i < attrs.getLength(); i++) {
+            Node cur = attrs.item(i);
+            if (cur.getNodeType() == Node.ATTRIBUTE_NODE) {
+              Attr a = (Attr) cur;
+              element.setAttribute(a.getName(), a.getValue());
+            }            
+        }
+            
+        return element;
+    }
+    
+
+
+}

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/java/org/apache/aries/mds/blueprint/MessageDrivenParser.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml Tue Jul 20 17:58:13 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
+            default-activation="lazy">
+            
+  <service interface="org.apache.aries.blueprint.NamespaceHandler">
+        <service-properties>
+            <entry key="osgi.service.blueprint.namespace" value="http://aries.apache.org/xmlns/messagedriven/v1.0.0"/>
+        </service-properties>
+        <bean class="org.apache.aries.mds.blueprint.MessageDrivenElementHandler" />
+  </service>              
+  
+</blueprint>
\ No newline at end of file

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/OSGI-INF/blueprint/mds.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd Tue Jul 20 17:58:13 2010
@@ -0,0 +1,77 @@
+<?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/xmlns/messagedriven"
+	xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" 
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	targetNamespace="http://aries.apache.org/xmlns/messagedriven"
+	elementFormDefault="qualified" 
+	attributeFormDefault="unqualified"
+	version="1.0.0">
+
+	<xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0" />
+
+	<xsd:complexType name="TmessageDriven">
+		<xsd:annotation>
+			<xsd:documentation>
+        	<![CDATA[
+                A messageDriven element is used to describe a message-driven bean and message-service service
+            ]]>
+			</xsd:documentation>
+		</xsd:annotation>
+		<xsd:sequence>
+			<xsd:element name="activationConfig" type="TactivationConfig"
+				minOccurs="1" maxOccurs="1" />
+			<xsd:choice minOccurs="0" maxOccurs="unbounded">
+				<xsd:element name="argument" type="bp:Targument" />
+				<xsd:element name="property" type="bp:Tproperty" />
+			</xsd:choice>
+		</xsd:sequence>
+
+		<xsd:attribute name="dependsOn" type="bp:TdependsOn" />
+		<xsd:attribute name="id" type="bp:Tidref" />
+		<xsd:attribute name="class" type="bp:Tclass" />
+		<xsd:attribute name="init-method" type="bp:Tmethod" />
+		<xsd:attribute name="destroy-method" type="bp:Tmethod" />
+		<xsd:attribute name="factory-method" type="bp:Tmethod" />
+		<xsd:attribute name="factory-ref" type="bp:Tidref" />
+		<xsd:attribute name="scope" type="bp:Tscope" />
+		
+		<xsd:attribute name="interface" type="bp:Tclass" use="required" />
+	</xsd:complexType>
+
+	<xsd:complexType name="TactivationConfig">
+		<xsd:annotation>
+			<xsd:documentation>
+        	<![CDATA[
+                An activationConfig element is used to describe the activation config for message-driven bean and message-service service.
+                The required entry for JMS activation config is destination and destinationType.   acknowledgeMode, acknowledgeMode and 
+                subscriptionDurability are optional entries.
+            ]]>
+	 		</xsd:documentation>
+		</xsd:annotation>
+		<xsd:sequence>
+			<xsd:element name="entry" type="bp:TservicePropertyEntry"
+				minOccurs="0" maxOccurs="unbounded" />
+		</xsd:sequence>
+	</xsd:complexType>
+
+
+	<xsd:element name="message-driven" type="TmessageDriven" />
+
+</xsd:schema>
\ No newline at end of file

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/main/resources/org/apache/aries/mds/blueprint/mds.xsd
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java Tue Jul 20 17:58:13 2010
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+package org.apache.aries.mds.blueprint;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.container.NamespaceHandlerRegistry;
+import org.apache.aries.blueprint.container.Parser;
+import org.apache.aries.blueprint.container.NamespaceHandlerRegistry.NamespaceHandlerSet;
+import org.apache.aries.blueprint.namespace.ComponentDefinitionRegistryImpl;
+import org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl;
+import org.apache.aries.mocks.BundleMock;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+
+public class NameSpaceHandlerTest {
+    
+    
+    @Test
+    public void testMultipleElements() throws Exception
+    {
+      Bundle b = Skeleton.newMock(new BundleMock("org.apache.aries.mds.blueprint", new Properties()), Bundle.class);
+      BundleContext ctx = b.getBundleContext();
+      NamespaceHandlerRegistry nhri = new NamespaceHandlerRegistryImpl(ctx);
+      
+      Properties props = new Properties();
+      props.put("osgi.service.blueprint.namespace", "http://aries.apache.org/xmlns/messagedriven");
+      NamespaceHandler namespaceHandler = new MessageDrivenElementHandler();
+      ctx.registerService(NamespaceHandler.class.getName(), namespaceHandler, props);
+      Parser p = new Parser();
+      
+      URL bpxml = this.getClass().getResource("aries.xml");
+      List<URL> bpxmlList = new LinkedList<URL>();
+      bpxmlList.add(bpxml); 
+      
+      p.parse(bpxmlList);
+      Set<URI> nsuris = p.getNamespaces();
+      NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
+      p.validate(nshandlers.getSchema());
+      
+      ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
+      p.populate(nshandlers, cdr);
+      
+      BeanMetadata comp = (BeanMetadata) cdr.getComponentDefinition("myMessageDrivenBean");
+      assertEquals("myMessageDrivenBean", comp.getId());
+      assertEquals("org.apache.aries.mds.sample.MyMessageDrivenBean", comp.getClassName());
+      assertEquals("destory", comp.getDestroyMethod());
+      assertEquals("singleton", comp.getScope());
+      
+      
+
+
+
+        
+    }
+}

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/java/org/apache/aries/mds/blueprint/NameSpaceHandlerTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml?rev=965932&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml (added)
+++ incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml Tue Jul 20 17:58:13 2010
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:md="http://aries.apache.org/xmlns/messagedriven" 
+            default-activation="lazy">
+            
+<md:message-driven id="myMessageDrivenBean" class="org.apache.aries.mds.sample.MyMessageDrivenBean" destroy-method="destory" 
+		    scope="singleton" interface="javax.jms.MessageListener">
+	<md:activationConfig>
+        <md:entry key="destination" value="Hello.Queue" />
+		<md:entry key="destinationType" value="javax.jms.Queue" />
+	</md:activationConfig>
+	<md:argument ref="connectionFactory" />
+
+</md:message-driven>
+             
+  
+</blueprint>
\ No newline at end of file

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/aries/sandbox/linsun/mds/mds-blueprint/src/test/resources/org/apache/aries/mds/blueprint/aries.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml