karaf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Nodet <gno...@apache.org>
Subject [DISCUSS] Spring support in Blueprint
Date Fri, 20 Nov 2015 16:56:51 GMT
I've just committed a new module (and the additional required changes and
existing modules) to support Spring namespaces (default and custom) in
blueprint.
See the source code at

http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-spring/src/main/java/org/apache/aries/blueprint/spring/

It's limited and not much tested for now, but it can handle things like the
following:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  xmlns:bean="http://camel.apache.org/schema/blueprint"
  xmlns:util="http://www.springframework.org/schema/util"
           xsi:schemaLocation="
             http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
             http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
             http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
             http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.2.xsd
             http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">

    <!-- plain blueprint bean referencing a spring bean -->
    <bean id="artemis" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory" ref="jmsConnectionFactory"/>
    </bean>

    <!-- spring bean -->
    <bean name="jmsConnectionFactory"
class="org.apache.activemq.artemis.api.jms.ActiveMQJMSClient"
factory-method="createConnectionFactory" xmlns="
http://www.springframework.org/schema/beans">
<constructor-arg value="tcp://0.0.0.0:61616?user=karaf&amp;password=karaf"/>
<constructor-arg value="broker"/>
    </bean>

    <!-- spring bean using custom namespace, referencing spring and
blueprint beans -->
    <util:list id="springList" xmlns="
http://www.springframework.org/schema/beans">
<value>foo</value>
<ref bean="jmsConnectionFactory" />
<ref bean="artemis"/>
    </util:list>

    <!-- blueprint service referencing a spring bean -->
    <service ref="springList" auto-export="all-classes"/>

</blueprint>


So you can use the default spring namespace or custom spring namespaces and
cross-reference beans between blueprint and spring.

I haven't tried auto-wiring or any advanced usage such as AOP.

I'll try to commit a few initial integration tests beginning of next week.
Please have a look and provide feedback and additional use cases (as tests
?).

Cheers,
Guillaume Nodet

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message