Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Spring context visibility between modules(Spring DM 1.2)
Spring context visibility between modules [message #660981] Tue, 22 March 2011 14:49 Go to next message
damien charpentier is currently offline damien charpentierFriend
Messages: 3
Registered: March 2011
Junior Member
Hi,
I am using Spring DM 1.2(Virgo) and it works great so far but i am having a design issue.

Imagine two bundles, bundleA and BundleB.

Object ConsumerA from BundleA uses an object ProducerB from BundleB.
Now ProducerB encapsulates a bean BeanC injected from the spring context via @Autowired annotation. BeanC is created with information from a property file.

Now, when ConsumerA calls ProducerB, BeanC is not in its scope. A beanNotfoundException is thrown.


I did make it work by referencing BeanC as a service in the service registry but it is not what i want in the end because it is too tight coupled.

Do you have any idea about it? Maybe to redesign how i am doing it?

For more info, my producerB is a Hibernate constraint validator. ConsumerA is JSF2 BeanValidator.


Thanks !!!

[Updated on: Tue, 22 March 2011 14:50]

Report message to a moderator

Re: Spring context visibility between modules [message #661030 is a reply to message #660981] Tue, 22 March 2011 19:34 Go to previous messageGo to next message
damien charpentier is currently offline damien charpentierFriend
Messages: 3
Registered: March 2011
Junior Member
Reply to myself, we are working on a factory. Will come back as soon as we get something conclusive.
Re: Spring context visibility between modules [message #661405 is a reply to message #660981] Thu, 24 March 2011 14:45 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 279
Registered: January 2010
Senior Member
With SpringDM each bundle has its own individual appContext. There is no sharing of contexts between bundles.

If you need to share types, use Import-Package/Import-Bundle etc.
If you need to share "beans" - use services.

Assuming:

1. A depends on B. (i.e. A has an Import-Package: b)
2. Both A and B need to create Spring application context.

In B set-up an app context with beans ProducerB and BeanC. Inject BeanC into ProducerB. Publish ProducerB as a service.

<osgi:service internface="ProducerBInterface" ref="producerB"/>

In A, import ProducerB as a service
<osgi:reference id="producerB" interface="producerBInterface"/>
Inject "producerB" bean into ConsumerA and use it.

Regards,
Dmitry
Re: Spring context visibility between modules [message #661485 is a reply to message #661405] Thu, 24 March 2011 21:46 Go to previous message
damien charpentier is currently offline damien charpentierFriend
Messages: 3
Registered: March 2011
Junior Member
Edit.

Thanks i wll try that.

[Updated on: Fri, 25 March 2011 10:52]

Report message to a moderator

Previous Topic:how to partition system to build bundle?
Next Topic:Current Status of Virgo Tooling
Goto Forum:
  


Current Time: Mon Dec 09 04:18:22 GMT 2024

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

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

Back to the top