starting threads from web container

View: New views
6 Messages — Rating Filter:   Alert me  

starting threads from web container

by jtalafous :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I want to have a background thread that is crunching data in the
background of my web app.

I am aware of <load-on-startup/> in the deployment descriptor of a web
app.  I could start the thread in one of these servlets that load on
startup.  But this doesn't seem proper... the servlet will handle
requests when I know that there will never be any.  It is extra
overhead that goes to waste.

It seems that there would be hooks some where in the web container
that I could use to create POJOs and they could in turn start the
thread.  Are there any, especially specified in web.xml?

_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members

Re: starting threads from web container

by Tim Watts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

See ServletContextListener as well as the <listener> tag. This assumes you're
running in a container that supports at least the servlet 2.3 spec.


On Monday 13 April 2009 7:42:26 pm J. Talafous wrote:

> I want to have a background thread that is crunching data in the
> background of my web app.
>
> I am aware of <load-on-startup/> in the deployment descriptor of a web
> app.  I could start the thread in one of these servlets that load on
> startup.  But this doesn't seem proper... the servlet will handle
> requests when I know that there will never be any.  It is extra
> overhead that goes to waste.
>
> It seems that there would be hooks some where in the web container
> that I could use to create POJOs and they could in turn start the
> thread.  Are there any, especially specified in web.xml?
>
> _______________________________________________
> ajug-members mailing list
> ajug-members@...
> http://www.ajug.org/mailman/listinfo/ajug-members

--
I suppose that I shall have to die beyond my means.
 -- Oscar Wilde, upon being told the cost of an operation


_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members

Parent Message unknown Re: starting threads from web container

by Christopher Mawata :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Not clear what you mean by
...
the servlet will handle requests when I know
that there will never be any
...
The overhead due to the more complex life-cycle should be trivial if
indeed the servlet has no code except in init()
Chris

-----Original Message-----
From: Tim Watts <timtw@...>
To: ajug-members@...
Date: Mon, 13 Apr 2009 23:40:30 -0400
Subject: Re: [ajug-members] starting threads from web container

Hi,

See ServletContextListener as well as the <listener> tag. This assumes you're
running in a container that supports at least the servlet 2.3 spec.


On Monday 13 April 2009 7:42:26 pm J. Talafous wrote:

> I want to have a background thread that is crunching data in the
> background of my web app.
>
> I am aware of <load-on-startup/> in the deployment descriptor of a web
> app.  I could start the thread in one of these servlets that load on
> startup.  But this doesn't seem proper... the servlet will handle
> requests when I know that there will never be any.  It is extra
> overhead that goes to waste.
>
> It seems that there would be hooks some where in the web container
> that I could use to create POJOs and they could in turn start the
> thread.  Are there any, especially specified in web.xml?
>
> _______________________________________________
> ajug-members mailing list
> ajug-members@...
> http://www.ajug.org/mailman/listinfo/ajug-members

--
I suppose that I shall have to die beyond my means.
 -- Oscar Wilde, upon being told the cost of an operation


_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members




_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members

Re: starting threads from web container

by Kerry Wilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You should check into using Quartz as a job scheduler.  Spring integrates
with it and it could be better than having a thread going at all times
(unless that is what you need).  Either way I think a ContextLoaderListener
is a good place to launch it.

kw

--------------------------------------------------
From: "J. Talafous" <jtalafous@...>
Sent: Monday, April 13, 2009 6:42 PM
To: <ajug-members@...>
Subject: [ajug-members] starting threads from web container

> I want to have a background thread that is crunching data in the
> background of my web app.
>
> I am aware of <load-on-startup/> in the deployment descriptor of a web
> app.  I could start the thread in one of these servlets that load on
> startup.  But this doesn't seem proper... the servlet will handle
> requests when I know that there will never be any.  It is extra
> overhead that goes to waste.
>
> It seems that there would be hooks some where in the web container
> that I could use to create POJOs and they could in turn start the
> thread.  Are there any, especially specified in web.xml?
>
> _______________________________________________
> ajug-members mailing list
> ajug-members@...
> http://www.ajug.org/mailman/listinfo/ajug-members 


_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members

Re: starting threads from web container

by Kerry Wilson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oops, I meant a ServletContextListener, not a ContextLoaderListener.

kw

_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members

Re: starting threads from web container

by Ramesh Rajamani :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

WebLogic Server initializes this servlet when WebLogic Server starts up. The content of this element must be a positive integer indicating the order in which the servlet should be loaded. Lower integers are loaded before higher integers. If no value is specified, or if the value specified is not a positive integer, WebLogic Server can load the servlet in any order in the startup sequence.

 
Iam not sure what server you are using but this will help you i guess
 
Regards,
 
Ramesh Rajamani
 

> From: Christopher-Mawata@...
> To: ajug-members@...
> Date: Tue, 14 Apr 2009 14:27:27 -0400
> Subject: Re: [ajug-members] starting threads from web container
>
> Not clear what you mean by
> ...
> the servlet will handle requests when I know
> that there will never be any
> ...
> The overhead due to the more complex life-cycle should be trivial if
> indeed the servlet has no code except in init()
> Chris
>
> -----Original Message-----
> From: Tim Watts <timtw@...>
> To: ajug-members@...
> Date: Mon, 13 Apr 2009 23:40:30 -0400
> Subject: Re: [ajug-members] starting threads from web container
>
> Hi,
>
> See ServletContextListener as well as the <listener> tag. This assumes you're
> running in a container that supports at least the servlet 2.3 spec.
>
>
> On Monday 13 April 2009 7:42:26 pm J. Talafous wrote:
> > I want to have a background thread that is crunching data in the
> > background of my web app.
> >
> > I am aware of <load-on-startup/> in the deployment descriptor of a web
> > app. I could start the thread in one of these servlets that load on
> > startup. But this doesn't seem proper... the servlet will handle
> > requests when I know that there will never be any. It is extra
> > overhead that goes to waste.
> >
> > It seems that there would be hooks some where in the web container
> > that I could use to create POJOs and they could in turn start the
> > thread. Are there any, especially specified in web.xml?
> >
> > _______________________________________________
> > ajug-members mailing list
> > ajug-members@...
> > http://www.ajug.org/mailman/listinfo/ajug-members
>
> --
> I suppose that I shall have to die beyond my means.
> -- Oscar Wilde, upon being told the cost of an operation
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members@...
> http://www.ajug.org/mailman/listinfo/ajug-members
>
>
>
>
> _______________________________________________
> ajug-members mailing list
> ajug-members@...
> http://www.ajug.org/mailman/listinfo/ajug-members


Windows Live Messenger. Multitasking at its finest.
_______________________________________________
ajug-members mailing list
ajug-members@...
http://www.ajug.org/mailman/listinfo/ajug-members