users@glassfish.java.net

Re: How do I run a process within a web service?

From: NBW <emailnbw_at_gmail.com>
Date: Thu, 10 Sep 2009 14:01:34 -0400

Running your own thread in a managed web service is not supported by the EE
spec. You could take a look at EJB Timers.

On Thu, Sep 10, 2009 at 3:51 AM, <glassfish_at_javadesktop.org> wrote:

> I’m new to web services. For the last few days I’ve been trying to figure
> out how to create a WAR file that I can deploy within Glassfish that when
> deployed starts a process (that contains an endless loop – this process must
> be running at all times). The web methods query the object that is running
> the process.
>
> I’ve tried creating a separate thread to run the process within the
> constructor of the SIB but Glassfish spits this back out and shuts down when
> I attempt to deploy it.
>
> How do I solve this problem? Any help will be greatly appreciated!
>
> Following is an example of what I mean
>
> public class SomeProcess implements Runnable
> {
> private State state;
>
> public void run()
> {
> while(true)
> {
> //update state
> }
> }
>
> public State getState(){return state;}
> }
>
> @WebService
> public class ProcessServer
> {
> /* I need the run() method of this object to start running when the web
> service starts*/
> private SomeProcess someProcess;
>
> public void ProcessServer()
> {
> /* Glassfish isn't happy about doing this!*/
> Thread processThread = new Thread(someProcess);
>
> processThread.start();
> }
>
> @WebMethod
> public State GetState()
> {
> return someProcess.getState();
> }
> }
> [Message sent by forum member 'orangeted' (fup_at_ai-junkie.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=363489
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>