2005/12/14, Christian Essl <[EMAIL PROTECTED]>: > > > With AspectJ you can use good citizen as well. I saw the wiki and a > > nice solution was found. With AspectJ is you can code naturally like > > (if you do not use the service in constructor): > > > > MyPage page = new MyPage(); > > page.setService(mockService); > > tester.startPage(page); > > tester.assertRenderedPage(MyPage.class); > > > > instead of setting the context mock, which is a nice solution as well. > > I use the Injector only on BookmarkablePages otherwise I inject by hand - > a lot of real DI citicens. And for the BookmarkablePages I have two > constructors one which calls the Injector the other one which does not. So > I don't even have to set context mock. There is no difference to AspectJ. >
Yes, both you and Igor are right, it can be done with the proxy approach as well. I am curious about good citizen usage. Suppose I have a case when only the SecondPage is using some service, and FirstPage and SecondPage are instantiated with the new operator and applying good citizen. Besides only SecondPage needs the service, the service is injected at HomePage, and FirstPage references as well. I do like good citizen, but in this case it is unnecessarily coupling some pages to the service. HomePage: setResponsePage(new FirstPage(service)); FirstPage: setResponsePage(new SecondPage(service)); > > > > > I don't know if IoC means the container must manage the lifecycle, I > > would go for something like "the environment is the responsible". > > Using AspectJ you are setting the environment to do DI for you, so > > inverting the control; the page (or its superclass) is not looking for > > the dependency, an outside code it is. > > Please see the arictel of Fowlers > (http://www.martinfowler.com/articles/injection.html). According to this > articel I'd say both AspectJ and the Injector use more the ServiceLocator > pattern than DI. The ServiceLocator is the SpringContext. Something Spring > is very proud of is that no bean is dependent on the ApplicationContext > (because of DI). However this is not true for either the AspectJ approach > nor the current Injector approach, because you'll always need a > ApplicationContext to look up the bean to inject. > I am pretty sold on this. If you take what Igor paste here from hivemind, the aspect is the container, it does not have do be Hivemind, Spring, Pico, etc. With AspectJ approach, the page is not dependent at all at the ApplicationContext. If you track dependencies you would have (for proxy based, something like this): MyPage -> SpringWebPage -> SpringInjector -> ApplicationContext (with AspectJ) MyPage -> SpringBean (the annotation) SpringBeanAspect -> SpringBean (the annotation) The page is only tied to the annotation, it does nothing about ApplicationContext, no reference at all. There is no coupling between the page and the aspect, that's why is a really IoC solution. > I think for Wicket the current lookup aproach is very good (for various > reasons already discussed) and I realy do not see an advantage of AspectJ. > > Beside this (the new) AspectJ has an issue with (old) CGLIB (see the CGLIB > users list) and this is extensively used in a lot of projects (like > Hibernate, Spring etc). > I am not writing any real applications, only prototypes, but I am having no problems at all. > Christian > > > > > > > ___________________________________________________________ > Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > _______________________________________________ > Wicket-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/wicket-user > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id865&op=click _______________________________________________ Wicket-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/wicket-user
