You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Weisu <we...@gmail.com> on 2007/03/13 01:19:18 UTC

[T5]Ioc-Perthread service lifecycle

Hi, I am try to create a perthread service, the following lines are in the
module builder class, how and where can I define cleanupThread() method?
 
@Lifecycle("perthread")
public static EllipseSession buildEllipseSession()
{
return new EllipseSessionImpl();
}
Thanks.
-- 
View this message in context: http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446131
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [WARNING] [T5]Ioc-Perthread service lifecycle

Posted by Weisu <we...@gmail.com>.
Thanks Howard, that works.

Howard Lewis Ship wrote:
> 
> Sorry, that was SVN trunk code (i.e., 5.0.3-SNAPSHOT), for 5.0.2 the
> service id is "tapestry.ioc.ThreadCleanupHub".
> 
> On 3/12/07, Weisu <we...@gmail.com> wrote:
>>
>> Thanks Howard, but I got this msg: Error invoking service builder method
>> com.mainco.ellipse.services.AppModule.buildEllipseSession(ThreadCleanupHub)
>> (for service 'app.EllipseSession'): Service 'app.ThreadCleanupHub' does
>> not
>> exist.
>> This is my code:
>> @Lifecycle("perthread")
>> public static EllipseSession
>> buildEllipseSession(@InjectService("ThreadCleanupHub") ThreadCleanupHub
>> threadCleanupHub)
>>         {
>>         EllipseSessionImpl service = new EllipseSessionImpl();
>>
>>         threadCleanupHub.addThreadCleanupListener(service);
>>
>>         return service;
>>
>>         }
>>
>> Howard Lewis Ship wrote:
>> >
>> > It tends to look like this:
>> >
>> >   @Lifecycle("perthread")
>> >     public static HibernateSessionManager
>> > build(@InjectService("HibernateSessionSource")
>> >     HibernateSessionSource sessionSource,
>> >
>> >     @InjectService("ThreadCleanupHub")
>> >     ThreadCleanupHub threadCleanupHub)
>> >     {
>> >         HibernateSessionManagerImpl service = new
>> > HibernateSessionManagerImpl(sessionSource);
>> >
>> >         threadCleanupHub.addThreadCleanupListener(service);
>> >
>> >         return service;
>> >     }
>> >
>> > In this example, HibernateSessionManagerImpl implements
>> > ThreadCleanupListener, in addition to HibernateSessionManager.
>> >
>> > ThreadCleanupHub is responsible for notifying its listeners at the end
>> > of the request.
>> >
>> > With the "perthread" lifecycle, your service builder method is invoked
>> > at most once per request.
>> >
>> > On 3/12/07, Weisu <we...@gmail.com> wrote:
>> >>
>> >> Hi, I am try to create a perthread service, the following lines are in
>> >> the
>> >> module builder class, how and where can I define cleanupThread()
>> method?
>> >>
>> >> @Lifecycle("perthread")
>> >> public static EllipseSession buildEllipseSession()
>> >> {
>> >> return new EllipseSessionImpl();
>> >> }
>> >> Thanks.
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446131
>> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>> >
>> > --
>> > Howard M. Lewis Ship
>> > TWD Consulting, Inc.
>> > Independent J2EE / Open-Source Java Consultant
>> > Creator and PMC Chair, Apache Tapestry
>> > Creator, Apache HiveMind
>> >
>> > Professional Tapestry training, mentoring, support
>> > and project work.  http://howardlewisship.com
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> > For additional commands, e-mail: users-help@tapestry.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446675
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
> 
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9447486
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [WARNING] [T5]Ioc-Perthread service lifecycle

Posted by Howard Lewis Ship <hl...@gmail.com>.
Sorry, that was SVN trunk code (i.e., 5.0.3-SNAPSHOT), for 5.0.2 the
service id is "tapestry.ioc.ThreadCleanupHub".

