On Mon, 19 Mar 2012 16:04:24 -0300, Ferran Maylinch <ferranmayli...@gmail.com> wrote:

Hello,

Hi!

We have 6 "child" services that extend a "parent" service class. This
parent service class has 3 dependencies that are only needed in methods
inside that parent class. How would we configure these services?

Exactly the way you would in other scenarios: field inject (@Inject) or constructor injection (my preferred).

One solution would be to add 3 innecessary parameters to the constructor of each "child" service:

They aren't unnecessary at all. You're subclassing a class, let's call it P, and P needs X, Y and Z. The subclasses of P *are* P instances, so they do depend on P's dependencies. Just pass the parent dependencies in the super() call to the parent constructor.

class Child extends P {

        ...
        public Child(X x, Y y, Z z, ChildDependency childDependency) {
                super(x, y, z);
                this.childDependency = childDependency;
        }

}

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to