Spring AOP with via Aries Blueprint Spring Support

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Spring AOP with via Aries Blueprint Spring Support

Michal Siemaszko

Hi, 

I'm working on migrating/upgrading a legacy application from Spring OSGi/DM to Aries Blueprint. 

Since Spring was being used previously and there were existing Spring application context configuration files (META-INF/spring/*.xml) in the close to 300 OSGi bundles application, my aim was to reuse those in Blueprint with minimal effort. 

I found those two Aries Blueprint components: 

 - "Apache Aries Blueprint Spring Support"

 - "Apache Aries Blueprint Spring Extender Support"
   
.. of which I started using "Apache Aries Blueprint Spring Support" after merging the Spring application context definitions to OSGI-INF/blueprint/*.xml in each bundle that contained them and add Spring namespaces to those (now) blueprint config files. When app starts Spring beans are initialized and seen by blueprint beans. 

One of the bundles uses Spring AOP, and that's where problems started. Since there's very little documentation on the "Apache Aries Blueprint Spring Support" component (found only this http://dev.karaf.apache.narkive.com/TOJsHBOR/discuss-spring-support-in-blueprint) and in this thread (http://karaf.922171.n3.nabble.com/Spring-AOP-example-in-Karaf-tp4030442p4030444.html) from November 2013 it is mentioned that "Apache Aries Blueprint doesn't support Spring AOP", I'm not sure if it is even possible to continue to use Spring AOP after switchting to Aries Blueprint and Aries Blueprint Spring Support. 

I'm plannning on adding Equinox weaving hooks (which were not used so far and it worked properly), configuring AspjectJ via aop.xml - but not sure if any of this will help / resolve this issue I'm hitting at startup, i.e. 
 (...)
[DefaultClassLoader@45fdc0dc] error can't determine annotations of missing type javax.transaction.Transactional
when weaving type org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
when weaving classes 
when weaving 

[Xlint:cantFindType]
[DefaultClassLoader@45fdc0dc] error can't determine annotations of missing type javax.transaction.Transactional
when weaving type org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
when weaving classes 
when weaving  
 (...)
 
... i.e. AOP config being completely ignored and Aspect weaving stuff it should not be touching. 

Below is snippet of AOP config used currently. Your input is much appreciated. 

Regards,
Michal 

---


<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation=" 
   http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">

(...)
<aop:config>
<aop:pointcut id="resourceDaoOperation"
expression="execution(* com.companyName.model.resources.pool.pg.impl.IResourceDao.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="resourceDaoOperation" />
</aop:config>
<aop:config>
<aop:pointcut id="allocationDaoOperation"
expression="execution(* com.companyName.model.resources.pool.pg.impl.IAllocationDao.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allocationDaoOperation" />
</aop:config>
<aop:config>
<aop:pointcut id="rpmServiceOperation"
expression="execution(* com.companyName.model.resources.pool.IResourcePoolManager.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="rpmServiceOperation" />
</aop:config>
<aop:config>
<aop:aspect id="concurrentOperationRetry" ref="operationRetryExecutor">
<aop:pointcut id="idempotentOperation"
expression="execution(* com.companyName.model.resources.pool.IResourcePoolManager.*(..))" />
<aop:around pointcut-ref="idempotentOperation" method="doConcurrentOperation" />
</aop:aspect>
</aop:config>
(...)

</blueprint>