You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Huhn <am...@insightbb.com> on 2007/11/07 05:11:47 UTC

T5: Preparing a pristine object for re-use

Hello,

I have a DAO that I want to re-initialize every time it is injected
(that is, the DAO has state that I want to reset to make it pristine).
I thought I could do it in the constructor for the DAO, since I am
defining the service as follows in my AppModule:

public static AccountDAO buildAccountDAO( Session prmSn )
{
  return new AccountDAOImpl( prmSn );
}

But it appears the constructor is only being executed the first time the
DAO is injected, it is not being executed on subsequent injections.  Am
I missing something?

Thanks,
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: T5: Preparing a pristine object for re-use

Posted by Andy Huhn <am...@insightbb.com>.
Bless you, Kris!  This is exactly what I needed!  I've been reading the
mailing list religiously, and trying to dig through the documentation.
I saw the discussion you referenced, but a lot of it went over my head.

Thanks very much!

Andy

On Wed, 2007-11-07 at 09:05 +0100, Kristian Marinkovic wrote:
> the default scope of a service is "singleton".
> 
> i you want a new DAO on every request you 
> can annotate you method with :
> 
> @Scope(IOCConstants.PERTHREAD_SCOPE)
> 
> if  you are using tapestry-hibernate you can have
> your session injected into a "singleton" scoped 
> service and tapestry will take care of it.
> 
> please see the documentation and search the
> mailinglist. there was a very good thread a week
> ago
> 
> e.g. 
> http://www.nabble.com/T5%3A-%27wrapping%27-hibernate-DAOs-as-services-tf4710067.html#a13466570
> 
> g,
> kris
> 
> 
> 
> 
> Andy Huhn <am...@insightbb.com> 
> 07.11.2007 05:11
> Bitte antworten an
> "Tapestry users" <us...@tapestry.apache.org>
> 
> 
> An
> Tapestry users <us...@tapestry.apache.org>
> Kopie
> 
> Thema
> T5: Preparing a pristine object for re-use
> 
> 
> 
> 
> 
> 
> 
> Hello,
> 
> I have a DAO that I want to re-initialize every time it is injected
> (that is, the DAO has state that I want to reset to make it pristine).
> I thought I could do it in the constructor for the DAO, since I am
> defining the service as follows in my AppModule:
> 
> public static AccountDAO buildAccountDAO( Session prmSn )
> {
>   return new AccountDAOImpl( prmSn );
> }
> 
> But it appears the constructor is only being executed the first time the
> DAO is injected, it is not being executed on subsequent injections.  Am
> I missing something?
> 
> Thanks,
> Andy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: T5: Preparing a pristine object for re-use

Posted by Kristian Marinkovic <kr...@porsche.co.at>.
the default scope of a service is "singleton".

i you want a new DAO on every request you 
can annotate you method with :

@Scope(IOCConstants.PERTHREAD_SCOPE)

if  you are using tapestry-hibernate you can have
your session injected into a "singleton" scoped 
service and tapestry will take care of it.

please see the documentation and search the
mailinglist. there was a very good thread a week
ago

e.g. 
http://www.nabble.com/T5%3A-%27wrapping%27-hibernate-DAOs-as-services-tf4710067.html#a13466570

g,
kris




Andy Huhn <am...@insightbb.com> 
07.11.2007 05:11
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>


An
Tapestry users <us...@tapestry.apache.org>
Kopie

Thema
T5: Preparing a pristine object for re-use







Hello,

I have a DAO that I want to re-initialize every time it is injected
(that is, the DAO has state that I want to reset to make it pristine).
I thought I could do it in the constructor for the DAO, since I am
defining the service as follows in my AppModule:

public static AccountDAO buildAccountDAO( Session prmSn )
{
  return new AccountDAOImpl( prmSn );
}

But it appears the constructor is only being executed the first time the
DAO is injected, it is not being executed on subsequent injections.  Am
I missing something?

Thanks,
Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org