2005/12/14, Igor Vaynberg <[EMAIL PROTECTED]>:
> it /used to be/ difficult to test objects that used auto-injection. it has
> been worked out now. see the wiki spring page for details. most of the
> objects however, such as detachable models and idataproviders are easier to
> test then with aspectj because they follow the good citizen pattern when
> proxies are used.
>

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.

> aspectj is not a pure solution either. it does exactly what the Injector
> does, it injects dependencies when they are first accessed. a pure IOC
> solution would have the container manage the lifecycle of the page
> (container.getPage (Clazz clazz, Object[] params), until that happens none
> of these solutions are "pure", and IOC is not always the best tool for the
> job.
>

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.

Besides, with AspectJ this kind of DI can be used everywhere, it is
not tied to Wicket pages, it is a general solution, as Spring 2.0 will
bring.

> -Igor
>
>
>
> On 12/14/05, Eduardo Rocha <[EMAIL PROTECTED]> wrote:
> >
> > I have seen a lot of discussion on how properly write unit test code
> > with these proxies, does a neat solution was found? Using AspectJ
> > makes natural setting mocks, since it checks to see whether the field
> > is null. Also, it is a true IoC solution, and besides proxing does DI,
> > it isn't a "pure" solution.
> >
> > 2005/12/14, Christian Essl <[EMAIL PROTECTED]>:
> > > Me too. I see no reason in using AspectJ. Just use interfaces (which is
> > > nearly always good design) and everything works fine. And in face of
> DAOs
> > > the performance problem of the reflective method call is not realy
> there.
> > >
> > > Christian
> > >
> > > On Wed, 14 Dec 2005 08:00:37 -0800, Igor Vaynberg
> > > <[EMAIL PROTECTED]> wrote:
> > >
> > > > aspectj sounds pretty sweet. i guess it would work in majority of
> cases.
> > > > the
> > > > reason i would still prefer proxies is because I like constructs like
> > > > this:
> > > >
> > > > MyDataProvider implements IDataProvider {
> > > >   private MyService svc;
> > > >
> > > >   MyDataProvider(MyService svc) {
> > > >     this.svc=svc;
> > > >   }
> > > > ...
> > > > }
> > > >
> > > > this allows me to use the same dataprovider on a subset of services
> that
> > > > all
> > > > extend the same subinterface. and i think in general its more clear
> when
> > > > you
> > > > write code like
> > > > MyDataProvider provider=new MyDataProvider(service);
> > > >
> > > > but this is just a personal preference.
> > > >
> > > > -Igor
> > > >
> > > >
> > > >
> > > > On 12/14/05, Christian Essl <[EMAIL PROTECTED]> wrote:
> > > >>
> > > >> Right. Thanks for the advice :)
> > > >>
> > > >> BTW If you do not use interfaces, you can also not advice final
> methods
> > > >> or
> > > >> methods on a final class.
> > > >>
> > > >> The concern here is that when you do not use an interface proxy this
> > > >> also
> > > >> applies to the proxies which we use in spring-integration. This is a
> > > >> limitation of cglib, which is used by both Spring-AOP and
> > > >> Spring-integration proxies, when the proxy-type needed is not (an)
> > > >> interface(s).
> > > >>
> > > >> Christian
> > > >>
> > > >> On Wed, 14 Dec 2005 14:01:35 +0100, Laurent PETIT
> > > >> < [EMAIL PROTECTED]> wrote:
> > > >>
> > > >> > On 12/14/05, Christian Essl <[EMAIL PROTECTED]> wrote:
> > > >> >> AspectJ modfies the byte-code of your class while Spring-AOP
> either
> > > >> >> creates a proxy or a subclass. This means that ie in Spring-AOP
> you
> > > >> can
> > > >> >> not advice field acess or statements within a method. Basicly with
> > > >> >> spring
> > > >> >> AOP you can only adivce calls to a certain method.
> > > >> >
> > > >> > Hello, it's not totally right to say "spring AOP you can only
> adivce
> > > >> > calls to a certain method". Reality is a bit worse:
> > > >> >
> > > >> > With spring AOP, you can only advice method calls when the calls
> > > >> > originate from an instance that is not the instance that holds the
> > > >> > method.
> > > >> > So : if the method AClass.method1 is adviced with springAOP, and if
> in
> > > >> > a method AClass.method2 you do something like this.method1() then
> you
> > > >> > don't use the proxied instance and springAOP will not work.
> > > >> >
> > > >> > So with spring AOP, you can't advice private methods, and you can
> > > >> > advice (default), protected and public methods as long as you do
> not
> > > >> > call them directly from other methods of the same instance.
> > > >> >
> > > >> >
> > > >> > My 0.02 EUR,
> > > >> >
> > > >> > --
> > > >> > Laurent
> > > >> >
> > > >> >
> > > >> >
> -------------------------------------------------------
> > > >> > 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
> > > >>
> > > >>
> > > >>
> > > >> --
> > > >> Christian Essl
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> ___________________________________________________________
> > > >> 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
> > > >>
> > >
> > >
> > >
> > > --
> > > Christian Essl
> > >
> > >
> > >
> > >
> > >
> > >
> ___________________________________________________________
> > > 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&opclick
> > _______________________________________________
> > 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

Reply via email to