struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeromy Evans (JIRA)" <j...@apache.org>
Subject [jira] Resolved: (WW-1681) Reimplement UIBean Key attribute to directly invoke getText rather than utilize ognl
Date Sat, 12 Apr 2008 03:15:05 GMT

     [ https://issues.apache.org/struts/browse/WW-1681?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Jeromy Evans resolved WW-1681.
------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 2.1.3)
                   2.1.1

The getText OGNL has been removed from UIBean and Label.  Instead they use the same algorithm
as the Text tag.
That is: iterate through the stack until the first TextProvider is found, then call its getText(...)
method directly.

This change removes the OGNL expression evaluation and subsequent iteration through the stack
looking for a method called getText(String).

> Reimplement UIBean Key attribute to directly invoke getText rather than utilize ognl
> ------------------------------------------------------------------------------------
>
>                 Key: WW-1681
>                 URL: https://issues.apache.org/struts/browse/WW-1681
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Tags
>    Affects Versions: 2.0.3
>            Reporter: David H. DeWolf
>            Assignee: Jeromy Evans
>             Fix For: 2.1.1
>
>
> I wrote a simple junit test (below) that tests the 2 techniques for retrieving I18N text.
 My numbers for 100 iterations were:
> Using OGNL expression: 476 ms
> Explicitly calling getText: 0 ms
> Yikes!!! There is quite a difference between the two.  The OGNL version takes 5 ms/request
compared to almost nothing for the explicit call.  It looks like it would be very beneficial
to reimplement the UIBean key lookup code based on the Text component-style of text lookup.
 I think the key attribute is a much cleaner way of specifying label text anyway so it's good
to give users an incentive to use it. :)
> Tom
> /************ start source code **************/
> package example;
> import java.util.Iterator;
> import junit.framework.TestCase;
> import com.opensymphony.xwork2.ActionSupport;
> import com.opensymphony.xwork2.TextProvider;
> import com.opensymphony.xwork2.util.OgnlValueStack;
> public class TestOgnl extends TestCase {
>    public void testOgnl() {
>        TestAction action = new TestAction();
>        OgnlValueStack stack = new OgnlValueStack();
>        stack.push(action);
>        String value = null;
>        long start = System.currentTimeMillis();
>        for(int i = 0; i < 100; i++) {
>            value = stack.findString("getText('key')");
>        }
>        long end = System.currentTimeMillis();
>        assertEquals("value", value);
>        System.out.println((end - start));
>        start = System.currentTimeMillis();
>        for(int i = 0; i < 100; i++) {
>            value = findString(stack, "key");
>        }
>        end = System.currentTimeMillis();
>        System.out.println((end - start));
>        assertEquals("value", value);
>    }
>    protected String findString(OgnlValueStack stack, String key) {
>        for(Iterator iterator = stack.getRoot().iterator(); iterator
>            .hasNext();) {
>            Object o = iterator.next();
>            if(o instanceof TextProvider) {
>                TextProvider tp = (TextProvider) o;
>                return tp.getText(key);
>            }
>        }
>        return null;
>    }
> }
> class TestAction extends ActionSupport {
>    @Override
>    public String getText(String arg0) {
>        if("key".equals(arg0)) {
>            return "value";
>        }
>        return null;
>    }
> }
> /************ end source code **************/

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


Mime
View raw message