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 <[EMAIL PROTECTED]>:
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]