wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ernesto Reinaldo Barreiro <reier...@gmail.com>
Subject Re: What is the proper way to start a secondary process in Wicket 6
Date Sat, 22 Nov 2014 04:47:26 GMT
Warren,

Service holder will be created in a WEB thread, so WebApplication will be
in context as a thread local. Mind that cosntructor of servce holder will
cal Injector.get().inject... too inject the services. After that unless you
need it for something else... you no longer need WebApplicatiion. Also if
your sevices has no state Service holder could be a singleton that is
created on application init and just shared by all bridges.

On Fri, Nov 21, 2014 at 5:53 PM, Warren Bell <warrenbell2@gmail.com> wrote:

> Ernesto,
>
> I am not sure that creating a service holder will do the trick without
> still attaching the app to the new thread. I am currently injecting a
> service into your ExecutionBridge class that is instantiated in the request
> thread. All is good until that ExecutionBridge gets passed to the new
> thread. Injecting the service in a Service holder is the same thing, isn’t
> it ?
>
> I haven’t tried attaching the app to the new thread and injecting the
> service straight into the new task/thread itself. I think that would be
> cleaner. I will try that out.
>
> Warren Bell
>
> On Nov 21, 2014, at 8:19 AM, Ernesto Reinaldo Barreiro <reiern70@gmail.com>
> wrote:
>
> > @Warren,
> >
> > Apologies for the extra t on your name: texting on a mobile phone is a
> > pain... I will update de demo to include a service. Just one question:
> the
> > app not in context is when you try to inject that service? Or because you
> > are using something else from WEB layer?
> >
> > On Fri, Nov 21, 2014 at 11:05 AM, Ernesto Reinaldo Barreiro <
> > reiern70@gmail.com> wrote:
> >
> >> Thanks for your answer!  There is no hurry.
> >>
> >> I will add a service to the mix to cover Warrent use case. Eg using
> Guice
> >> integration.
> >>
> >> On 21 Nov 2014 09:34, "Martin Grigorov" <mgrigorov@apache.org> wrote:
> >>>
> >>> Hi Ernesto,
> >>>
> >>> I'm traveling now. I'll be able to take a look at Sunday.
> >>> On Nov 20, 2014 3:48 PM, "Ernesto Reinaldo Barreiro" <
> reiern70@gmail.com
> >>>
> >>> wrote:
> >>>
> >>>> Martin,
> >>>>
> >>>> I have created
> >>>>
> >>>> https://github.com/reiern70/antilia-bits/tree/master/bgprocess
> >>>>
> >>>> My only caveats are
> >>>>
> >>>>
> >>>>
> >>
> https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L50
> >>>>
> >>>> and
> >>>>
> >>>>
> >>>>
> >>
> https://github.com/reiern70/antilia-bits/blob/master/bgprocess/src/main/java/com/antilia/panel/TasksListPanel.java#L70
> >>>>
> >>>> I had to re-add Timer behavior: I do not see yet why? It is as if the
> >> timer
> >>>> is not re-rendered: they are not isTemporar :-( I will check when I
> >> have
> >>>> more time.
> >>>>
> >>>> I would appreciate if you can review the code... before I write
> >> anything on
> >>>> my fork  of Wicket in Action. This probably could be done in a leaner
> >> way
> >>>> mounting a resource to serve JSON for task states and building the UI
> >> at
> >>>> client side... But example illustrates how to do it with "plain
> >> Wicket".
> >>>>
> >>>>
> >>>> On Thu, Nov 20, 2014 at 8:40 AM, Ernesto Reinaldo Barreiro <
> >>>> reiern70@gmail.com> wrote:
> >>>>
> >>>>> Ok. Let me see what I can do this weekend while I wait for my son
to
> >>>>> finish he's shower after he's football match  ;-)
> >>>>>
> >>>>> On Thu, Nov 20, 2014 at 8:30 AM, Martin Grigorov <
> >> mgrigorov@apache.org>
> >>>>> wrote:
> >>>>>
> >>>>>> Sure! Thanks!
> >>>>>> It could be as fancy as you wish.
> >>>>>>
> >>>>>> Martin Grigorov
> >>>>>> Wicket Training and Consulting
> >>>>>> https://twitter.com/mtgrigorov
> >>>>>>
> >>>>>> On Thu, Nov 20, 2014 at 10:17 AM, Ernesto Reinaldo Barreiro
<
> >>>>>> reiern70@gmail.com> wrote:
> >>>>>>
> >>>>>>> Can I give it a try? Something event showing some progress
at
> >> client
> >>>>>> side?
> >>>>>>>
> >>>>>>> On Thu, Nov 20, 2014 at 7:54 AM, Martin Grigorov <
> >>>> mgrigorov@apache.org>
> >>>>>>> wrote:
> >>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> Someday I'll write a blog (with a demo) about this at
> >>>>>>>> http://wicketinaction.com.
> >>>>>>>> The question is being asked regularly.
> >>>>>>>>
> >>>>>>>> Actually anyone can send a Pull Request at
> >>>>>>>> https://github.com/dashorst/wicketinaction.com with
such
> >> article.
> >>>>>>>>
> >>>>>>>> Martin Grigorov
> >>>>>>>> Wicket Training and Consulting
> >>>>>>>> https://twitter.com/mtgrigorov
> >>>>>>>>
> >>>>>>>> On Thu, Nov 20, 2014 at 7:26 AM, Ernesto Reinaldo Barreiro
<
> >>>>>>>> reiern70@gmail.com> wrote:
> >>>>>>>>
> >>>>>>>>> Hi Warren,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Thu, Nov 20, 2014 at 12:46 AM, Warren Bell <
> >>>>>> warrenbell2@gmail.com>
> >>>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> I am using Wicket 6 REST annotations and want
to
> >> asynchronously
> >>>>>>> start a
> >>>>>>>>>> process that writes some logging data to a db.
I don’t need
> >> the
> >>>>>>>> response
> >>>>>>>>> to
> >>>>>>>>>> wait for this process. I have tried using threads,
but I
> >> get the
> >>>>>> “App
> >>>>>>>> not
> >>>>>>>>>> attached to this thread” exception when I
try to use an
> >> injected
> >>>>>>>> service.
> >>>>>>>>>> This logging process is a little more complicated
than what
> >>>> log4j
> >>>>>> or
> >>>>>>>>>> loopback can do. The bottom line is that I do
not want the
> >>>>>>>>> request/response
> >>>>>>>>>> process to have to wait for the logging process
to complete.
> >>>> What
> >>>>>> is
> >>>>>>>> the
> >>>>>>>>>> proper way of doing this in Wicket 6 using an
injected
> >> service.
> >>>>>>>>>>
> >>>>>>>>>> Sometimes  what I do is I create a context class
> >> ServiceHolder,
> >>>>>>> inject
> >>>>>>>>> what I need on this class (e.g. services) and pass
this to
> >> the non
> >>>>>> web
> >>>>>>>>> thread (e.g as an argument to the runnable). Injector.inject
> >> will
> >>>>>> have
> >>>>>>>>> WicketApp in context.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> 1) Get request
> >>>>>>>>>> 2) Log some data (Do not wait for this to complete)
> >>>>>>>>>> 3) Process request
> >>>>>>>>>> 4) Return response
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> You could use the same ServiceHolder as a bridge
to pass info
> >> to
> >>>> the
> >>>>>>> WEB
> >>>>>>>>> layer. 1) keep a reference to it 2) in another (polling)
> >> request
> >>>>>> use it
> >>>>>>>> to
> >>>>>>>>> see how back-ground job is progressing. Sometimes
I also use
> >> it to
> >>>>>>>> control
> >>>>>>>>> the Job: e.g. stop/pause it, cancel it. Once Job
finishes
> >> just let
> >>>>>>>> service
> >>>>>>>>> holder "go".
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Thanks,
> >>>>>>>>>>
> >>>>>>>>>> Warren Bell
> >>>>>>>>>>
> >>>>>>
> >> ---------------------------------------------------------------------
> >>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>>>>>>>> For additional commands, e-mail:
> >> users-help@wicket.apache.org
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> --
> >>>>>>>>> Regards - Ernesto Reinaldo Barreiro
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> --
> >>>>>>> Regards - Ernesto Reinaldo Barreiro
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>> --
> >>>>> Regards - Ernesto Reinaldo Barreiro
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> Regards - Ernesto Reinaldo Barreiro
> >>>>
> >>
> >
> >
> >
> > --
> > Regards - Ernesto Reinaldo Barreiro
>
>


-- 
Regards - Ernesto Reinaldo Barreiro

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message