Hi, Ram.
SCA also supports constructor-based dependency injection. For example,
@Constrcutor
public MyServiceImpl(@Reference OtherService service, @Property prop) {
...
}
Thanks,
Raymond
From: Ramkumar R
Sent: Friday, October 10, 2008 12:56 AM
To: [email protected]
Subject: Should Tuscany support Injection of service references through
Constructors
Hi All,
I came across this requirement, while working with Spring, but I believe
this topic also holds good for Java implementations.
Spring supports Constructor Injection by allowing to inject properties and
objects via the constructors. Not sure if Tuscany should support this
feature? As SCA+Spring depends on Tuscany runtime for binding and dependency
injections.
I believe currently Tuscany supports injection of service references through
getter & setter methods.
This question arises because the biggest benefit of setter injection is that
it allows for circular dependencies. Circular dependencies are actually
pretty common. If you have a UserService that needs to get information about
an employer from CompanyService and the CompanyService needs information
about employees from UserService, right there you have a circular
dependency. In general I find a lot of circular dependencies between service
methods, but with complex object models it is possible to have circular
dependencies elsewhere.
So considering the circular dependency issue, I believe it would be a bad
idea to support the same in Tuscany.
Like to hear from the community for more insight on this topic and how we
should go about it.
--
Thanks & Regards,
Ramkumar Ramalingam