Skip to main content



      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 10:49 Go to next message
Eclipse UserFriend
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 10:50] by Moderator

Re: Spring context visibility between modules [message #661030 is a reply to message #660981] Tue, 22 March 2011 15:34 Go to previous messageGo to next message
Eclipse UserFriend
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 10:45 Go to previous messageGo to next message
Eclipse UserFriend
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 17:46 Go to previous message
Eclipse UserFriend
Edit.

Thanks i wll try that.

[Updated on: Fri, 25 March 2011 06:52] by Moderator

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


Current Time: Fri Jul 04 14:08:23 EDT 2025

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

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

Back to the top