Issue Type: Bug Bug
Affects Versions: 5.0, 4.5.9
Assignee: Philipp Bärfuss
Components: rendering
Created: 03/Jul/13 5:56 PM
Description:

We use now the proxy based bean merger but build again and again such proxy objects. I quickly improved the info.magnolia.beanmerger.ProxyBasedBeanMerger by adding value caching.


       @Override
        public Object invoke(Object proxy, Method method, Object[] arguments) throws Throwable {
        	// only merge calls to property getters
            if (arguments.length > 0) {
                // invoke the method on the first possibility
                for (Object source : sources) {
                    if(method.getDeclaringClass().isInstance(source)){
                    	if(method.getName().startsWith("set")){
                    		String getterMethodName = "get" + StringUtils.removeStart(method.getName(),"set");
                    		cache.remove(getterMethodName);
                    	}
                        return method.invoke(source, arguments);
                    }
                }
                throw new IllegalStateException("Can't call method " + method.getName() + " on any of the sources.");
            }

            // try to use cache
            if(cache.containsKey(method.getName())){
            	return cache.get(method.getName());
            }

            List values = new ArrayList();
            for (Object obj : sources) {
                values.add(evaluate(obj, method, arguments));
            }

            Object merged = merger.merge(values);
            cache.put(method.getName(), merged);
            return merged;
        }
Project: Magnolia
Priority: Critical Critical
Reporter: Philipp Bärfuss
Security Level: Public
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



----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to