On 6/23/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:



> > class PersonModel extends LoadableDetachableModel {
> >    @SpringBean
> >    private PersonDao dao;
> >    private final long id;
> >    public PersonModel(long id) {
> >      this.id=id;
> >      InjectorHolder.getInjector().inject(this);
> >    }
> >    ...
> > }
> >
>
> Ah very interesting to see this is possible. Still I am thinking why
> this would be better than using the application to hold the DAOs.
>

this is better because if you use applications to hold non-proxied daos
you have to be very careful not to leave a reference to it anywhere. because
dependencies injected throgh @SpringBean are special proxies you dont have
to worry about it because the proxies can be safely serialized.


I do understand that. But isn't it very easy to avoid it? For example the
PersonClass would be something like this:

class PersonModel extends LoadableDetachableModel {
  private final long id;
  public PersonModel(long id) {
    this.id=id;
  }

 private PersonDao getDao() {
   return MyApplication.get().getPersonDao();
  ...
}

With this getter there is no temptation to save the DAO as a field.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to