Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gemini » Influence Interface AOP Proxy on osgi:reference side(the proxy creation for osgi:reference can in hist turn be subject to proxy creation. Can it be regulated ?)
Influence Interface AOP Proxy on osgi:reference side [message #678414] Thu, 09 June 2011 14:30 Go to next message
Wim Ockerman is currently offline Wim OckermanFriend
Messages: 2
Registered: June 2011
Junior Member
Hi,

We were experiminting with Annotating Transaction Demarcation on Service Interfaces of which the implementation is registerred using SpringDM to osgi.

It seams that the annotations also triggers an additional (unexpected for us) proxy creation in or around the sprin DM proxy for an osgi:reference bean.

Is there a way around this ?

Through some own investigation I noticed the following callstack decides that a proxy is needed due to the annotations

at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)


In the wrapIfNecessary method a call to isInfrastructureClass is done to see if the handled bean is not an Advice, Advisor or AopInfrastructureBean compatible class.

Can it be a solution to have this interface extended or implemented by one of the SpringDM constructs to hold of the proxy creation ?

Or is there knowledge of a better way to avoid such proxying ?

Re: Influence Interface AOP Proxy on osgi:reference side [message #681764 is a reply to message #678414] Thu, 09 June 2011 20:12 Go to previous messageGo to next message
Costin Leau is currently offline Costin LeauFriend
Messages: 45
Registered: February 2010
Member
Can you post a snippet of your configuration - specifically how you enable transaction demarcation and import the services.

Regarding importing what type of reference do you have - single or multiple? The former generates a proxy through Spring infrastructure which automatically adds the Advise interface (you can verify this yourself by getting the bean class and looking at the interfaces). The latter does not since it's a collection not a proxy.

Note that all these interfaces indicate an actual advice to be applied - not really an actual bean. Depending on your use case the imported service might be or not proxied depending on your usage.

I'd be interested in getting more data on your references (and their classes) to see why the double proxying occurs.
As a separate solution you can define a different pointcut in the transaction configuration to make sure you exclude these beans in the first place or not import the annotations (so they don't become visible on the interface).

The service references are meant to resemble as much as possible the actual services so the best to consider them (or not) is to use a proper pointcut rather then rely on the Spring infrastructure interfaces.
Re: Influence Interface AOP Proxy on osgi:reference side [message #683713 is a reply to message #681764] Tue, 14 June 2011 09:37 Go to previous message
Wim Ockerman is currently offline Wim OckermanFriend
Messages: 2
Registered: June 2011
Junior Member
We were using <tx:annotation-driven/> in both using bundle and serving bundle spring configs. This because our using bundle also contains a service which needed transactional wrapping.

We're using osgi:reference, so a single reference. You said this generates a proxy through spring, so it is clear for us now that through this path the <tx:annotation-driven/> will see the annotations on the interface on which the proxy is based and thus transactionally wrap it.

We're now investigating as you suggested the use of a pointcut to restrict the beans on which the transaction annotation may have an effect.

We're experimenting now with an AOP config like the following in both bundles:
    <tx:advice id="tx-advice" transaction-manager="transactionManagerOSGI"/>
    
    <aop:config>
      <aop:pointcut id="serviceOperation" expression="within(ourpackagename.impl.*)"/>
      <aop:advisor 
        pointcut-ref="serviceOperation"
        advice-ref="tx-advice"/>
    </aop:config>


The tx:advice use without tx:attributes by default creates then an AnnotationTransactionAttributeSource, which picks up only at the required beans, the annotations defined by the implementation's interfaces.

Initial testing shows positive results this way. We still have to do full ivt tests to see if this has no adverse effects.

Thanks for the insight in how the proxies are created.

Previous Topic:Gemini Maven repository
Next Topic:Gemini JPA Mission Statement?
Goto Forum:
  


Current Time: Thu Apr 25 15:26:59 GMT 2024

Powered by FUDForum. Page generated in 0.02559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top