ServletContextAware interface ignored for custom ActionMapper
-------------------------------------------------------------

                 Key: WW-3221
                 URL: https://issues.apache.org/struts/browse/WW-3221
             Project: Struts 2
          Issue Type: Improvement
    Affects Versions: 2.1.6
         Environment: Windows XP, Jetty (under Google App Engine java dev 
environment).
            Reporter: Todd Owen
            Priority: Minor


I am implementing an ActionMapper by extending DefaultActionMapper. I would 
like to access the ServletContext, where some application-specific 
configuration is stored. Since the docs for the ServletContextAware interface 
say that it is: "for components that have a dependence on the Servlet context", 
I implemented this interface but it's method (setServletContext) is never 
called. Here is the class:

        public class RexMapper
        extends org.apache.struts2.dispatcher.mapper.DefaultActionMapper
        implements ServletContextAware {        
                public RexMapper() {
                        // This constructor *is* called.
                }

                @Override
                public void setServletContext(ServletContext arg0) {
                        // This method is *not* called.
                }
        }

In struts.xml:

        <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" 
name="rexMapper" class="org.technologyforchange.rex.RexMapper"/>

I have been able to work around this by using the internal dependency injection 
framework: I add a javax.servlet.ServletContext parameter to the constructor, 
and annotate it with @com.opensymphony.xwork2.inject.Inject. However, I 
understand that developers are encouraged not to rely on the internal injection 
framework. Therefore, I'm reporting this to JIRA.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to