[Building Sakai] wiring up potentially null services

View: New views
2 Messages — Rating Filter:   Alert me  

[Building Sakai] wiring up potentially null services

by John Bush-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm working on a project where we have an optional service, similiar  
to say the ContentReviewService.  You can't directly inject in spring  
because the bean might not exist.  I've typically solved this by  
making a call directly to the component manager in the code that  
requires the service, and then testing for null everywhere.  I've been  
told there might be something in EntityBroker or somewhere else that  
can handle this more elegantly.   Ring a bell for anyone ?

John Bush
Development Manager
rSmart




_______________________________________________
sakai-dev mailing list
sakai-dev@...
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev

TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe@... with a subject of "unsubscribe"

Re: [Building Sakai] wiring up potentially null services

by Aaron Zeckoski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yeah, I think you want to look at this code:
https://source.sakaiproject.org/svn/entitybroker/trunk/utils/src/java/org/sakaiproject/entitybroker/util/spring/BeanCollectorAutoRegistrar.java

You can use the same technique or actually use it directly if you like.
Hope that helps!
:-)
-AZ


On Wed, Nov 4, 2009 at 6:01 PM, John Bush <john.bush@...> wrote:

> I'm working on a project where we have an optional service, similiar to say
> the ContentReviewService.  You can't directly inject in spring because the
> bean might not exist.  I've typically solved this by making a call directly
> to the component manager in the code that requires the service, and then
> testing for null everywhere.  I've been told there might be something in
> EntityBroker or somewhere else that can handle this more elegantly.   Ring a
> bell for anyone ?
>
> John Bush
> Development Manager
> rSmart
>
>
>
>
>



--
Aaron Zeckoski (azeckoski (at) vt.edu)
Senior Research Engineer - CARET - University of Cambridge
https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
http://aaronz-sakai.blogspot.com/ - http://tinyurl.com/azprofile
_______________________________________________
sakai-dev mailing list
sakai-dev@...
http://collab.sakaiproject.org/mailman/listinfo/sakai-dev

TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe@... with a subject of "unsubscribe"