What is the best way to use transactional active objects?

I see the following alternatives and do not know which one is better than the other.

a) Keep @ComponentImport annotation on your classes where you require ActiveObjects like this:

@ComponentImport
private ActiveObjects activeObjects;

And in combination with this add the following to the Spring configuration:

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

This solution is based on the ActiveObjects component being available under the name activeObjects or else this will not work.

b) Remove all @ComponentImport annotations from your code and require Spring to resolve ActiveObjects with OSGi so that there is only one instance available to your classes.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="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/2"
       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/2
         http://www.atlassian.com/schema/atlassian-scanner/2/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="activeObjects">
        <osgi:interfaces>
            <value>com.atlassian.activeobjects.external.ActiveObjects</value>
        </osgi:interfaces>
    </osgi:reference>

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

    <atlassian-scanner:scan-indexes/>

</beans>   

Can anybody tell me which of those two alternative is the better way or whether there is another solution to favor over those two?

1 Like

Have you ever thought of using Atlassian Spring Scanner.

Using above has made my life much more simple.

As you can see from the configuration in my question I am already using Atlassian Spring Scanner but struggling with the best way to inject the Active Objects instance into the Bean Post Processor to handle @Transaction annotations on my service interfaces.

So your answer does not help me to choose from the alternatives I have listed in my question.

@Transaction annotation is not implemented in JIRA. The only way I know is to create a custom transaction object.
https://jira.atlassian.com/browse/JRASERVER-25808

1 Like