Just to clarify Jimmy, you don't need to implement your own servlet filter -
that is just an example of some of my code getting a service from the ioc
registry - anywhere you can access the servlet context you should be able to
retrieve the service you want.  I'm a bit of a newbie myself with Tapestry,
but I'm not sure what benefit the access you are looking for would give - it
looks to me like the differences you are talking about are just semantics -
the servlet context is available through the web app - the registry is
available from the servlet context - the service you want is retrievable
from the ioc registry keyed on its interface name.  Perhaps what you are
looking for is access to the ioc registry from a non web app perspective?
I'm sure some of the more experienced Tapestry people on the list can point
you in the right direction if that is the case.

Regards,
Jim.

-----Original Message-----
From: Jimmy.Lew [mailto:jae...@aol.com] 
Sent: 29 June 2010 17:53
To: users@tapestry.apache.org
Subject: RE: Is there anyway to access injected service instance out of box?


first of all, thanks million for the responses. If i didn't misunderstand ,
i
have to implement a customized filter under tapestry project.  My target is
to be able to get my injected service from the Registry object out of
tapestry module at run-time, the injected service is global singleton and it
is managed by Tapestry IOC module.

At run-time, the Registry object is initialized by "public final void
init(FilterConfig filterConfig)" method and is saved as an attribute object
of ServletContext. I'm just trying to get the Registry object out of
Tapestry module with noninvasive way, it seems that in the javadoc of
Tapestry, there's no such API that enables user to access injected service
through Registry object like: 

public static Registry RegistryFactory.getRegistry(String moduleName){...};

I think IOC module could use a Map like structure to manage the unique
Registry of every TapestryModule, like <ModuleName,Registry> and provide an
uniform Interface for other framework to access.





jc1001 wrote:
> 
> I forgot to put:
> 
> HttpSession session = req.getSession(false); 
> 
> ... in the code below.  Anyhoo just saw "static" in your original query -
> not sure if this is what you require.
> 
> Regards,
> Jim.
> 
> -----Original Message-----
> From: Jim O'Callaghan [mailto:jc1000...@yahoo.co.uk] 
> Sent: 29 June 2010 15:17
> To: 'Tapestry users'
> Subject: RE: Is there anyway to access injected service instance out of
> box?
> 
> Can't you do it in a filter? - 
> 
> public void doFilter(ServletRequest request, ServletResponse response,
>                       FilterChain chain) throws IOException,
> ServletException {
>       HttpServletRequest req = (HttpServletRequest) request;
>       ServletContext context = session.getServletContext(); 
>       Registry registry = (Registry)
> context.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);
>       MyServiceInterface myInjectedServiceInstance =
> registry.getService(YourServiceInterface.class)
> 
> Regards,
> Jim.
> 
> -----Original Message-----
> From: Jimmy.Lew [mailto:jae...@aol.com] 
> Sent: 29 June 2010 13:58
> To: users@tapestry.apache.org
> Subject: Re: Is there anyway to access injected service instance out of
> box?
> 
> 
> You mean like this:
> 
> ......
> Registry reg=servletContext.getAttribute(REGISTRY_CONTEXT_NAME);
> MyserviceInterface
>
myInjectedServiceInstance=reg.getService("MyserviceID",MyserviceInterface.cl
> ass);
> ......
> 
> but how could i get the singleton ServletContext object outside tapestry,
> i
> couldn't find any static method to reach this?
> 
> 
> 
> Christophe Cordenier wrote:
>> 
>> Hi
>> 
>> Tapestry Registry allows you to access all the services your have
>> declared,
>> it is available in the servlet context under this name :
>> 
>>     public static final String REGISTRY_CONTEXT_NAME =
>> "org.apache.tapestry5.application-registry";
>> 
>> 2010/6/29 Jimmy.Lew <jae...@aol.com>
>> 
>>>
>>> Does Tapestry IOC module  provide API to allow other frameworks to
>>> access
>>> injected service instance? e.g., i want to use DWR to check a injected
>>> session manager service in a tapestry page. Appreciate somebody could
>>> give
>>> a
>>> hint.
>>> --
>>> View this message in context:
>>>
>
http://old.nabble.com/Is-there-anyway-to-access-injected-service-instance-ou
> t-of-box--tp29020920p29020920.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>> 
>> 
>> -- 
>> Regards,
>> Christophe Cordenier.
>> 
>> Committer on Apache Tapestry 5
>> Co-Creator of wooki @wookicentral.com
>> 
>> 
> 
> -- 
> View this message in context:
>
http://old.nabble.com/Is-there-anyway-to-access-injected-service-instance-ou
> t-of-box--tp29020920p29023334.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context:
http://old.nabble.com/Is-there-anyway-to-access-injected-service-instance-ou
t-of-box--tp29020920p29025872.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


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

Reply via email to