0

Basically, I want to be able to use Spring to do this in an OSGI bundle:

  • use applicationContext.xml to define beans and proxy and decorate them
  • use @Transactional on a method to give it a transaction (Spring will need to proxy it)

I understand that there is Spring DM which has been retired into Eclipse Gemini. I can still use spring DM 2.0 that will allow me point 1 with spring blueprint? Is there a way to use 'regular' Spring to do this too?

How do I do point 2? Is it possible to use Spring in OSGI bundle to provide transactions? Has anyone done this successfully?

Should I stay away from Spring in OSGI, or is there more that I'm not aware of?

che javara
  • 748
  • 1
  • 8
  • 18

1 Answers1

0

Well you can still use Spring-DM even the "old" 1.2.1, though I really suggest switching to Blueprint, it just runs smoothly with OSGi and isn't much different then Spring itself. Especially since you want to do transactions on your beans. My favorite setup is Blueprint (either Aries or Gemini) with OpenJPA, it works best in a OSGi environment.

Here a simple sample on how to do this with Aries Blueprint

<bean id="myDao" class="my.project.dao.jpa.MyJpaDao">
<jpa:context property="em" unitname="persistenc-unit" />
<tx:transaction method="*" value="Required" />
</bean>

With the you are able to make any method transaction on that class. I usually keep those DAO object in a separate bundle only containing my entity classes and DAOs. To get a hold of these DAOs in my application I register as Services

<service id="myDAO" ref="myDao" interface="my.project.dao.MyDao" />

Now for you it is still possible to do a "soft" transferal to blueprint with that. If you keep your entities seperate in an extra bundle like I did you just need to reference those DAO-Services from your Spring (in conjunction with Spring-DM, in this case it's recomndet to stick to spring-dm 1.2.1, you'll get really bad issues otherwise), and go from there on with your std. spring application. That's the real beauty of OSGi, you are able to mix all those Service Frameworks as you like.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22