@Transactional annotation / atlassian spring scanner?

There is a section in

https://developer.atlassian.com/docs/atlassian-platform-common-components/active-objects/getting-started-with-active-objects

describing how to set up a spring BeanPostProcessor wrapping all components having a @Transactional annotation with a TX-Proxy.

Is there a similar construct to do that stuff with Atlassian Spring Scanner?

Example: 

atlasian-pluginx.xml

<component
   key="tx-processor"
   name="Transactional Annotation Processor" 
   class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
  <decription>Processes @Transactional annotations.</decription>
</component>

 

code:
@Transactional
public interface TestStepService {
 TestStep findById(int testStepId);
 TestStep updateTestStep(TestStep testStep)
}

 

2 answers

1 accepted

This widget could not be displayed.

(1) Remove any ComponentImport annotations from ActiveObjects


// AO is imported via META-INF/spring/plugin-context.xml
// @ComponentImport
com.atlassian.activeobjects.external.ActiveObjects ao;

(2) Configure TransactionalAnnotationProcessor in META-INF/spring/plugin-context.xml descriptor

<beans
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner"
xmlns="http://www.springframework.org/schema/beans"
xmlns:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.atlassian.com/schema/atlassian-scanner http://www.atlassian.com/schema/atlassian-scanner/atlassian-scanner.xsd
http://www.eclipse.org/gemini/blueprint/schema/blueprint http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint.xsd">
<osgi:reference id="ao_osgi">
<osgi:interfaces>
<beans:value>com.atlassian.activeobjects.external.ActiveObjects</beans:value>
</osgi:interfaces>
</osgi:reference>
<beans:bean id="tx-processor" class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
<beans:constructor-arg ref="ao_osgi"/>
</beans:bean>
<atlassian-scanner:scan-indexes/>
</beans>

really? why Atlassian makes this so complicated now - in comparison with the atplassian-pligin.xml style? 

Is there a docu where you found this, because the scanner docu is missing of explicit examples :-/?

There might be some better solution for the problem, but I had no time for further investigations.

Unfortunately I can't point you directly to an appropriate documentation. 

You have to dive into the documentation of the underlying framework stack sad to get some knowledge what is happening behind the scenes. 

You may look for BeanPostProcessor in the spring documentation to get some basic understanding how the TX Annotation is working and then check the Atlassian documentation

 

This widget could not be displayed.

I'll leave it here, it might help somenone:

Keep @ComponentImport and add only

<bean class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
<constructor-arg ref="activeObjects"/>
</bean>

 in the plugin-context.xml.

Works with ao v.1.4.0, atlassian-scanner v1.2.7

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 9 hours ago in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

23 views 3 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you