You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2008/01/24 10:45:21 UTC
T5: Service and thread
Hi,
I have a service which does some file download that takes quite long, I'd
like to run the service in a separate thread, possible with Tapestry Ioc? or
I have to manage the thread manually? Thanks,
A.C.
--
View this message in context: http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15061626.html
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: Service and thread
Posted by Andy Huhn <am...@insightbb.com>.
Angelo,
Additionally, if you have a job that you want to schedule to do this
download, you could use a scheduler such as Quartz to kick off the job
without any intervention.
Andy
On Thu, 2008-01-24 at 01:45 -0800, Angelo Chen wrote:
> Hi,
>
> I have a service which does some file download that takes quite long, I'd
> like to run the service in a separate thread, possible with Tapestry Ioc? or
> I have to manage the thread manually? Thanks,
>
> A.C.
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Service and thread
Posted by Davor Hrg <hr...@gmail.com>.
you have to call your code in a separate Thread
...
it can be inline as well..
private int progress;
public void getAll(){
final Sth myVar....
new Thread(new Runnable(){
public void run(){
.... do long running code here, and set progress variable if possible
}
}).start();
}
after this you have to bind this task to the your ASO
so you can access it and display progress on the page ...
these are just pointers ... the rest is on you :):)
Davor Hrg
On Jan 26, 2008 1:01 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi Davor,
>
> getAll is not async, it will not return immediately, how to make a service
> async? thanks.
>
>
>
>
> Davor Hrg wrote:
> >
> > are you sure
> > fileService.getAll();
> > is async and returns immediately ?
> >
> > Davor Hrg
> >
> >
> >
> > On Jan 25, 2008 4:36 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
> >>
> >> Hi Davor,
> >>
> >> the service downloads files from remote server which takes quite long
> >> time,
> >> the code is:
> >>
> >> @Inject private FileService fileService;
> >>
> >> Class onActionFromTest() throws Exception {
> >>
> >> try {
> >> fileService.getAll();
> >> }
> >> } catch (CodeExistsException e) {
> >> e.printStackTrace();
> >> }
> >> return null;
> >> }
> >>
> >> after the call fileService.getAll(), the cursor in the browser at that
> >> time
> >> is in the 'wait' state, i have to click another page to bring the cursor
> >> back to normal.
> >>
> >>
> >>
> >>
> >>
> >> Davor Hrg wrote:
> >> >
> >> > hm.. I'm not following you ...
> >> >
> >> > you say you download sth ...
> >> > does your service download sth from some server to yourown
> >> > or is browser downloading from your server ...
> >> > could you say more about your case ... some ceode mybe ...
> >> >
> >> >
> >> > Davor Hrg
> >> >
> >> > On Jan 25, 2008 11:08 AM, Angelo Chen <an...@yahoo.com.hk>
> >> wrote:
> >> >>
> >> >> Hi Davor, Andy,
> >> >>
> >> >> Thanks for the reply, what I do now is, just start the service, and i
> >> >> can
> >> >> go to other pages as well, but if I stay in the same page where i
> >> start
> >> >> the
> >> >> service, the cursor will be in the 'wait' state, i have to leave the
> >> page
> >> >> first, any idea?
> >> >>
> >> >> A.C.
> >> >>
> >> >>
> >> >> Davor Hrg wrote:
> >> >> >
> >> >> > Tapestry-ioc will not generate threads for you,
> >> >> > taopestry-ioc makes sure that some resources are unique per thread,
> >> >> > and threads can be generated where ever. They mostly come from
> >> >> underlaying
> >> >> > server for each request.
> >> >> >
> >> >> >
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
> >> >>
> >> >> 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
> >> >>
> >> >>
> >> >
> >> > ---------------------------------------------------------------------
> >> > 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%3A-Service-and-thread-tp15061626p15090199.html
> >>
> >> 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
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > 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%3A-Service-and-thread-tp15061626p15099632.html
>
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Service and thread
Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Davor,
getAll is not async, it will not return immediately, how to make a service
async? thanks.
Davor Hrg wrote:
>
> are you sure
> fileService.getAll();
> is async and returns immediately ?
>
> Davor Hrg
>
>
>
> On Jan 25, 2008 4:36 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>>
>> Hi Davor,
>>
>> the service downloads files from remote server which takes quite long
>> time,
>> the code is:
>>
>> @Inject private FileService fileService;
>>
>> Class onActionFromTest() throws Exception {
>>
>> try {
>> fileService.getAll();
>> }
>> } catch (CodeExistsException e) {
>> e.printStackTrace();
>> }
>> return null;
>> }
>>
>> after the call fileService.getAll(), the cursor in the browser at that
>> time
>> is in the 'wait' state, i have to click another page to bring the cursor
>> back to normal.
>>
>>
>>
>>
>>
>> Davor Hrg wrote:
>> >
>> > hm.. I'm not following you ...
>> >
>> > you say you download sth ...
>> > does your service download sth from some server to yourown
>> > or is browser downloading from your server ...
>> > could you say more about your case ... some ceode mybe ...
>> >
>> >
>> > Davor Hrg
>> >
>> > On Jan 25, 2008 11:08 AM, Angelo Chen <an...@yahoo.com.hk>
>> wrote:
>> >>
>> >> Hi Davor, Andy,
>> >>
>> >> Thanks for the reply, what I do now is, just start the service, and i
>> >> can
>> >> go to other pages as well, but if I stay in the same page where i
>> start
>> >> the
>> >> service, the cursor will be in the 'wait' state, i have to leave the
>> page
>> >> first, any idea?
>> >>
>> >> A.C.
>> >>
>> >>
>> >> Davor Hrg wrote:
>> >> >
>> >> > Tapestry-ioc will not generate threads for you,
>> >> > taopestry-ioc makes sure that some resources are unique per thread,
>> >> > and threads can be generated where ever. They mostly come from
>> >> underlaying
>> >> > server for each request.
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
>> >>
>> >> 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
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > 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%3A-Service-and-thread-tp15061626p15090199.html
>>
>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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%3A-Service-and-thread-tp15061626p15099632.html
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: Service and thread
Posted by Davor Hrg <hr...@gmail.com>.
are you sure
fileService.getAll();
is async and returns immediately ?
Davor Hrg
On Jan 25, 2008 4:36 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi Davor,
>
> the service downloads files from remote server which takes quite long time,
> the code is:
>
> @Inject private FileService fileService;
>
> Class onActionFromTest() throws Exception {
>
> try {
> fileService.getAll();
> }
> } catch (CodeExistsException e) {
> e.printStackTrace();
> }
> return null;
> }
>
> after the call fileService.getAll(), the cursor in the browser at that time
> is in the 'wait' state, i have to click another page to bring the cursor
> back to normal.
>
>
>
>
>
> Davor Hrg wrote:
> >
> > hm.. I'm not following you ...
> >
> > you say you download sth ...
> > does your service download sth from some server to yourown
> > or is browser downloading from your server ...
> > could you say more about your case ... some ceode mybe ...
> >
> >
> > Davor Hrg
> >
> > On Jan 25, 2008 11:08 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
> >>
> >> Hi Davor, Andy,
> >>
> >> Thanks for the reply, what I do now is, just start the service, and i
> >> can
> >> go to other pages as well, but if I stay in the same page where i start
> >> the
> >> service, the cursor will be in the 'wait' state, i have to leave the page
> >> first, any idea?
> >>
> >> A.C.
> >>
> >>
> >> Davor Hrg wrote:
> >> >
> >> > Tapestry-ioc will not generate threads for you,
> >> > taopestry-ioc makes sure that some resources are unique per thread,
> >> > and threads can be generated where ever. They mostly come from
> >> underlaying
> >> > server for each request.
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
> >>
> >> 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
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > 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%3A-Service-and-thread-tp15061626p15090199.html
>
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Service and thread
Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Davor,
the service downloads files from remote server which takes quite long time,
the code is:
@Inject private FileService fileService;
Class onActionFromTest() throws Exception {
try {
fileService.getAll();
}
} catch (CodeExistsException e) {
e.printStackTrace();
}
return null;
}
after the call fileService.getAll(), the cursor in the browser at that time
is in the 'wait' state, i have to click another page to bring the cursor
back to normal.
Davor Hrg wrote:
>
> hm.. I'm not following you ...
>
> you say you download sth ...
> does your service download sth from some server to yourown
> or is browser downloading from your server ...
> could you say more about your case ... some ceode mybe ...
>
>
> Davor Hrg
>
> On Jan 25, 2008 11:08 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>>
>> Hi Davor, Andy,
>>
>> Thanks for the reply, what I do now is, just start the service, and i
>> can
>> go to other pages as well, but if I stay in the same page where i start
>> the
>> service, the cursor will be in the 'wait' state, i have to leave the page
>> first, any idea?
>>
>> A.C.
>>
>>
>> Davor Hrg wrote:
>> >
>> > Tapestry-ioc will not generate threads for you,
>> > taopestry-ioc makes sure that some resources are unique per thread,
>> > and threads can be generated where ever. They mostly come from
>> underlaying
>> > server for each request.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
>>
>> 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
>>
>>
>
> ---------------------------------------------------------------------
> 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%3A-Service-and-thread-tp15061626p15090199.html
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: Service and thread
Posted by Davor Hrg <hr...@gmail.com>.
hm.. I'm not following you ...
you say you download sth ...
does your service download sth from some server to yourown
or is browser downloading from your server ...
could you say more about your case ... some ceode mybe ...
Davor Hrg
On Jan 25, 2008 11:08 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi Davor, Andy,
>
> Thanks for the reply, what I do now is, just start the service, and i can
> go to other pages as well, but if I stay in the same page where i start the
> service, the cursor will be in the 'wait' state, i have to leave the page
> first, any idea?
>
> A.C.
>
>
> Davor Hrg wrote:
> >
> > Tapestry-ioc will not generate threads for you,
> > taopestry-ioc makes sure that some resources are unique per thread,
> > and threads can be generated where ever. They mostly come from underlaying
> > server for each request.
> >
> >
>
> --
> View this message in context: http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
>
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Service and thread
Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Davor, Andy,
Thanks for the reply, what I do now is, just start the service, and i can
go to other pages as well, but if I stay in the same page where i start the
service, the cursor will be in the 'wait' state, i have to leave the page
first, any idea?
A.C.
Davor Hrg wrote:
>
> Tapestry-ioc will not generate threads for you,
> taopestry-ioc makes sure that some resources are unique per thread,
> and threads can be generated where ever. They mostly come from underlaying
> server for each request.
>
>
--
View this message in context: http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15084799.html
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: Service and thread
Posted by Davor Hrg <hr...@gmail.com>.
Tapestry-ioc will not generate threads for you,
taopestry-ioc makes sure that some resources are unique per thread,
and threads can be generated where ever. They mostly come from underlaying
server for each request.
If you spawn your own thread, you can freely use any threaded resource,
just make sure that you call ThreadCleanupHub after thread finishes it's work
so tapestry can free the resources.
Davor Hrg
On Jan 24, 2008 10:45 AM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> I have a service which does some file download that takes quite long, I'd
> like to run the service in a separate thread, possible with Tapestry Ioc? or
> I have to manage the thread manually? Thanks,
>
> A.C.
>
>
> --
> View this message in context: http://www.nabble.com/T5%3A-Service-and-thread-tp15061626p15061626.html
> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org