You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@gunnsoft.com.au> on 2007/11/15 00:35:47 UTC
T4 - access hivemind registry from another servlet
Ok, so the tapestry servlet initializes and stores the hivemind registry
for use within tapestry. My hivemind services and tapestry components
and pages can find each other via injection or context method calls.
That's fine, but now I've got separate servlet in which I need to have
access to my hivemind services. What's the best way to do this?
Thanks, Paul.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T4 - access hivemind registry from another servlet
Posted by Paul Stanton <pa...@gunnsoft.com.au>.
ok thankyou, i've extended the servlet.
Renat Zubairov wrote:
> Another way to extend Application servlet from tapestry and with your
> implementation and then just replace ApplicationServlet declaration inside
> web.xml with your new class.
> Logic is more or less the same.
>
> On 15/11/2007, Jili Lv <lj...@gmail.com> wrote:
>
>> 1. Add a filter class :
>>
>> package com.example;
>>
>> import java.io.IOException;
>>
>> import javax.servlet.Filter;
>> import javax.servlet.FilterChain;
>> import javax.servlet.FilterConfig;
>> import javax.servlet.ServletException;
>> import javax.servlet.ServletRequest;
>> import javax.servlet.ServletResponse;
>>
>> import org.apache.hivemind.Registry;
>>
>> public class HivemindRegistryPublishFilter implements Filter {
>>
>> private FilterConfig config;
>>
>> static public Registry getRegistry() {
>> return _localRegistry.get();
>> }
>>
>> public void init(FilterConfig config) throws ServletException {
>> this.config = config;
>> }
>>
>> public void destroy() {
>> }
>>
>> public void doFilter(ServletRequest request, ServletResponse
>> response, FilterChain chain)
>> throws IOException, ServletException {
>> try
>> {
>> // tapestry 4.1.2 servlet name is xxx.
>>
>> _localRegistry.set((Registry)config.getServletContext().getAttribute("
>> org.apache.tapestry.Registry:"
>> + "xxx"));
>> chain.doFilter(request, response);
>> } finally {
>> _localRegistry.set(null);
>> }
>> }
>>
>> static protected ThreadLocal<Registry> _localRegistry = new
>> ThreadLocal<Registry>();
>> }
>>
>> 2. configure web.xml
>>
>> <filter>
>> <filter-name>registryFilter</filter-name>
>> <filter-class>com.example.HivemindRegistryPublishFilter
>> </filter-class>
>> </filter>
>> <filter-mapping>
>> <filter-name>registryFilter</filter-name>
>> <url-pattern>/*</url-pattern>
>> </filter-mapping>
>>
>> 3. now get Registry use
>> com.example.HivemindRegistryPublishFilter.getRegistry()
>>
>> this is base on the hivetranse source code
>> http://hivetranse.sourceforge.net/
>>
>> 2007/11/15, Paul Stanton <pa...@gunnsoft.com.au>:
>>
>>> Ok, so the tapestry servlet initializes and stores the hivemind registry
>>> for use within tapestry. My hivemind services and tapestry components
>>> and pages can find each other via injection or context method calls.
>>> That's fine, but now I've got separate servlet in which I need to have
>>> access to my hivemind services. What's the best way to do this?
>>>
>>> Thanks, Paul.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T4 - access hivemind registry from another servlet
Posted by Renat Zubairov <re...@gmail.com>.
Another way to extend Application servlet from tapestry and with your
implementation and then just replace ApplicationServlet declaration inside
web.xml with your new class.
Logic is more or less the same.
On 15/11/2007, Jili Lv <lj...@gmail.com> wrote:
>
> 1. Add a filter class :
>
> package com.example;
>
> import java.io.IOException;
>
> import javax.servlet.Filter;
> import javax.servlet.FilterChain;
> import javax.servlet.FilterConfig;
> import javax.servlet.ServletException;
> import javax.servlet.ServletRequest;
> import javax.servlet.ServletResponse;
>
> import org.apache.hivemind.Registry;
>
> public class HivemindRegistryPublishFilter implements Filter {
>
> private FilterConfig config;
>
> static public Registry getRegistry() {
> return _localRegistry.get();
> }
>
> public void init(FilterConfig config) throws ServletException {
> this.config = config;
> }
>
> public void destroy() {
> }
>
> public void doFilter(ServletRequest request, ServletResponse
> response, FilterChain chain)
> throws IOException, ServletException {
> try
> {
> // tapestry 4.1.2 servlet name is xxx.
>
> _localRegistry.set((Registry)config.getServletContext().getAttribute("
> org.apache.tapestry.Registry:"
> + "xxx"));
> chain.doFilter(request, response);
> } finally {
> _localRegistry.set(null);
> }
> }
>
> static protected ThreadLocal<Registry> _localRegistry = new
> ThreadLocal<Registry>();
> }
>
> 2. configure web.xml
>
> <filter>
> <filter-name>registryFilter</filter-name>
> <filter-class>com.example.HivemindRegistryPublishFilter
> </filter-class>
> </filter>
> <filter-mapping>
> <filter-name>registryFilter</filter-name>
> <url-pattern>/*</url-pattern>
> </filter-mapping>
>
> 3. now get Registry use
> com.example.HivemindRegistryPublishFilter.getRegistry()
>
> this is base on the hivetranse source code
> http://hivetranse.sourceforge.net/
>
> 2007/11/15, Paul Stanton <pa...@gunnsoft.com.au>:
> > Ok, so the tapestry servlet initializes and stores the hivemind registry
> > for use within tapestry. My hivemind services and tapestry components
> > and pages can find each other via injection or context method calls.
> > That's fine, but now I've got separate servlet in which I need to have
> > access to my hivemind services. What's the best way to do this?
> >
> > Thanks, Paul.
> >
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
--
Best regards,
Renat Zubairov
Re: T4 - access hivemind registry from another servlet
Posted by Jili Lv <lj...@gmail.com>.
1. Add a filter class :
package com.example;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.hivemind.Registry;
public class HivemindRegistryPublishFilter implements Filter {
private FilterConfig config;
static public Registry getRegistry() {
return _localRegistry.get();
}
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void destroy() {
}
public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain)
throws IOException, ServletException {
try
{
// tapestry 4.1.2 servlet name is xxx.
_localRegistry.set((Registry)config.getServletContext().getAttribute("org.apache.tapestry.Registry:"
+ "xxx"));
chain.doFilter(request, response);
} finally {
_localRegistry.set(null);
}
}
static protected ThreadLocal<Registry> _localRegistry = new
ThreadLocal<Registry>();
}
2. configure web.xml
<filter>
<filter-name>registryFilter</filter-name>
<filter-class>com.example.HivemindRegistryPublishFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>registryFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3. now get Registry use com.example.HivemindRegistryPublishFilter.getRegistry()
this is base on the hivetranse source code
http://hivetranse.sourceforge.net/
2007/11/15, Paul Stanton <pa...@gunnsoft.com.au>:
> Ok, so the tapestry servlet initializes and stores the hivemind registry
> for use within tapestry. My hivemind services and tapestry components
> and pages can find each other via injection or context method calls.
> That's fine, but now I've got separate servlet in which I need to have
> access to my hivemind services. What's the best way to do this?
>
> Thanks, Paul.
>
>
>
> ---------------------------------------------------------------------
> 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