You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thim Anneessens <th...@gmail.com> on 2012/05/25 12:18:32 UTC

How to get a service whithout using @Inject

Hello,

I need to use a Tapestry service outside of the Tapestry scope (in 
another servlet of the same web app) and would like to know what is the 
cleanest way to achieve this.

Thanks,
Thim.

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


Re: How to get a service whithout using @Inject

Posted by Lance Java <la...@googlemail.com>.
Whilst tapestry will happily work side-by-side with other servlets, you can
get tapestry to instantiate a servlet and delegate to it. Here is my recent
attempt at integrating DWR with tapestry before I abandoned the idea.

https://github.com/uklance/tapestry-push/blob/master/src/main/java/com/lazan/push/dwr/DwrHttpServletRequestFilter.java
https://github.com/uklance/tapestry-push/blob/master/src/main/java/com/lazan/services/AppModule.java

One of the benefits of this approach is that you can provide the
functionality in a separate jar without needing to add to web.xml and you
can configure the servlet init-params as tapestry symbols.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-get-a-service-whithout-using-Inject-tp5713412p5713424.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: How to get a service whithout using @Inject

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 25 May 2012 07:18:32 -0300, Thim Anneessens <th...@gmail.com>  
wrote:

> Hello,

Hi!

> I need to use a Tapestry service outside of the Tapestry scope (in  
> another servlet of the same web app) and would like to know what is the  
> cleanest way to achieve this.

The Tapestry-created Registry instance is stored in the  
TapestryFilter.REGISTRY_CONTEXT_NAME  
(org.apache.tapestry5.application-registry) attribute of the  
ServletContext. From the Registry instance you can use its getService()  
methods (which are inherited from ObjectLocator) to get configured  
services. That's exactly the methods used by the code that handles  
@Inject. Registry has also the autobuild() method to create an instance of  
any class with dependencies injected.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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