You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2015/11/20 17:45:34 UTC

svn commit: r1715391 - in /aries/trunk/blueprint: ./ blueprint-spring/ blueprint-spring/src/ blueprint-spring/src/main/ blueprint-spring/src/main/java/ blueprint-spring/src/main/java/org/ blueprint-spring/src/main/java/org/apache/ blueprint-spring/src/...

Author: gnodet
Date: Fri Nov 20 16:45:33 2015
New Revision: 1715391

URL: http://svn.apache.org/viewvc?rev=1715391&view=rev
Log:
[ARIES-1456] Support spring beans and spring custom namespaces (work in progress)

Added:
    aries/trunk/blueprint/blueprint-spring/
    aries/trunk/blueprint/blueprint-spring/pom.xml
    aries/trunk/blueprint/blueprint-spring/src/
    aries/trunk/blueprint/blueprint-spring/src/main/
    aries/trunk/blueprint/blueprint-spring/src/main/java/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/Activator.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BeansNamespaceHandler.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintBeanFactory.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringApplicationContext.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringExtension.java
    aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringNamespaceHandlerResolver.java
Modified:
    aries/trunk/blueprint/pom.xml

Added: aries/trunk/blueprint/blueprint-spring/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/pom.xml?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/pom.xml (added)
+++ aries/trunk/blueprint/blueprint-spring/pom.xml Fri Nov 20 16:45:33 2015
@@ -0,0 +1,209 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.aries</groupId>
+        <artifactId>parent</artifactId>
+        <version>2.0.1</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.aries.blueprint</groupId>
+    <artifactId>org.apache.aries.blueprint.spring</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>Apache Aries Blueprint Spring Support</name>
+    <description>
+        This bundle contains Spring support for blueprint.
+    </description>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-spring</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-spring</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring</url>
+    </scm>
+
+    <properties>
+        <!-- Export package versions are maintained in packageinfo files -->
+        <aries.osgi.export.pkg />
+        <aries.osgi.import.pkg>
+           org.apache.aries.blueprint;provide:=true;version="[1.0,2.0)",
+           org.apache.aries.blueprint.ext;provide:=true;version="[1.0,2.0)",
+           org.apache.aries.blueprint.reflect;version="[1.0,2.0)",
+           *
+        </aries.osgi.import.pkg>
+        <aries.osgi.private.pkg>
+            org.apache.aries.blueprint.spring,
+            org.apache.felix.utils.extender
+        </aries.osgi.private.pkg>
+        <aries.osgi.activator>
+            org.apache.aries.blueprint.spring.Activator
+        </aries.osgi.activator>
+        <blueprint.api.version>1.0.0</blueprint.api.version>
+        <blueprint.core.version>1.5.0-SNAPSHOT</blueprint.core.version>
+        <blueprint.parser.version>1.4.0-SNAPSHOT</blueprint.parser.version>
+        <!--
+        <lastReleaseVersion>1.0.4</lastReleaseVersion>
+        -->
+    </properties>
+
+    <profiles>
+        <profile>
+            <id>dev</id>
+            <properties>
+                <blueprint.api.version>1.0.1</blueprint.api.version>
+                <blueprint.core.version>1.5.0-SNAPSHOT</blueprint.core.version>
+                <blueprint.parser.version>1.4.0-SNAPSHOT</blueprint.parser.version>
+            </properties>
+        </profile>
+    </profiles>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.api</artifactId>
+            <version>${blueprint.api.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>blueprint-parser</artifactId>
+            <version>${blueprint.parser.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.core</artifactId>
+            <version>${blueprint.core.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+            <version>4.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>4.2.2.RELEASE</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+            <version>4.2.2.RELEASE</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.8.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.pojosr</groupId>
+            <artifactId>de.kalpatec.pojosr.framework</artifactId>
+            <version>0.1.6</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.swissbox</groupId>
+            <artifactId>pax-swissbox-tinybundles</artifactId>
+            <version>1.3.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.7</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl-over-slf4j</artifactId>
+            <version>1.7.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.proxy</groupId>
+            <artifactId>org.apache.aries.proxy.impl</artifactId>
+            <version>1.0.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <version>1.2.8</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>4.2.2.RELEASE</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <version>4.2.2.RELEASE</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.aries.versioning</groupId>
+                <artifactId>org.apache.aries.versioning.plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>version-check</goal>
+                        </goals>
+                        <configuration>
+                            <skip>true</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/Activator.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/Activator.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/Activator.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,65 @@
+/**
+ *  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.blueprint.spring;
+
+import java.net.URL;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.felix.utils.extender.AbstractExtender;
+import org.apache.felix.utils.extender.Extension;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Spring namespace extender.
+ * This OSGi extender is responsible for registering spring namespaces for blueprint.
+ *
+ * @see SpringExtension
+ */
+public class Activator extends AbstractExtender {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
+
+    ServiceRegistration<NamespaceHandler> registration;
+
+    @Override
+    protected Extension doCreateExtension(Bundle bundle) throws Exception {
+        URL handlers = bundle.getResource(SpringExtension.SPRING_HANDLERS);
+        if (handlers != null) {
+            return new SpringExtension(bundle);
+        }
+        return null;
+    }
+
+    @Override
+    protected void debug(Bundle bundle, String msg) {
+        LOGGER.debug(msg + ": " + bundle.getSymbolicName() + "/" + bundle.getVersion());
+    }
+
+    @Override
+    protected void warn(Bundle bundle, String msg, Throwable t) {
+        LOGGER.warn(msg + ": " + bundle.getSymbolicName() + "/" + bundle.getVersion(), t);
+    }
+
+    @Override
+    protected void error(String msg, Throwable t) {
+        LOGGER.error(msg, t);
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BeansNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BeansNamespaceHandler.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BeansNamespaceHandler.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BeansNamespaceHandler.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,65 @@
+/**
+ *  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.blueprint.spring;
+
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.parsing.BeanComponentDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * A spring namespace handler to handle spring bean elements.
+ */
+public class BeansNamespaceHandler implements org.springframework.beans.factory.xml.NamespaceHandler {
+
+    @Override
+    public void init() {
+    }
+
+    @Override
+    public BeanDefinition parse(Element ele, ParserContext parserContext) {
+        if (BeanDefinitionParserDelegate.BEAN_ELEMENT.equals(ele.getLocalName())) {
+            BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
+            BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(ele);
+            if (bdHolder != null) {
+                bdHolder = delegate.decorateBeanDefinitionIfRequired(ele, bdHolder);
+                try {
+                    // Register the final decorated instance.
+                    BeanDefinitionReaderUtils.registerBeanDefinition(bdHolder, parserContext.getReaderContext().getRegistry());
+                } catch (BeanDefinitionStoreException ex) {
+                    parserContext.getReaderContext().error("Failed to register bean definition with name '" +
+                            bdHolder.getBeanName() + "'", ele, ex);
+                }
+                // Send registration event.
+                parserContext.getReaderContext().fireComponentRegistered(new BeanComponentDefinition(bdHolder));
+            }
+        } else {
+            throw new UnsupportedOperationException();
+        }
+        return null;
+    }
+
+    @Override
+    public BeanDefinitionHolder decorate(Node source, BeanDefinitionHolder definition, ParserContext parserContext) {
+        return definition;
+    }
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintBeanFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintBeanFactory.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintBeanFactory.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintBeanFactory.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,193 @@
+/**
+ *  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.blueprint.spring;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+import org.apache.aries.blueprint.reflect.RefMetadataImpl;
+import org.apache.aries.blueprint.reflect.ValueMetadataImpl;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
+import org.osgi.service.blueprint.container.ReifiedType;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.core.ResolvableType;
+
+public class BlueprintBeanFactory extends DefaultListableBeanFactory {
+
+    private final ExtendedBlueprintContainer container;
+
+    public BlueprintBeanFactory(ExtendedBlueprintContainer container) {
+        super(new WrapperBeanFactory(container));
+        this.container = container;
+    }
+
+    @Override
+    public <T> T getBean(Class<T> requiredType) throws BeansException {
+        return super.getBean(requiredType);
+    }
+
+    @Override
+    public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException {
+        ComponentDefinitionRegistry registry = container.getComponentDefinitionRegistry();
+        ComponentMetadata metadata = registry.getComponentDefinition(beanName);
+        if (metadata != null && !(metadata instanceof SpringMetadata)) {
+            throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName,
+                    "Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName +
+                            "': There is already bound.");
+        }
+        super.registerBeanDefinition(beanName, beanDefinition);
+        if (!beanDefinition.isAbstract()) {
+            registry.registerComponentDefinition(new SpringMetadata(beanName));
+        }
+    }
+
+    @Override
+    public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException {
+        super.removeBeanDefinition(beanName);
+    }
+
+    public class SpringMetadata extends BeanMetadataImpl {
+        private final String beanName;
+
+        public SpringMetadata(String beanName) {
+            this.beanName = beanName;
+            setFactoryComponent(new RefMetadataImpl(BlueprintNamespaceHandler.SPRING_BEAN_FACTORY_ID));
+            setFactoryMethod("getBean");
+            addArgument(new ValueMetadataImpl(beanName), null, -1);
+        }
+
+        public BeanDefinition getDefinition() {
+            return getBeanDefinition(beanName);
+        }
+
+        @Override
+        public String getId() {
+            return beanName;
+        }
+
+        @Override
+        public String getScope() {
+            return getDefinition().isSingleton() ? SCOPE_SINGLETON : SCOPE_PROTOTYPE;
+        }
+
+        @Override
+        public int getActivation() {
+            return getDefinition().isLazyInit() ? ACTIVATION_LAZY : ACTIVATION_EAGER;
+        }
+
+        @Override
+        public List<String> getDependsOn() {
+            String[] dependson = getDefinition().getDependsOn();
+            return dependson != null ? Arrays.asList(dependson) : Collections.<String>emptyList();
+        }
+    }
+
+
+    static class WrapperBeanFactory implements BeanFactory {
+
+        private final ExtendedBlueprintContainer container;
+
+        public WrapperBeanFactory(ExtendedBlueprintContainer container) {
+            this.container = container;
+        }
+
+        @Override
+        public Object getBean(String name) throws BeansException {
+            try {
+                return container.getComponentInstance(name);
+            } catch (NoSuchComponentException e) {
+                throw new NoSuchBeanDefinitionException(name);
+            }
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
+            Object bean = getBean(name);
+            if (requiredType != null && bean != null && !requiredType.isAssignableFrom(bean.getClass())) {
+                try {
+                    bean = container.getConverter().convert(bean, new ReifiedType(requiredType));
+                } catch (Exception ex) {
+                    throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
+                }
+            }
+            return (T) bean;
+        }
+
+        @Override
+        public <T> T getBean(Class<T> requiredType) throws BeansException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Object getBean(String name, Object... args) throws BeansException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public <T> T getBean(Class<T> requiredType, Object... args) throws BeansException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean containsBean(String name) {
+            return container.getComponentIds().contains(name);
+        }
+
+        @Override
+        public boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean isPrototype(String name) throws NoSuchBeanDefinitionException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean isTypeMatch(String name, ResolvableType typeToMatch) throws NoSuchBeanDefinitionException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public boolean isTypeMatch(String name, Class<?> typeToMatch) throws NoSuchBeanDefinitionException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public String[] getAliases(String name) {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/BlueprintNamespaceHandler.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,172 @@
+/**
+ *  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.blueprint.spring;
+
+import java.net.URL;
+import java.util.Collections;
+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.ParserContext;
+import org.apache.aries.blueprint.PassThroughMetadata;
+import org.apache.aries.blueprint.reflect.BeanMetadataImpl;
+import org.apache.aries.blueprint.reflect.PassThroughMetadataImpl;
+import org.apache.aries.blueprint.reflect.RefMetadataImpl;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.Metadata;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.parsing.EmptyReaderEventListener;
+import org.springframework.beans.factory.parsing.FailFastProblemReporter;
+import org.springframework.beans.factory.parsing.NullSourceExtractor;
+import org.springframework.beans.factory.parsing.ProblemReporter;
+import org.springframework.beans.factory.parsing.ReaderEventListener;
+import org.springframework.beans.factory.parsing.SourceExtractor;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.beans.factory.xml.XmlReaderContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Blueprint NamespaceHandler wrapper for a spring NamespaceHandler
+ */
+public class BlueprintNamespaceHandler implements NamespaceHandler {
+
+    public static final String SPRING_CONTEXT_ID = "." + org.springframework.beans.factory.xml.ParserContext.class.getName();
+    public static final String SPRING_BEAN_PROCESSOR_ID = "." + SpringBeanProcessor.class.getName();
+    public static final String SPRING_APPLICATION_CONTEXT_ID = "." + ApplicationContext.class.getName();
+    public static final String SPRING_BEAN_FACTORY_ID = "." + BeanFactory.class.getName();
+
+    private final Bundle bundle;
+    private final Properties schemas;
+    private final org.springframework.beans.factory.xml.NamespaceHandler springHandler;
+
+    public BlueprintNamespaceHandler(Bundle bundle, Properties schemas, org.springframework.beans.factory.xml.NamespaceHandler springHandler) {
+        this.bundle = bundle;
+        this.schemas = schemas;
+        this.springHandler = springHandler;
+    }
+
+    public org.springframework.beans.factory.xml.NamespaceHandler getSpringHandler() {
+        return springHandler;
+    }
+
+    @Override
+    public URL getSchemaLocation(String s) {
+        if (schemas.containsKey(s)) {
+            return bundle.getResource(schemas.getProperty(s));
+        }
+        return null;
+    }
+
+    @Override
+    public Set<Class> getManagedClasses() {
+        return Collections.<Class>singleton(BeanDefinition.class);
+    }
+
+    @Override
+    public Metadata parse(Element element, ParserContext parserContext) {
+        try {
+            // Get the spring context
+            org.springframework.beans.factory.xml.ParserContext springContext
+                    = getOrCreateParserContext(parserContext);
+            // Parse spring bean
+            springHandler.parse(element, springContext);
+            return null;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public ComponentMetadata decorate(Node node, ComponentMetadata componentMetadata, ParserContext parserContext) {
+        throw new UnsupportedOperationException();
+    }
+
+    private org.springframework.beans.factory.xml.ParserContext getOrCreateParserContext(ParserContext parserContext) {
+        ComponentDefinitionRegistry registry = parserContext.getComponentDefinitionRegistry();
+        org.springframework.beans.factory.xml.ParserContext springContext;
+        ComponentMetadata contextMetadata = registry.getComponentDefinition(SPRING_CONTEXT_ID);
+        if (contextMetadata == null) {
+            ExtendedBlueprintContainer container = getBlueprintContainer(parserContext);
+            // Create spring application context
+            SpringApplicationContext applicationContext = new SpringApplicationContext(container);
+            registry.registerComponentDefinition(new PassThroughMetadataImpl(
+                    SPRING_APPLICATION_CONTEXT_ID, applicationContext
+            ));
+            // Create registry
+            DefaultListableBeanFactory beanFactory = applicationContext.getBeanFactory();
+            registry.registerComponentDefinition(new PassThroughMetadataImpl(
+                    SPRING_BEAN_FACTORY_ID, beanFactory
+            ));
+            // Create spring context
+            springContext = createSpringParserContext(parserContext, beanFactory);
+            registry.registerComponentDefinition(new PassThroughMetadataImpl(
+                    SPRING_CONTEXT_ID, springContext
+            ));
+            // Create processor
+            BeanMetadataImpl bm = new BeanMetadataImpl();
+            bm.setId(SPRING_BEAN_PROCESSOR_ID);
+            bm.setProcessor(true);
+            bm.setScope(BeanMetadata.SCOPE_SINGLETON);
+            bm.setRuntimeClass(SpringBeanProcessor.class);
+            bm.setActivation(BeanMetadata.ACTIVATION_EAGER);
+            bm.addArgument(new RefMetadataImpl("blueprintBundleContext"), null, 0);
+            bm.addArgument(new RefMetadataImpl("blueprintContainer"), null, 0);
+            bm.addArgument(new RefMetadataImpl(SPRING_APPLICATION_CONTEXT_ID), null, 0);
+            registry.registerComponentDefinition(bm);
+        } else {
+            PassThroughMetadata ptm = (PassThroughMetadata) contextMetadata;
+            springContext = (org.springframework.beans.factory.xml.ParserContext) ptm.getObject();
+        }
+        return springContext;
+    }
+
+    private ExtendedBlueprintContainer getBlueprintContainer(ParserContext parserContext) {
+        return (ExtendedBlueprintContainer) ((PassThroughMetadata) parserContext.getComponentDefinitionRegistry().getComponentDefinition("blueprintContainer")).getObject();
+    }
+
+    private org.springframework.beans.factory.xml.ParserContext createSpringParserContext(ParserContext parserContext, DefaultListableBeanFactory registry) {
+        try {
+            XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(registry);
+            Resource resource = new UrlResource(parserContext.getSourceNode().getOwnerDocument().getDocumentURI());
+            ProblemReporter problemReporter = new FailFastProblemReporter();
+            ReaderEventListener listener = new EmptyReaderEventListener();
+            SourceExtractor extractor = new NullSourceExtractor();
+            NamespaceHandlerResolver resolver = new SpringNamespaceHandlerResolver(parserContext);
+            XmlReaderContext xmlReaderContext = new XmlReaderContext(resource, problemReporter, listener, extractor, xbdr, resolver);
+            BeanDefinitionParserDelegate bdpd = new BeanDefinitionParserDelegate(xmlReaderContext);
+            return new org.springframework.beans.factory.xml.ParserContext(xmlReaderContext, bdpd);
+        } catch (Exception e) {
+            throw new RuntimeException("Error creating spring parser context", e);
+        }
+    }
+
+
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringApplicationContext.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringApplicationContext.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringApplicationContext.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringApplicationContext.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,62 @@
+/**
+ *  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.blueprint.spring;
+
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.osgi.framework.wiring.BundleWiring;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.support.AbstractApplicationContext;
+
+public class SpringApplicationContext extends AbstractApplicationContext {
+
+    private final ExtendedBlueprintContainer container;
+    private final DefaultListableBeanFactory beanFactory;
+
+    public SpringApplicationContext(ExtendedBlueprintContainer container) {
+        this.container = container;
+        this.beanFactory = new BlueprintBeanFactory(container);
+        setClassLoader(container.getBundleContext().getBundle().adapt(BundleWiring.class).getClassLoader());
+        prepareBeanFactory(beanFactory);
+    }
+
+    public void process() {
+        // Invoke factory processors registered as beans in the context.
+        invokeBeanFactoryPostProcessors(beanFactory);
+        // Register bean processors that intercept bean creation.
+        registerBeanPostProcessors(beanFactory);
+    }
+
+    @Override
+    protected void refreshBeanFactory() throws BeansException, IllegalStateException {
+    }
+
+    @Override
+    protected void closeBeanFactory() {
+    }
+
+    @Override
+    public DefaultListableBeanFactory getBeanFactory() throws IllegalStateException {
+        return beanFactory;
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringBeanProcessor.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,124 @@
+/**
+ *  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.blueprint.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.aries.blueprint.BeanProcessor;
+import org.apache.aries.blueprint.ComponentDefinitionRegistry;
+import org.apache.aries.blueprint.ComponentDefinitionRegistryProcessor;
+import org.apache.aries.blueprint.ExtendedBeanMetadata;
+import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.springframework.beans.factory.Aware;
+import org.springframework.beans.factory.BeanClassLoaderAware;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.support.AbstractApplicationContext;
+
+public class SpringBeanProcessor implements BeanProcessor, ComponentDefinitionRegistryProcessor {
+
+    private final BundleContext bundleContext;
+    private final ExtendedBlueprintContainer blueprintContainer;
+    private final SpringApplicationContext applicationContext;
+    boolean creatingProcessor;
+
+    public SpringBeanProcessor(
+            BundleContext bundleContext,
+            ExtendedBlueprintContainer blueprintContainer,
+            SpringApplicationContext applicationContext) {
+        this.bundleContext = bundleContext;
+        this.blueprintContainer = blueprintContainer;
+        this.applicationContext = applicationContext;
+    }
+
+    @Override
+    public void process(ComponentDefinitionRegistry componentDefinitionRegistry) {
+        applicationContext.process();
+    }
+
+    @Override
+    public Object beforeInit(Object o, String s, BeanCreator beanCreator, BeanMetadata beanMetadata) {
+        if (o instanceof Aware) {
+            if (o instanceof BeanNameAware) {
+                ((BeanNameAware) o).setBeanName(s);
+            }
+            if (o instanceof BeanClassLoaderAware) {
+                ClassLoader cl = bundleContext.getBundle().adapt(BundleWiring.class).getClassLoader();
+                ((BeanClassLoaderAware) o).setBeanClassLoader(cl);
+            }
+            if (o instanceof BeanFactoryAware) {
+                ((BeanFactoryAware) o).setBeanFactory(applicationContext.getBeanFactory());
+            }
+        }
+        return applicationContext.getBeanFactory().applyBeanPostProcessorsBeforeInitialization(o, s);
+    }
+
+    @Override
+    public Object afterInit(Object o, String s, BeanCreator beanCreator, BeanMetadata beanMetadata) {
+        return applicationContext.getBeanFactory().applyBeanPostProcessorsAfterInitialization(o, s);
+    }
+
+    @Override
+    public void beforeDestroy(Object o, String s) {
+        for (BeanPostProcessor processor : applicationContext.getBeanFactory().getBeanPostProcessors()) {
+            if (processor instanceof DestructionAwareBeanPostProcessor) {
+                ((DestructionAwareBeanPostProcessor) processor).postProcessBeforeDestruction(o, s);
+            }
+        }
+    }
+
+    @Override
+    public void afterDestroy(Object o, String s) {
+    }
+
+    private <T> List<T> getProcessors(Class<T> type) {
+        List<T> processors = new ArrayList<T>();
+        if (!creatingProcessor) {
+            creatingProcessor = true;
+            for (BeanMetadata bean : blueprintContainer.getMetadata(BeanMetadata.class)) {
+                Class clazz = null;
+                if (bean instanceof ExtendedBeanMetadata) {
+                    clazz = ((ExtendedBeanMetadata) bean).getRuntimeClass();
+                }
+                if (clazz == null && bean.getClassName() != null) {
+                    try {
+                        clazz = bundleContext.getBundle().loadClass(bean.getClassName());
+                    } catch (ClassNotFoundException e) {
+                    }
+                }
+                if (clazz == null) {
+                    continue;
+                }
+                if (type.isAssignableFrom(clazz)) {
+                    Object p = blueprintContainer.getComponentInstance(bean.getId());
+                    processors.add(type.cast(p));
+                }
+            }
+            creatingProcessor = false;
+        }
+        return processors;
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringExtension.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringExtension.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringExtension.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringExtension.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,116 @@
+/**
+ *  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.blueprint.spring;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.felix.utils.extender.Extension;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceRegistration;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
+
+/**
+ * Spring extension.
+ * Each spring namespace is wrapped in a blueprint namespace.
+ *
+ * @see BlueprintNamespaceHandler
+ */
+public class SpringExtension implements Extension {
+
+    public static final String SPRING_HANDLERS = "META-INF/spring.handlers";
+    public static final String SPRING_SCHEMAS = "META-INF/spring.schemas";
+
+    private final Bundle bundle;
+    private final List<ServiceRegistration<NamespaceHandler>> registrations;
+
+    public SpringExtension(Bundle bundle) {
+        this.bundle = bundle;
+        this.registrations = new ArrayList<ServiceRegistration<NamespaceHandler>>();
+    }
+
+    @Override
+    public void start() throws Exception {
+        Map<String, NamespaceHandler> handlers = new HashMap<String, NamespaceHandler>();
+        Properties props = loadSpringHandlers();
+        Properties schemas = loadSpringSchemas();
+        for (String key : props.stringPropertyNames()) {
+            String clazzName = props.getProperty(key);
+            org.springframework.beans.factory.xml.NamespaceHandler springHandler
+                    = (org.springframework.beans.factory.xml.NamespaceHandler) bundle.loadClass(clazzName).newInstance();
+            springHandler.init();
+            NamespaceHandler wrapper = new BlueprintNamespaceHandler(bundle, schemas, springHandler);
+            handlers.put(key, wrapper);
+        }
+        if (bundle == FrameworkUtil.getBundle(BeanFactory.class)) {
+            org.springframework.beans.factory.xml.NamespaceHandler springHandler
+                    = new BeansNamespaceHandler();
+            NamespaceHandler wrapper = new BlueprintNamespaceHandler(bundle, schemas, springHandler);
+            handlers.put(BeanDefinitionParserDelegate.BEANS_NAMESPACE_URI, wrapper);
+        }
+        for (Map.Entry<String, NamespaceHandler> entry : handlers.entrySet()) {
+            Hashtable<String, String> svcProps = new Hashtable<String, String>();
+            svcProps.put("osgi.service.blueprint.namespace", entry.getKey());
+            ServiceRegistration<NamespaceHandler> reg =
+                    bundle.getBundleContext().registerService(NamespaceHandler.class, entry.getValue(),
+                            svcProps);
+            registrations.add(reg);
+        }
+    }
+
+    private Properties loadSpringHandlers() throws IOException {
+        Properties props = new Properties();
+        URL url = bundle.getResource(SPRING_HANDLERS);
+        InputStream is = url.openStream();
+        try {
+            props.load(is);
+        } finally {
+            is.close();
+        }
+        return props;
+    }
+
+    private Properties loadSpringSchemas() throws IOException {
+        Properties props = new Properties();
+        URL url = bundle.getResource(SPRING_SCHEMAS);
+        InputStream is = url.openStream();
+        try {
+            props.load(is);
+        } finally {
+            is.close();
+        }
+        return props;
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        for (ServiceRegistration<NamespaceHandler> reg : registrations) {
+            reg.unregister();
+        }
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringNamespaceHandlerResolver.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringNamespaceHandlerResolver.java?rev=1715391&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringNamespaceHandlerResolver.java (added)
+++ aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/SpringNamespaceHandlerResolver.java Fri Nov 20 16:45:33 2015
@@ -0,0 +1,46 @@
+/**
+ *  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.blueprint.spring;
+
+import java.net.URI;
+
+import org.apache.aries.blueprint.NamespaceHandler;
+import org.apache.aries.blueprint.ParserContext;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.springframework.beans.factory.xml.NamespaceHandlerResolver;
+
+public class SpringNamespaceHandlerResolver implements NamespaceHandlerResolver {
+
+    private final ParserContext parserContext;
+
+    public SpringNamespaceHandlerResolver(ParserContext parserContext) {
+        this.parserContext = parserContext;
+    }
+
+    @Override
+    public org.springframework.beans.factory.xml.NamespaceHandler resolve(String namespaceUri) {
+        try {
+            NamespaceHandler handler = parserContext.getNamespaceHandler(URI.create(namespaceUri));
+            if (handler instanceof BlueprintNamespaceHandler) {
+                return ((BlueprintNamespaceHandler) handler).getSpringHandler();
+            }
+        } catch (ComponentDefinitionException e) {
+            // Ignore
+        }
+        return null;
+    }
+}

Modified: aries/trunk/blueprint/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/pom.xml?rev=1715391&r1=1715390&r2=1715391&view=diff
==============================================================================
--- aries/trunk/blueprint/pom.xml (original)
+++ aries/trunk/blueprint/pom.xml Fri Nov 20 16:45:33 2015
@@ -54,6 +54,7 @@
         <module>blueprint-annotation-api</module>
         <module>blueprint-annotation-impl</module>
         <module>blueprint-authz</module>
+        <module>blueprint-spring</module>
         <module>blueprint-sample-annotation</module>
         <module>blueprint-sample-fragment</module>
         <module>blueprint-sample-war</module>