|
From: Dain S. <da...@iq...> - 2005-05-30 15:54:17
|
On May 30, 2005, at 12:19 AM, Alexandru Popescu wrote:
> If you search the forum you will find different solutions to the
> above problem. I was looking for
> the same thing for a while, and currently i am quite happy with a
> modified solution I've found on forum.
Can you give me a hint on what to search for? I could spend hours
looking for this.
> For the 2nd question: do you need another method call than the
> after-init?
I'm not sure what you mean. In geronimo the normal geronimo bean
creation process is:
1) call constructor
Foo foo = new Foo(a, b, c)
2) setter inject including dynamic properties (order is not important)
foo.setBar(bar)
foo.setAtttibute("baz", baz);
foo.setCheese(cheese);
foo.setAtttibute("donkey", donkey);
3) call initialization done method
foo.doStart();
So all injection must occur before the initialization method. I can
think of two ways to support dynamic properties directly in spring:
1) specifically support them by a dynamicSetterName field to the bean
definition, and either automatically assume that any property without
a setter is a dynamic property, or have some way for a user to flag a
property as dynamic
2) generically support additional initialization methods (with
arguments) before the final after-init method is called. This would
require adding a list of method names with args to invoke. For the
args, you could just the same matching rules as constructor injection.
The first option is simpler and cleaner, but the second is much more
powerful (more complex and a bit ugly).
-dain
|