Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » When does Virgo register the ApplicationContext service?(get the service reference to ApplicationContext in Activator return null)
When does Virgo register the ApplicationContext service? [message #632733] Thu, 14 October 2010 06:22 Go to next message
guofeng zhang is currently offline guofeng zhangFriend
Messages: 49
Registered: July 2009
Member
I used the following code in Activator to get a reference to ApplicationContext:
ServiceReference[] appContext = context.getAllServiceReferences("org.springframework.context.ApplicationContext", "(org.springframework.context.service.name=org.planner.service.member.management.implx)");


But the returned value is null.

Has Virgo not yet registered the service when Activator.start() is called, or is there any bug in the above code?
Re: When does Virgo register the ApplicationContext service? [message #632734 is a reply to message #632733] Thu, 14 October 2010 06:24 Go to previous messageGo to next message
guofeng zhang is currently offline guofeng zhangFriend
Messages: 49
Registered: July 2009
Member
The above code is to get the ApplicationContext service registered by its bundle.
Re: When does Virgo register the ApplicationContext service? [message #632776 is a reply to message #632734] Thu, 14 October 2010 09:04 Go to previous messageGo to next message
guofeng zhang is currently offline guofeng zhangFriend
Messages: 49
Registered: July 2009
Member
From the Virgo log, the Activator.start() is called before OsgiBundleXmlApplicationContext is loaded, so the ApplicationContext service is registered later than the call to Activator.start().

Write a class that implements "ApplicationContextAware" and define this class inside the application context is safe to get the instance of ApplicationContext.
Re: When does Virgo register the ApplicationContext service? [message #632790 is a reply to message #632776] Thu, 14 October 2010 09:41 Go to previous message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
You seem to have answered your own question. Well done! Smile

The Spring DM extender in Virgo kicks in when the bundle STARTED event is broadcast, which is after any bundle activator has returned.

Note that for bundle artifacts deployed by Virgo, Virgo tracks the completion of both the synchronous portion of the start, which includes calling any bundle activator, and the asynchronous portion of the start, which includes the Spring DM extender building any application context and publishing it in the service registry, and only when both these have completed successfully changes the bundle install artifact state (visible on the admin console and elsewhere) from STARTING to ACTIVE. If either fail, there is appropriate error handling and diagnostics. If the asynchronous portion takes an extended time, then warnings are issued periodically.
Previous Topic:can't import groovy-all bundle
Next Topic:Error on startup for Virgo M6
Goto Forum:
  


Current Time: Thu Apr 25 15:26:58 GMT 2024

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

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

Back to the top