cancel
Showing results for 
Search instead for 
Did you mean: 

ServiceRegistry or Spring injection?

sandermvdb
Champ in-the-making
Champ in-the-making
What is the best way of retrieving the Repository Services, by using the ServiceRegistry or by wiring it together using Spring injection? What are the advantages and disadvantages of either way?
6 REPLIES 6

mitpatoliya
Star Collaborator
Star Collaborator
Injecting only required services is best practice.

Do you mean the best way is to only inject the ServiceRegistry and get all other services from this ServiceRegistry?
And why is this 'better' than injecting all necessary services using Spring?

mrogers
Star Contributor
Star Contributor
No.   IMHO I'm allergic to the service registry and wish it had never been written.

If you are using spring then you inject your dependencies. That's what spring does!   Then you can unit test your code,  write interceptors,  restructure your code and clearly see the dependencies.     If you use the service regictry it injects a big blob of junk into your code that you have no control over.

sandermvdb
Champ in-the-making
Champ in-the-making
Thanx for this helpfull comment!
And how about the Spring annotation @Autowired? Can this be used with Alfresco (so I don't need the bean refs in the XML and the setters in my Java code)?

mrogers
Star Contributor
Star Contributor
I've got a nasty feeling that alfresco's version of spring is so old it's not got @autowired.    Yes updating spring is on the todo list.

sandermvdb
Champ in-the-making
Champ in-the-making
Ok, then I will use the regular way of injecting services.
Tx!