You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Holloway <bi...@gmail.com> on 2007/08/17 01:46:40 UTC

T4: Instance method dangers

I want to "cache" a rountrip to a database in an instance method of a
page class like this:

public FlowDataPageContent getFlowDataPageContent() {
    	
    	if (_pageContent == null)
    	{
    		_pageContent = getContentService().getFlowDataPageContent(/*
some data in an ASO */);
    	}
    	

    	return _pageContent;
    }

content service is injected by Spring.

Am I going to get into threading/concurrency problems here?  Is there
a more elegant way to avoid multiple round trips to the database
accessed by my service?

Bill

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


Re: T4: Instance method dangers

Posted by Bill Holloway <bi...@gmail.com>.
Thanks!   I'll talk to the service layer/Spring people tomorrow about
pushing the caching down into the service there.  They've been
thinking about using os cache or something.

bill

On 8/16/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> It's thread safe.
>
> A more elegant method may be to push the caching out to something more
> generic like your database or object caching strategies such as is
> used in things like hibernate.
>
> Some properties - such as those passed in as parameters to components
> - are sometimes cached by tapestry during render already as well.
>
> On 8/16/07, Bill Holloway <bi...@gmail.com> wrote:
> > I want to "cache" a rountrip to a database in an instance method of a
> > page class like this:
> >
> > public FlowDataPageContent getFlowDataPageContent() {
> >
> >         if (_pageContent == null)
> >         {
> >                 _pageContent = getContentService().getFlowDataPageContent(/*
> > some data in an ASO */);
> >         }
> >
> >
> >         return _pageContent;
> >     }
> >
> > content service is injected by Spring.
> >
> > Am I going to get into threading/concurrency problems here?  Is there
> > a more elegant way to avoid multiple round trips to the database
> > accessed by my service?
> >
> > Bill
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> 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: T4: Instance method dangers

Posted by Jesse Kuhnert <jk...@gmail.com>.
It's thread safe.

A more elegant method may be to push the caching out to something more
generic like your database or object caching strategies such as is
used in things like hibernate.

Some properties - such as those passed in as parameters to components
- are sometimes cached by tapestry during render already as well.

On 8/16/07, Bill Holloway <bi...@gmail.com> wrote:
> I want to "cache" a rountrip to a database in an instance method of a
> page class like this:
>
> public FlowDataPageContent getFlowDataPageContent() {
>
>         if (_pageContent == null)
>         {
>                 _pageContent = getContentService().getFlowDataPageContent(/*
> some data in an ASO */);
>         }
>
>
>         return _pageContent;
>     }
>
> content service is injected by Spring.
>
> Am I going to get into threading/concurrency problems here?  Is there
> a more elegant way to avoid multiple round trips to the database
> accessed by my service?
>
> Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

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