If you like the "do-it-all-in-Java" philosophy that Wicket follows, then you might prefer Guice over Spring. There is no XML configuration in Guice - it is all done using the Guice Module
class.
For example, your Wicket WebApplication
class might look something like this:
public class SampleApplication extends WebApplication
{
@Override
protected void init()
{
addComponentInstantiationListener(
new GuiceComponentInjector(this, new GuiceModule()));
}
}
The GuiceComponentInjector
comes from the wicket-guice extension. Here's the Module:
public class GuiceModule extends AbstractModule
{
@Override
protected void configure()
{
// Business object bindings go here.
bind(Greetings.class).to(GreetingRepository.class);
}
}
In this example, Greetings
is an interface implemented by a concrete GreetingRepository
class. When Guice needs to inject a Greetings
object, it will satisfy the dependency with a GreetingRepository
.
There is a more complete example at the Wicket Examples page. Also, I have put together a sample project that demonstrates how to build a Wicket/Guice application for Google App Engine. The code is in the Subversion trunk. You can safely ignore the App Engine specifics and focus on how the Wicket-Guice integration works.