Monday, 12 January 2009

Spring and Wicket

I'm trying to use spring in my wicket application to its full effect. One thing I'm using right now is the tag. This allows us to specify the name of a method and the spring bean it should return when called. Its a child tag of bean. One thing to note is that the corresponding java class becomes abstract and the method is declared as abstract. This is so that at run time the spring context will provide a proxy subclass and provide an implementation that returns the bean specified in the context file.

Why might you want to use this? In my wicket application I'm using a SpringComponentInjector to read annotations in my java classes and inject dependencies accordingly. I don't have an application context to call getBean on. If I want to create an instance of a class containing annotated dependencies (of spring prototype scope) the lookup-method is perfect for giving me a new instance of a configured spring bean on demand.

No comments: