On Oct 27, 2005, at 11:00 AM, Joni Suominen wrote:

On Wed, 2005-10-26 at 10:59 -0700, Igor Vaynberg wrote:

This is similar to how i do it. My application is a spring bean that
gets injected by spring on creation and is then used as a service
locator. I am simply questioning the automatic injection into pages,
does it really make sense if it only takes you half way there. If in
my panel i need to do a ((MyPage)getPage()).getService() then i might
as well do ((MyApp)getApplication).getService().


I agree that it is very bad if Spring integration using IOC can only be
done as a half baked solution. However, I see following problems when
using Spring as a service locator.

1. Unit testing components

It is not feasible to unit test wicket components wired with full blown backend services. We often manually wire the dependencies, which is very
easy in IOC paradigm:

public class MyTest extends TestCase {
     public void setUp() {
         MyComponent myComponent = new MyComponent();
         myComponent.setFinder(new MockFinder());
     }
}

This is of course no problem. In your test cases, simply don't activate the aspect that does the lookup and you will be fine. The annotation in the component or web page does nothing by itself.


2. How to abstract the service locator?

Lets say I'm creating a reusable Dictionary component. I'd like to
abstract away the actual interface to dictionary behind
DictionaryLookupService.

public class Dictionary extends Panel {
    private transient DictionaryLookupService dictionaryLookupService;

    public void onClick() {
         dictionaryLookupService.findWord(...);
         ...
    }
}

This implementation, which expects the implementation of
DictionaryLookupService be injected, does not depend on any particular
page, wicket application or spring API.

I don't see the problem here :-)

 S.



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to