did you see SpringPage class? it calls the SpringInjector.inject(this) in its default constructor so if you extend from that page you never have to call SpringInjector directly in your own code. you cane make a SpringPanel that does the same. that should cover the two mostly used use cases.
-Igor
On 11/29/05, Joni Suominen <[EMAIL PROTECTED]> wrote:
I finally got some time to take a look at the latest spring integration
work. Looks very good! It really seems to be a good way to integrate
spring + wicket. It is still possible to use wicket in a wicket way
(using constructors to instantiate components) and get the benefits of
ioc. There's one minor issue which could probably be fixed though. It
currently expects explicit calls to method SpringInjector.inject(...) to
inject the proxies. I made a small bootstrapper which uses Java 5
instrumentation + asm bytecode library to inject SpringInjector to all
classes which has @SpringBean annotation. Using the bootstrapper the
integration can be done just by tagging the dependencies with
annotation:
public class MyComponent extends Panel {
@SpringBean
private ContactDao contactDao;
public MyComponent() {
this(id, new Model("test")); // inject
SpringInjector.inject (this) after this line
add(new TextField("field"));
}
}
A call to SpringInjector.inject(this) will be injected between the two
lines in above constructor. Do you see any problems with this approach?
I attached the bootstrapper jar if anyone wants to give it a try.
Usage:
1. Remove explicit calls to SpringInjector.inject()
2. Start the vm giving the bootstrapper as an instrumentation agent.
E.g:
java -javaagent: wicket-contrib-spring-bootstrap-1.0.jar ......
--
Joni Suominen
