You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mathias Nilsson <wi...@gmail.com> on 2014/04/19 14:46:06 UTC
WicketTester in Thread
Hi,
I', using Wicket to send html mail and I know that this has been asked many
times but I can't reuse my wicket tester. I have a cron job
@org.nnsoft.guice.guartz.Scheduled( cronExpression = "0/5 * * * * ?" ) that
executes and checks for mail.
@Inject MyApplication application
WicketTester tester = new WicketTester( application ) will fail.
There is no application attached to current thread main
If I create a WicketTester and want to reuse it in the next cron job I get
the same exception. I need to do this every time in my CronJob and it seems
to expensive.
Injector injector = Guice.createInjector(new MediaModule());
WicketTester tester = new WicketTester( new TestApplication(injector) );
....use the tester
Do I really need to do this every time the CronJob executes?
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-in-Thread-tp4665477.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: WicketTester in Thread
Posted by Maxim Solodovnik <so...@gmail.com>.
#2 works for me with Quartz
Thanks Martin!
On Sat, Apr 19, 2014 at 9:51 PM, Mathias Nilsson <
wicket.programmer@gmail.com> wrote:
> Thank you!
>
> 1) ComponentRenderer does not work. Have already tried that and with same
> result as my above error.
> 2) I get the same result when trying this.
> 3) I Will try this.
>
> // Mathias
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/WicketTester-in-Thread-tp4665477p4665481.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
WBR
Maxim aka solomax
Re: WicketTester in Thread
Posted by Mathias Nilsson <wi...@gmail.com>.
Thank you!
1) ComponentRenderer does not work. Have already tried that and with same
result as my above error.
2) I get the same result when trying this.
3) I Will try this.
// Mathias
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/WicketTester-in-Thread-tp4665477p4665481.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: WicketTester in Thread
Posted by Martin Grigorov <mg...@apache.org>.
Hi,
I am not sure how this @Scheduled works but it seems it uses different
threads for each run.
Here are some options:
1) use ComponentRenderer (
http://www.wicket-library.com/wicket-examples-6.0.x/mailtemplate/)
2) get the application by name - Application#get(String). The name is the
name of WicketFilter you specify in web.xml
3) Create WicketTester once and pass it to your own Thread that run every N
secs/mins/hours/... I.e. do the scheduling yourself
4) I guess the library providing @Scheduled also provides some kind of
ThreadFactory where you can set/unset the application instance for each run
Martin Grigorov
Wicket Training and Consulting
On Sat, Apr 19, 2014 at 3:46 PM, Mathias Nilsson <
wicket.programmer@gmail.com> wrote:
> Hi,
>
> I', using Wicket to send html mail and I know that this has been asked many
> times but I can't reuse my wicket tester. I have a cron job
> @org.nnsoft.guice.guartz.Scheduled( cronExpression = "0/5 * * * * ?" ) that
> executes and checks for mail.
>
>
> @Inject MyApplication application
>
> WicketTester tester = new WicketTester( application ) will fail.
> There is no application attached to current thread main
>
> If I create a WicketTester and want to reuse it in the next cron job I get
> the same exception. I need to do this every time in my CronJob and it seems
> to expensive.
>
> Injector injector = Guice.createInjector(new MediaModule());
> WicketTester tester = new WicketTester( new TestApplication(injector) );
> ....use the tester
>
> Do I really need to do this every time the CronJob executes?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/WicketTester-in-Thread-tp4665477.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>