You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Charles Anthony <ch...@hpdsoftware.com> on 2004/07/26 11:06:19 UTC

RE: how to postinitialize objects after being completely material ized

Sheesh - I can't even type my name properly today.

It's got to be Monday.

Cheers,

C.H.A.R.L.E.S.

> -----Original Message-----
> From: Charles Anthony [mailto:charles.anthony@hpdsoftware.com]
> Sent: 26 July 2004 10:05
> To: 'OJB Users List'
> Subject: RE: how to postinitialize objects after being completely
> material ized
> 
> 
> Hi David,
> 
> Another approach : if you get your persistent objects to implement
> org.apache.ojb.broker.PersistenceBrokerAware interface, you could then
> implement the afterLookup method e.g.
> 
> public void afterLookup(PersistenceBroker broker) {
>    _postinit();
> };
> 
> The afterLookup method is invoked after a persistence broker loads the
> object - and, I believe, after any of the references are loaded too.
> 
> Some people would not like this approach (due to the persistency layer
> "invading" your domain objects) - I am not one of them.
> 
> HTH,
> 
> Chaeers,
> 
> > -----Original Message-----
> > From: David Zejda [mailto:dvid@atlas.cz]
> > Sent: 26 July 2004 09:59
> > To: OJB Users List
> > Subject: how to postinitialize objects after being completely
> > materialized
> > 
> > 
> > I have a custom row reader able to initialize materialized 
> objects by
> > their _postinit() methods. Essentially it works, but there is 
> > a problem
> > - the _postinit() should be called after the object is materialized
> > completely, i.e. with all fields, but also references and 
> collections
> > filled. So, I guess I have to override some other method of 
> > rowreader or
> >   something completely different - please, give a hint.
> > 
> > public class RowReaderPostinitializingImpl extends 
> > RowReaderDefaultImpl
> > {
> >      public RowReaderPostinitializingImpl(ClassDescriptor c)
> >      {
> >          super(c);
> >      }
> > 
> >      public Object readObjectFrom(Map row)
> >      {
> >          Object result = super.readObjectFrom(row);
> >          if (result instanceof Postinitializable)
> >          {
> >              Postinitializable art = (Postinitializable) result;
> >              art._postinit();
> >              return art;
> >          }
> >          else
> >          {
> >              return result;
> >          }
> >      }
> > }
> > 
> > David
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> > 
> > 
> 
> 
> ___________________________________________________________
> HPD Software Ltd. - Helping Business Finance Business
> Email terms and conditions: www.hpdsoftware.com/disclaimer 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org