On Tue, Sep 18, 2007 at 04:56:14PM -0400, Rick Reumann wrote:
> I've looked at the wiki post here about Spring:
> http://cwiki.apache.org/WICKET/spring.html
> 
> I'm curious about 'best approaches' and if you bare with me I'll explain my
> concern, but let me first address what I'll want to do..
> 

I suppose "best approaches" is subjective, but I prefer the @SpringBean
annotations in my pages:

public class App extends WebApplication implements ISpringContextLocator
{
    public ApplicationContext getSpringContext() {
        return 
WebApplicationContextUtils.getWebApplicationContext(getServletContext());
    }
    protected void init() {
        super.init();
        addComponentInstantiationListener(new SpringComponentInjector(this));
    }
}

public class MyPage extends WebPage {

    @SpringBean
    public SomeService someService;

    public MyPage() {
        someService.doSomething();
    }
}

Using an annotation instead of calling createSpringBeanProxy directly
allows me to manually inject test instances of my services/business
delegates to do unit tests.

> (Slight drawaback to this is I'd have to define all the BusinessDelegates as
> spring managed objects - but I can deal with that since it's not a bad
> practice anyway.)

I'd call it a good thing.

jk

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to