On Sat, Aug 6, 2011 at 8:30 PM, Eranda Sooriyabandara <0704...@gmail.com> wrote: > Hi Jean-Sebastian, > I was bit confused on how am I going to maintain the relationship between > Session, Database and Group. With all these methods I am kind of lost in the > middle in choosing one. If you can call one for me I can work on it. > First I was thought of keep some status for the component but later I > realized that constructor injection will be more applicable since I have > constructors with Complex datatypes. What do you think? > In the middle of implementing I got the following problems, > Can we parse a complex datatype as a constructor parameter. > When we going to initialize the class (call the constructor). > Can we access the Objects of Session, Database and Group in the client and > access its method. > > thanks > Eranda
I had a similar use case, and I modeled it like two compoments : DataSource and DataAccess, DataSource had multiple properties which were mostly database specific configuration required to instantiate a "connection" and Data Access had a reference to a dataSource which got injected by SCA. If I understand your concept of session, you might be able to handle that by using "scopes" where a singleton DataSource/DataAccess would be "injected" into a service that requires persistence access. You might need to play a little bit with generics to allow your DataSource to create different types of connections based on what persistence implementation you are utilizing. -- Luciano Resende http://people.apache.org/~lresende http://twitter.com/lresende1975 http://lresende.blogspot.com/