Found the answer: I used WebApplicationContextUtils to get the Spring
WebApplicationContext. For example, this.webApplicationContext =
WebApplicationContextUtils.getWebApplicationContext(webContext.getContext());
Brody Wong wrote:
>
> I have written a preprocess filter for the commons chain from the
> ShaleApplicationFilter. I have also successfully integrate Shale and
> Spring using the value binding method. However, I would like to access
> the Spring Bean Factory inside the preprocess filter. Is there anyway to
> get an instance of the Spring's WebApplicationContext inside the
> preprocess filter? The following is the sample code I wrote: public class
> PermissionFilter extends AbstractRegExpFilter {
> PermissionsManager permissionsManager ;
>
> /**
> * <p>Return the servlet path (if any) concatenated with the path info
> * (if any) for this request.</p>
> *
> * @param context <code>Context</code> for the current request
> */
> protected String value(ShaleWebContext context) {
>
> if (this.permissionsManager == null) {
>
> WebApplicationContext wac =
> (WebApplicationContext)context.getContext() ;
> this.permissionsManager =
> (PermissionsManager)wac.getBean("permissionsManager") ;
>
> }
> String servletPath = context.getRequest().getServletPath();
> if (servletPath == null) {
> servletPath = "";
> }
> String pathInfo = context.getRequest().getPathInfo();
> if (pathInfo == null) {
> pathInfo = "";
> }
> return servletPath + pathInfo ;
>
> }
>
>
> }
> But it fails when casting the servlet context to Spring's
> WebApplicationContext. Thanks in advance for your help.
>
--
View this message in context:
http://www.nabble.com/Accessing-Spring-Beans-inside-ShaleApplication-preprocess-hook-tf4219349.html#a12010504
Sent from the Shale - User mailing list archive at Nabble.com.