• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring Transaction using AOP in EJB Project

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My application has only EJB project and no Web tier.
I want to implement spring declarative transaction management using AOP.
How to load the spring context xml?

Thanks in advance,
Gokul
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, the only solution with EJBs is to have your EJBs extend the Spring class that makes EJB Spring App Context aware.

Good Luck

Mark
 
gokul maha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am NOT using EJBs (Session beans) for Transaction Management. I want to use Spring POJO Declarative Transaction Management using AOP. Only entry point to the application is MDB.
Since there is not web project, I am not sure how to load the application context xml where the transaction attributes are defined and let the container be aware of it.

<bean id="sampleManager" class="test.SampleManager">
<property name="dataAccessor" ref ="dataAccessor"/>
<property name="dataSource">
<ref local="dataSource"/>
</property>
</bean>

<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation = "REQUIRED"/>
</tx:attributes>
</tx:advice>

<aop:config>
<aop:pointcut id="testOp" expression="execution(* test.SampleInterface.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="testOp"/>
</aop:config>

<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>

SampleManager implements SampleInterface.


Could you please help on this? Thanks.
 
Ranch Hand
Posts: 85
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can try this, have a web.xml and define a servlet in it like:


then define a main class like:

 
gokul maha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Vivek. But want to know, Can we use web.xml in EJB project?
How this web.xml will be triggered. I dont have any web module/project at all. My application is triggered using MDB.
 
Vivek K Singh
Ranch Hand
Posts: 85
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes you can do that: http://www.eclipse.org/webtools/community/tutorials/ejbtutorial/buildingejbs.html

Also, there are other ways to do this as well. You can have a main method to load the Spring beans. Where to trigger it from can be a bit tricky...
 
gokul maha
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I will try this option.
Once loaded using the above method, the container will take care of the transaction using the attributes in the context xml right ?
 
Vivek K Singh
Ranch Hand
Posts: 85
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah it will...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic