cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ServiceRegistry from a static method??

eolith
Champ on-the-rise
Champ on-the-rise
Hello,

I need to access some foundation services (NodeService) from a static method in a Java class. How can I do it?? I can't find a way to do Spring dependency injection and access that "injected" bean from a static method.

How can I do it?? Thanks.
2 REPLIES 2

jayjayecl
Confirmed Champ
Confirmed Champ
if you have a FacesContext instance "fc", do

serviceRegistry = Repository.getServiceRegistry(fc);

But the better way would be to inject #{serviceRegistry} via Spring. Why coundn't you get it work ?

rogier_oudshoor
Champ in-the-making
Champ in-the-making
You could technically inject a springbean on a static attribute (where the "regular" setMyService(MyService) sets the "static" MyService attribute). You have to ensure that your static method gets called after the spring dependency injection takes place obviously Smiley Wink