You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tomas Kolda <ko...@web2net.cz> on 2009/01/22 22:43:07 UTC

Hibernate in background thread

Hi,

I need to do something in background (import data once a day). I'm using 
Tapestry-Hibernate package. User should be able to run import from web 
page also. What is the right way to get Hibernate session in background 
thread? I found nice howto on wiki.

http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread

There is simple service wrapper ThreadSource. I can write:

_threadSource.runInThread(new Runnable(){
    public void run(){
        //do something
    }
});

But I need something like:

_threadSource.runInThread(new Runnable(){
    @Inject
    Session session;
    public void run(){
        //do something
    }
});

As I know, AOP search for constructors using reflection that will get 
what it needs. So no way to get it working in this way.

What should I do? I can modify ThreadSource and put there Session that 
will be provided to thread. Is it right approach? Or is there something 
that will provide me service object to satisfy my needs? Something like 
registry.getService(Session.class); ?

Second question:
Is there something like "cron" in Tapestry? I know that it looks ugly, 
to run something in servlet container, but is it possible?

Thank you
Tomas




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


Re: Hibernate in background thread

Posted by Kalle Korhonen <ka...@gmail.com>.
Chenillekit already has Quartz integration, sort of similar to what Spring
offers (but easier):
http://www.chenillekit.org/chenillekit-quartz/index.html

Kalle

On Thu, Jan 22, 2009 at 1:44 PM, Daniel Honig <da...@gmail.com>wrote:

> What about using Quartz for such a task?
> http://www.opensymphony.com/quartz/
>
> On Thu, Jan 22, 2009 at 4:43 PM, Tomas Kolda <ko...@web2net.cz> wrote:
>
> > Hi,
> >
> > I need to do something in background (import data once a day). I'm using
> > Tapestry-Hibernate package. User should be able to run import from web
> page
> > also. What is the right way to get Hibernate session in background
> thread? I
> > found nice howto on wiki.
> >
> > http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread
> >
> > There is simple service wrapper ThreadSource. I can write:
> >
> > _threadSource.runInThread(new Runnable(){
> >   public void run(){
> >       //do something
> >   }
> > });
> >
> > But I need something like:
> >
> > _threadSource.runInThread(new Runnable(){
> >   @Inject
> >   Session session;
> >   public void run(){
> >       //do something
> >   }
> > });
> >
> > As I know, AOP search for constructors using reflection that will get
> what
> > it needs. So no way to get it working in this way.
> >
> > What should I do? I can modify ThreadSource and put there Session that
> will
> > be provided to thread. Is it right approach? Or is there something that
> will
> > provide me service object to satisfy my needs? Something like
> > registry.getService(Session.class); ?
> >
> > Second question:
> > Is there something like "cron" in Tapestry? I know that it looks ugly, to
> > run something in servlet container, but is it possible?
> >
> > Thank you
> > Tomas
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: Hibernate in background thread

Posted by Daniel Honig <da...@gmail.com>.
What about using Quartz for such a task?http://www.opensymphony.com/quartz/

On Thu, Jan 22, 2009 at 4:43 PM, Tomas Kolda <ko...@web2net.cz> wrote:

> Hi,
>
> I need to do something in background (import data once a day). I'm using
> Tapestry-Hibernate package. User should be able to run import from web page
> also. What is the right way to get Hibernate session in background thread? I
> found nice howto on wiki.
>
> http://wiki.apache.org/tapestry/Tapestry5HowToRunTaskInThread
>
> There is simple service wrapper ThreadSource. I can write:
>
> _threadSource.runInThread(new Runnable(){
>   public void run(){
>       //do something
>   }
> });
>
> But I need something like:
>
> _threadSource.runInThread(new Runnable(){
>   @Inject
>   Session session;
>   public void run(){
>       //do something
>   }
> });
>
> As I know, AOP search for constructors using reflection that will get what
> it needs. So no way to get it working in this way.
>
> What should I do? I can modify ThreadSource and put there Session that will
> be provided to thread. Is it right approach? Or is there something that will
> provide me service object to satisfy my needs? Something like
> registry.getService(Session.class); ?
>
> Second question:
> Is there something like "cron" in Tapestry? I know that it looks ugly, to
> run something in servlet container, but is it possible?
>
> Thank you
> Tomas
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>