Return-Path: X-Original-To: apmail-wicket-users-archive@minotaur.apache.org Delivered-To: apmail-wicket-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7345C1114F for ; Tue, 6 May 2014 14:26:19 +0000 (UTC) Received: (qmail 28747 invoked by uid 500); 6 May 2014 14:11:17 -0000 Delivered-To: apmail-wicket-users-archive@wicket.apache.org Received: (qmail 28676 invoked by uid 500); 6 May 2014 14:11:16 -0000 Mailing-List: contact users-help@wicket.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@wicket.apache.org Delivered-To: mailing list users@wicket.apache.org Received: (qmail 28406 invoked by uid 99); 6 May 2014 14:11:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 14:11:03 +0000 X-ASF-Spam-Status: No, hits=1.7 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of reiern70@gmail.com designates 209.85.216.179 as permitted sender) Received: from [209.85.216.179] (HELO mail-qc0-f179.google.com) (209.85.216.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 14:10:59 +0000 Received: by mail-qc0-f179.google.com with SMTP id x3so6090088qcv.38 for ; Tue, 06 May 2014 07:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=fZxxP7eIqFPVO1Yx9+SD51sh0hPDeKzWkegp6kjXu1M=; b=IoCe2578MWR55dWomoSkhzfjxwU4Bg6bnNhR9Y/qpZuSC91sdZXRTggg5yViQPE2k3 mESVFpxHTiObXD1dXjm4hWsYmOmyPyXf6AvqXb480dSzeBNWcQq6D5ude99nojkoeFFC XHL0XbauaqObct0YZ7fGEXcS3hfZpMnRsuBVhMwpdGKto2xRqmV5R5+pmABlf/BmXCu5 Vn2NRpuOFjCGm/NeehEHbQ7ezppoWYQIh3LYvyisQ5BSj+SQvK/4JdMID5PGl20Xw9fo ontq/9f01ChXgu8FE7cPYUbPjNddJLABStiEDZs/iytDIx/3A81HZ2PFii9n7kKimFRC WWRg== MIME-Version: 1.0 X-Received: by 10.140.36.105 with SMTP id o96mr25925530qgo.25.1399385439234; Tue, 06 May 2014 07:10:39 -0700 (PDT) Received: by 10.96.173.70 with HTTP; Tue, 6 May 2014 07:10:39 -0700 (PDT) In-Reply-To: References: Date: Tue, 6 May 2014 16:10:39 +0200 Message-ID: Subject: Re: Background Threading From: Ernesto Reinaldo Barreiro To: "users@wicket.apache.org" Content-Type: multipart/alternative; boundary=001a11c17334028afa04f8bbd0e4 X-Virus-Checked: Checked by ClamAV on apache.org --001a11c17334028afa04f8bbd0e4 Content-Type: text/plain; charset=UTF-8 It does not requiere hibernate... I will build an example... better than empty talk. On Tue, May 6, 2014 at 3:59 PM, Richard W. Adams wrote: > Well for starters, the example seems to require Hibernate (which our > organization doesn't allow us to use). This correct? > > Second, I don't have the flexibility implement a service. I have to send > Javascript back to the client, and the corporate Javascript framework then > renders the progress bar. > > What is the 'context' class you refer to? Where is it instantiated and > where is it stored? > > > > > From: Ernesto Reinaldo Barreiro > To: "users@wicket.apache.org" > Date: 05/06/2014 07:52 AM > Subject: Re: Background Threading > > > > Hi, > > > On Tue, May 6, 2014 at 2:11 PM, Richard W. Adams wrote: > > > Interesting approach. Our use case is more complex, as it runs a > > background task in a separate thread. Our task has three basic > > requirements. It must: > > > > 1. Be cancellable. > > > > 2. Report its outcome (success/failure/warning). > > > > 3. Report incremental progress. > > > > Our fundamental problem is not how to display the progress bar, it's how > > to determine the outcome of the background thread. That's an > unexpectedly > > a tough nut to crack. The vast majority of examples we've seen use the > > Runnable interface (which doesn't help us, as it can't be canceled or > > return a value), rather than Callable interface (which meets our needs, > > but doesn't seem to play well with Wicket) > > > > Really? Is it that hard? > > 1-Create a "context" class to pass information to/from WEB > threads/background thread. > 2-Both threads keep a copy of it: so you can report progress, cancel > generation and so on. > > I have implemented something like that ages ago > > https://code.google.com/p/antilia/wiki/OSGiPowered > > > > > > > > > > > > > From: Colin Rogers > > To: "users@wicket.apache.org" > > Date: 05/05/2014 08:14 PM > > Subject: RE: Progress Bar > > > > > > > > There is a pretty nifty, jquery based progress bar, in wicket-jquery-ui > > library... > > > > > http://www.7thweb.net/wicket-jquery-ui/progressbar/DefaultProgressBarPage > > > > Cheers, > > Col. > > > > -----Original Message----- > > From: Richard W. Adams [mailto:RWADAMS1@UP.COM] > > Sent: Tuesday, 6 May 2014 3:19 AM > > To: users@wicket.apache.org > > Subject: Progress Bar > > > > We have a requirement to implement a progress bar for long-running > server > > operations. We can't use the code at > > https://github.com/wicketstuff/core/wiki/Progressbar, because it doesn't > > meet our corporate user interface look-and-feel standards. > > > > So, we started our own implementation. Our test page contains these > > methods below (the TestExecutor below class implements > > Callable). > > > > > > > > //---------------------------------------------------------------------------------------------- > > private Component createButton() { > > return new AjaxButton("start-button") { > > private static final long serialVersionUID = -1; > > > > @Override protected void onSubmit(final > AjaxRequestTarget > > ajax, final Form form) { > > > > final ExecutorService service = Executors. > > newSingleThreadExecutor(); > > try { > > final ProgressBarTestPage page = > > ProgressBarTestPage.this; > > final TransactionData data = new > > TransactionData (page.getId(), false); > > final TestExecutor executor = new > > TestExecutor(data, getPermissions()); > > > > executor.addListener(page); // > Request > > notification when done > > future = service.submit(executor); // > > Begin execution > > progressBarUpdater.start(ajax, > executor); > > // Start polling for progress > > > > } catch (final Exception ex) { > > throw new RuntimeException(ex); > > } > > service.shutdown(); // Terminate gracefully > > (VM probably > > } // won't exit if we fail to do > this) > > }; > > } > > > > > > //---------------------------------------------------------------------------------------------- > > /** > > Observer Pattern method to let us know when the task is done so we > can > > check how things went. > > */ > > @Override public void executionComplete(final EnmCallableExecutor > > executor) { > > > > try { > > if (!future.isCancelled()) { // > > Unless execution was canceled > > final ExecutorResult result = future.get(); // > > Get the outcome > > System.out.println(result); > > /* > > * TODO: Show success or error message > > */ > > } > > } catch (final Exception ex) { > > ex.printStackTrace(); > > } > > } > > > > The ProgessBarUpdater class has this method: > > > > > > > > //---------------------------------------------------------------------------------------------- > > /** > > * Displays the progress bar & begins the polling. We don't start > the > > polling until > > * explicitly told to do, for efficiency purposes. > > * @param ajax The Ajax request wrapper. > > * @param reporter The object to query for progress data. > > */ > > public void start(final AjaxRequestTarget ajax, final ProgressReporter > > reporter) { > > > > add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(2)) { > > private static final long serialVersionUID = 1L; > > > > @Override protected void onPostProcessTarget(final > > AjaxRequestTarget ajax) { > > > > final Progress progress = > reporter.getProgress(); > > final String script = // Build > > script to update > > ProgressScript.build(progress); // > > progress bar > > ajax.appendJavascript(script); > > if (progress == null) { // If > > operation is finished > > final ProgressBarUpdater updater = > > ProgressBarUpdater.this; > > updater.remove(this); // > > Stop timer to prevent > > ajax.addComponent(updater); // > pointless > > polling > > } > > } > > }); > > ajax.addComponent(this); > > } > > > > The page also contains a Future object so we can check the result after > > the thread finishes: > > > > private Future future; > > > > __________________________________________ > > > > Having said all that, here's the problem: When I click the page's > button, > > Wicket throws this error: > > > > Unable to serialize class: java.util.concurrent.FutureTask > > > > The FutureTask object, I believe, is coming from the service.submit call > > whose return value we store in our Future variable. > > > > Does anyone know how to get around this roadblock? > > > > > > > > ** > > > > This email and any attachments may contain information that is > > confidential and/or privileged for the sole use of the intended > recipient. > > Any use, review, disclosure, copying, distribution or reliance by > others, > > and any forwarding of this email or its contents, without the express > > permission of the sender is strictly prohibited by law. If you are not > > the intended recipient, please contact the sender immediately, delete > the > > e-mail and destroy all copies. > > ** > > EMAIL DISCLAIMER This email message and its attachments are confidential > > and may also contain copyright or privileged material. If you are not > the > > intended recipient, you may not forward the email or disclose or use the > > information contained in it. If you have received this email message in > > error, please advise the sender immediately by replying to this email > and > > delete the message and any associated attachments. Any views, opinions, > > conclusions, advice or statements expressed in this email message are > > those of the individual sender and should not be relied upon as the > > considered view, opinion, conclusions, advice or statement of this > company > > except where the sender expressly, and with authority, states them to be > > the considered view, opinion, conclusions, advice or statement of this > > company. Every care is taken but we recommend that you scan any > > attachments for viruses. > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org > > For additional commands, e-mail: users-help@wicket.apache.org > > > > > > > > > > ** > > > > This email and any attachments may contain information that is > > confidential and/or privileged for the sole use of the intended > recipient. > > Any use, review, disclosure, copying, distribution or reliance by > others, > > and any forwarding of this email or its contents, without the express > > permission of the sender is strictly prohibited by law. If you are not > the > > intended recipient, please contact the sender immediately, delete the > > e-mail and destroy all copies. > > ** > > > > > > -- > Regards - Ernesto Reinaldo Barreiro > > > > ** > > This email and any attachments may contain information that is > confidential and/or privileged for the sole use of the intended recipient. > Any use, review, disclosure, copying, distribution or reliance by others, > and any forwarding of this email or its contents, without the express > permission of the sender is strictly prohibited by law. If you are not the > intended recipient, please contact the sender immediately, delete the > e-mail and destroy all copies. > ** > -- Regards - Ernesto Reinaldo Barreiro --001a11c17334028afa04f8bbd0e4--