You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by zack1403 <za...@gmail.com> on 2009/10/01 18:44:27 UTC

Best way to get service from different thread

Hi Everyone,

I have been looking through the docs and mailing list but cant find and
answer to this.  What is the best way to get an autobuilt service from a
separate thread?  I have a quartz job that needs one of my services but im
not sure what i do to get it.

Thanks,
Zack
-- 
View this message in context: http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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: Best way to get service from different thread

Posted by Howard Lewis Ship <hl...@gmail.com>.
When there are per-thread services they are there for a reason. They
tend to be rare, and hold data specific to a single request.  Remember
that the proxies are completely shareable across threads, the dispatch
to the per-thread instance occurs INSIDE the proxy.

As usual, rather than asking for a specific solution/workaround to a
specific perceived problem, you will get much more utility by
discussing what you are ultimately attempt to do. You'll usually
discover the solution is MUCH simpler than what you naively ask for.


On Thu, Oct 1, 2009 at 12:14 PM, zack1403 <za...@gmail.com> wrote:
>
> Because the thread might use any number of different services and it would be
> nice to be able to just grab them at will from another thread rather than
> modifying a constructor each time.  I guess I'll just have pass all the
> objects.  Thanks for the help!
>
> Zack
>
>
> Kalle Korhonen-2 wrote:
>>
>> On Thu, Oct 1, 2009 at 10:09 AM, zack1403 <za...@gmail.com> wrote:
>>> Sorry yea I shouldnt have used quartz as an example.  I use job data map
>>> to
>>> pass hibernate stuff through in that case but what about a standalone new
>>> thread?  I have a service that spawns new tasks in new threads.  Is there
>>> a
>>> way i can inject something like service resources?
>>
>> No, not as far as I know - I suppose you could try get access to the
>> same service registry instance but it's well-hidden for a reason. Why
>> don't you just pass the required services to the thread at its
>> construction?
>>
>> Kalle
>>
>>> Kalle Korhonen-2 wrote:
>>>>
>>>> You put the service in JobDataMap and in Job you get the map from
>>>> JobExecutionContext.
>>>>
>>>> Kalle
>>>>
>>>>
>>>> On Thu, Oct 1, 2009 at 9:44 AM, zack1403 <za...@gmail.com> wrote:
>>>>>
>>>>> Hi Everyone,
>>>>>
>>>>> I have been looking through the docs and mailing list but cant find and
>>>>> answer to this.  What is the best way to get an autobuilt service from
>>>>> a
>>>>> separate thread?  I have a quartz job that needs one of my services but
>>>>> im
>>>>> not sure what i do to get it.
>>>>>
>>>>> Thanks,
>>>>> Zack
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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/Best-way-to-get-service-from-different-thread-tp25701647p25702945.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/Best-way-to-get-service-from-different-thread-tp25701647p25704884.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
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Best way to get service from different thread

Posted by zack1403 <za...@gmail.com>.
Because the thread might use any number of different services and it would be
nice to be able to just grab them at will from another thread rather than
modifying a constructor each time.  I guess I'll just have pass all the
objects.  Thanks for the help!

Zack


Kalle Korhonen-2 wrote:
> 
> On Thu, Oct 1, 2009 at 10:09 AM, zack1403 <za...@gmail.com> wrote:
>> Sorry yea I shouldnt have used quartz as an example.  I use job data map
>> to
>> pass hibernate stuff through in that case but what about a standalone new
>> thread?  I have a service that spawns new tasks in new threads.  Is there
>> a
>> way i can inject something like service resources?
> 
> No, not as far as I know - I suppose you could try get access to the
> same service registry instance but it's well-hidden for a reason. Why
> don't you just pass the required services to the thread at its
> construction?
> 
> Kalle
> 
>> Kalle Korhonen-2 wrote:
>>>
>>> You put the service in JobDataMap and in Job you get the map from
>>> JobExecutionContext.
>>>
>>> Kalle
>>>
>>>
>>> On Thu, Oct 1, 2009 at 9:44 AM, zack1403 <za...@gmail.com> wrote:
>>>>
>>>> Hi Everyone,
>>>>
>>>> I have been looking through the docs and mailing list but cant find and
>>>> answer to this.  What is the best way to get an autobuilt service from
>>>> a
>>>> separate thread?  I have a quartz job that needs one of my services but
>>>> im
>>>> not sure what i do to get it.
>>>>
>>>> Thanks,
>>>> Zack
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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/Best-way-to-get-service-from-different-thread-tp25701647p25702945.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/Best-way-to-get-service-from-different-thread-tp25701647p25704884.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: Best way to get service from different thread

Posted by Kalle Korhonen <ka...@gmail.com>.
On Thu, Oct 1, 2009 at 10:09 AM, zack1403 <za...@gmail.com> wrote:
> Sorry yea I shouldnt have used quartz as an example.  I use job data map to
> pass hibernate stuff through in that case but what about a standalone new
> thread?  I have a service that spawns new tasks in new threads.  Is there a
> way i can inject something like service resources?

No, not as far as I know - I suppose you could try get access to the
same service registry instance but it's well-hidden for a reason. Why
don't you just pass the required services to the thread at its
construction?

Kalle

> Kalle Korhonen-2 wrote:
>>
>> You put the service in JobDataMap and in Job you get the map from
>> JobExecutionContext.
>>
>> Kalle
>>
>>
>> On Thu, Oct 1, 2009 at 9:44 AM, zack1403 <za...@gmail.com> wrote:
>>>
>>> Hi Everyone,
>>>
>>> I have been looking through the docs and mailing list but cant find and
>>> answer to this.  What is the best way to get an autobuilt service from a
>>> separate thread?  I have a quartz job that needs one of my services but
>>> im
>>> not sure what i do to get it.
>>>
>>> Thanks,
>>> Zack
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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/Best-way-to-get-service-from-different-thread-tp25701647p25702945.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: Best way to get service from different thread

Posted by zack1403 <za...@gmail.com>.
Sorry yea I shouldnt have used quartz as an example.  I use job data map to
pass hibernate stuff through in that case but what about a standalone new
thread?  I have a service that spawns new tasks in new threads.  Is there a
way i can inject something like service resources?

Zack


Kalle Korhonen-2 wrote:
> 
> You put the service in JobDataMap and in Job you get the map from
> JobExecutionContext.
> 
> Kalle
> 
> 
> On Thu, Oct 1, 2009 at 9:44 AM, zack1403 <za...@gmail.com> wrote:
>>
>> Hi Everyone,
>>
>> I have been looking through the docs and mailing list but cant find and
>> answer to this.  What is the best way to get an autobuilt service from a
>> separate thread?  I have a quartz job that needs one of my services but
>> im
>> not sure what i do to get it.
>>
>> Thanks,
>> Zack
>> --
>> View this message in context:
>> http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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/Best-way-to-get-service-from-different-thread-tp25701647p25702945.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: Best way to get service from different thread

Posted by Kalle Korhonen <ka...@gmail.com>.
You put the service in JobDataMap and in Job you get the map from
JobExecutionContext.

Kalle


On Thu, Oct 1, 2009 at 9:44 AM, zack1403 <za...@gmail.com> wrote:
>
> Hi Everyone,
>
> I have been looking through the docs and mailing list but cant find and
> answer to this.  What is the best way to get an autobuilt service from a
> separate thread?  I have a quartz job that needs one of my services but im
> not sure what i do to get it.
>
> Thanks,
> Zack
> --
> View this message in context: http://www.nabble.com/Best-way-to-get-service-from-different-thread-tp25701647p25701647.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