That's what the other one did, but it used the callback methods to do
the set/unset.  This way, you don't have to clutter up each task's
code.

On Fri, May 28, 2010 at 4:23 PM, Douglas Ferguson
<doug...@douglasferguson.us> wrote:
> This worked for me..
>
>
>                                                                               
> �...@override
>                                                                               
>  public void run() {
>                                                                               
>          try {
>                                                                               
>                  Application.set(app);
>                                                                               
>                  //Do my long running operation
>                                                                               
>          } catch (Throwable t) {
>                                                                               
>                  log.error("Error doing it...: " + t.getMessage(), t);
>                                                                               
>          }finally{
>                                                                               
>                  Application.unset();
>                                                                               
>          }
>                                                                               
>  }
>
>
> Now, it's time to brainstorm as to how I could make this work generically...
>
>
> On May 28, 2010, at 11:34 AM, James Carman wrote:
>
>> Perhaps you would be interested in the other threads that have been
>> going on where we discuss InheritableThreadLocal.  In there Jeremy
>> gave a good solution that would fix what you're seeing.  Basically,
>> you use the beforeExecute()/afterExecute() methods to set/clear the
>> Application's ThreadLocal variable so that it's available during the
>> execution of the task.
>>
>> On Fri, May 28, 2010 at 12:01 PM, Douglas Ferguson
>> <doug...@douglasferguson.us> wrote:
>>> I'm still spinning my wheels on this one.
>>>
>>> Let me try to explain better..
>>>
>>> On the page I have
>>>
>>> @Inject DAOFactory
>>> @Inject MyService
>>>
>>> On the DAOFactory I have
>>>
>>> @Inject DAO1
>>> @Inject DAO2
>>> etc...
>>>
>>> On MyService I have
>>>
>>> @Inject DAO1
>>>
>>> In my module I have
>>>
>>> bind(MyService.class).toInstance(new MyService());
>>> bind(IDAOFactory.class).to(DAOFactory.class).in(Singleton.class);
>>> bind(DAO1.class).in(Singleton.class);
>>> bind(DAO2.class).in(Singleton.class);
>>>
>>> On the page I also have:
>>>
>>> genericWorkPool.submit(new Runnable() {
>>>
>>> @Override
>>> public void run() {
>>> try {
>>> //Do stuff with DAOFactory -- works
>>>                       //Do stuff with MyService -- Blow ups <<<---- See 
>>> exception below
>>> } catch (Throwable t) {
>>> log.error("Error sending email on Signup: " + t.getMessage(), t);
>>> }
>>> }
>>> }
>>>
>>> This is the error I get
>>>
>>> org.apache.wicket.WicketRuntimeException: There is no application attached 
>>> to current thread pool-13-thread-3
>>> at org.apache.wicket.Application.get(Application.java:179)
>>> at 
>>> org.apache.wicket.guice.GuiceProxyTargetLocator.locateProxyTarget(GuiceProxyTargetLocator.java:73)
>>> at 
>>> org.apache.wicket.proxy.LazyInitProxyFactory$CGLibInterceptor.intercept(LazyInitProxyFactory.java:317)
>>> at 
>>> WICKET_com.conducive.logic.buzzbox.BuzzboxEmailGenerator$$EnhancerByCGLIB$$1171cfab.generateFor(<generated>)
>>>   <-- this is "MyService"
>>>
>>> I can't understand why DAOFactory would work ok but MyService wouldn't.
>>>
>>>
>>> On May 27, 2010, at 6:53 PM, Douglas Ferguson wrote:
>>>
>>> I'm using 1.4.8 (not the ITL version).
>>>
>>> I have pass a runnable to an executer, how can I make use of classes that 
>>> use @Inject?
>>>
>>> When I try to do so, it blows up saying "There is no application attached 
>>> to current thread pool-13-thread-1"
>>>
>>> The confusing thing is that I inject 2 DAOs and 1 service. The 2DAOs work 
>>> just fine but the service blows up.
>>>
>>> I've tried these combinations:
>>>
>>> 1) @Inject into the page and then pass the reference to the constructor of 
>>> the runnable
>>> 2) Construct the service in the Runnable and call 
>>> @InjectorHolder.getInjector().inject(service)
>>>
>>> Neither works.
>>>
>>> D/
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to