On 3/12/07, Weisu <we...@gmail.com> wrote:
>
> Thanks Howard, but I got this msg: Error invoking service builder method
> com.mainco.ellipse.services.AppModule.buildEllipseSession(ThreadCleanupHub)
> (for service 'app.EllipseSession'): Service 'app.ThreadCleanupHub' does not
> exist.
> This is my code:
> @Lifecycle("perthread")
> public static EllipseSession
> buildEllipseSession(@InjectService("ThreadCleanupHub") ThreadCleanupHub
> threadCleanupHub)
>         {
>         EllipseSessionImpl service = new EllipseSessionImpl();
>
>         threadCleanupHub.addThreadCleanupListener(service);
>
>         return service;
>
>         }
>
> Howard Lewis Ship wrote:
> >
> > It tends to look like this:
> >
> >   @Lifecycle("perthread")
> >     public static HibernateSessionManager
> > build(@InjectService("HibernateSessionSource")
> >     HibernateSessionSource sessionSource,
> >
> >     @InjectService("ThreadCleanupHub")
> >     ThreadCleanupHub threadCleanupHub)
> >     {
> >         HibernateSessionManagerImpl service = new
> > HibernateSessionManagerImpl(sessionSource);
> >
> >         threadCleanupHub.addThreadCleanupListener(service);
> >
> >         return service;
> >     }
> >
> > In this example, HibernateSessionManagerImpl implements
> > ThreadCleanupListener, in addition to HibernateSessionManager.
> >
> > ThreadCleanupHub is responsible for notifying its listeners at the end
> > of the request.
> >
> > With the "perthread" lifecycle, your service builder method is invoked
> > at most once per request.
> >
> > On 3/12/07, Weisu <we...@gmail.com> wrote:
> >>
> >> Hi, I am try to create a perthread service, the following lines are in
> >> the
> >> module builder class, how and where can I define cleanupThread() method?
> >>
> >> @Lifecycle("perthread")
> >> public static EllipseSession buildEllipseSession()
> >> {
> >> return new EllipseSessionImpl();
> >> }
> >> Thanks.
> >> --
> >> View this message in context:
> >> http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446131
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446675
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


Re: [WARNING] [T5]Ioc-Perthread service lifecycle

Posted by Weisu <we...@gmail.com>.
Thanks Howard, but I got this msg: Error invoking service builder method
com.mainco.ellipse.services.AppModule.buildEllipseSession(ThreadCleanupHub)
(for service 'app.EllipseSession'): Service 'app.ThreadCleanupHub' does not
exist.
This is my code:
@Lifecycle("perthread")
public static EllipseSession
buildEllipseSession(@InjectService("ThreadCleanupHub") ThreadCleanupHub
threadCleanupHub) 
	{
    	EllipseSessionImpl service = new EllipseSessionImpl(); 

    	threadCleanupHub.addThreadCleanupListener(service); 

    	return service; 

	}

Howard Lewis Ship wrote:
> 
> It tends to look like this:
> 
>   @Lifecycle("perthread")
>     public static HibernateSessionManager
> build(@InjectService("HibernateSessionSource")
>     HibernateSessionSource sessionSource,
> 
>     @InjectService("ThreadCleanupHub")
>     ThreadCleanupHub threadCleanupHub)
>     {
>         HibernateSessionManagerImpl service = new
> HibernateSessionManagerImpl(sessionSource);
> 
>         threadCleanupHub.addThreadCleanupListener(service);
> 
>         return service;
>     }
> 
> In this example, HibernateSessionManagerImpl implements
> ThreadCleanupListener, in addition to HibernateSessionManager.
> 
> ThreadCleanupHub is responsible for notifying its listeners at the end
> of the request.
> 
> With the "perthread" lifecycle, your service builder method is invoked
> at most once per request.
> 
> On 3/12/07, Weisu <we...@gmail.com> wrote:
>>
>> Hi, I am try to create a perthread service, the following lines are in
>> the
>> module builder class, how and where can I define cleanupThread() method?
>>
>> @Lifecycle("perthread")
>> public static EllipseSession buildEllipseSession()
>> {
>> return new EllipseSessionImpl();
>> }
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446131
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> -- 
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
> 
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446675
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: [T5]Ioc-Perthread service lifecycle

Posted by Howard Lewis Ship <hl...@gmail.com>.
It tends to look like this:

  @Lifecycle("perthread")
    public static HibernateSessionManager
build(@InjectService("HibernateSessionSource")
    HibernateSessionSource sessionSource,

    @InjectService("ThreadCleanupHub")
    ThreadCleanupHub threadCleanupHub)
    {
        HibernateSessionManagerImpl service = new
HibernateSessionManagerImpl(sessionSource);

        threadCleanupHub.addThreadCleanupListener(service);

        return service;
    }

In this example, HibernateSessionManagerImpl implements
ThreadCleanupListener, in addition to HibernateSessionManager.

ThreadCleanupHub is responsible for notifying its listeners at the end
of the request.

With the "perthread" lifecycle, your service builder method is invoked
at most once per request.

On 3/12/07, Weisu <we...@gmail.com> wrote:
>
> Hi, I am try to create a perthread service, the following lines are in the
> module builder class, how and where can I define cleanupThread() method?
>
> @Lifecycle("perthread")
> public static EllipseSession buildEllipseSession()
> {
> return new EllipseSessionImpl();
> }
> Thanks.
> --
> View this message in context: http://www.nabble.com/-T5-Ioc-Perthread-service-lifecycle-tf3393129.html#a9446131
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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