struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-3905) The TextProvider injection in ActionSupport isn't quite integrated into the framework's core DI
Date Fri, 19 Oct 2012 05:58:03 GMT

    [ https://issues.apache.org/jira/browse/WW-3905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13479646#comment-13479646
] 

Lukasz Lenart edited comment on WW-3905 at 10/19/12 5:57 AM:
-------------------------------------------------------------

My solution is like this, you can test it by overriding getTextProvider() in your actions

{code:java}
protected TextProvider getTextProvider() {
    if (textProvider == null) {
        ObjectFactory objectFactory = ActionContext.getContext().getInstance(ObjectFactory.class);
        if (objectFactory == null) {
            TextProviderFactory tpf = new TextProviderFactory();
            textProvider = tpf.createInstance(getClass(), this);
        } else {
            try {
                Map<String, Object> context = Collections.emptyMap();
                textProvider = (TextProvider) objectFactory.buildBean(TextProvider.class,
context);
            } catch (Exception e) {
                throw new ConfigurationException("Cannot create TextProvider with ObjectFactory!",
e);
            }
        }
    }
    return textProvider;
}
{code}

The only problem is this will work only with actions, in other places a different instance
of TextProvider will be used.
                
      was (Author: lukaszlenart):
    My solution is like this, you can test it by overriding getTextProvider() in your actions

{code:java}
protected TextProvider getTextProvider() {
    if (textProvider == null) {
        TextProviderFactory tpf;
        ObjectFactory objectFactory = ActionContext.getContext().getInstance(ObjectFactory.class);
        if (objectFactory == null) {
            tpf = new TextProviderFactory();
            textProvider = tpf.createInstance(getClass(), this);
        } else {
            try {
                Map<String, Object> context = Collections.emptyMap();
                textProvider = (TextProvider) objectFactory.buildBean(TextProvider.class,
context);
            } catch (Exception e) {
                throw new ConfigurationException("Cannot create TextProvider with ObjectFactory!",
e);
            }
        }
    }
    return textProvider;
}
{code}
                  
> The TextProvider injection in ActionSupport isn't quite integrated into the framework's
core DI 
> ------------------------------------------------------------------------------------------------
>
>                 Key: WW-3905
>                 URL: https://issues.apache.org/jira/browse/WW-3905
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.3.4.1
>            Reporter: chad davis
>              Labels: ActionSupport, DependencyInjection, TextProvider
>             Fix For: 2.3.6
>
>
> The injection of the TextProvider into ActionSupport occurs via a lazy initialization
in the getTextProvider() method.  This method obtains the TextProvider from a factory that
has the implementation injected into it via  the core di mechanism.  The problem with this
is that ActionSupport programmatically does the injection using it's reference to the core
ContainerImpl.  This makes it impossible to use the Spring plugin's SpringObjectFactory to
manage this TextProvider.    

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message