>>>>> Steinar Bang <[email protected]>: > Does anyone have a code example for how to get the ServletContext in a > filter?
> I tried adding a @Reference for javax.servlet.ServletContext in a DS > component, but that @Reference never received a service injection. I've found this http://blog.vogella.com/2017/04/20/access-osgi-services-via-web-interface/ (search for "Register Filters") @Component( property = "osgi.http.whiteboard.filter.pattern=/invert", scope=ServiceScope.PROTOTYPE) public class SimpleServletFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } ... } Unfortunately, for the AbstractShiroFilter class the init(FilterConfig) method is made final in a base class: https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java#L94 and the onFilterConfgSet() method https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractFilter.java#L121 is made final in the AbstractShiroFilterClass: https://github.com/apache/shiro/blob/master/web/src/main/java/org/apache/shiro/web/servlet/AbstractShiroFilter.java#L149 Is there any guarantee that activate() won't be called until after init(FilterConfig) has been called? -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected] --- You received this message because you are subscribed to the Google Groups "OPS4J" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
