From 41982aa2bf1d109e86038da4b62fbd574d303417 Mon Sep 17 00:00:00 2001 From: rsrinivasan Date: Tue, 10 Nov 2009 06:02:22 +0000 Subject: 3.0.5Patch - Bug 293211 - Performance problem when validate managed properties --- .../jst/jsf/common/util/JDTBeanIntrospector.java | 6 +- .../common/util/JDTBeanPropertyWorkingCopy.java | 64 ++++++++++++++++------ 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java index 526d717ff..5175158cf 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanIntrospector.java @@ -49,6 +49,7 @@ public class JDTBeanIntrospector private final static String IS_PREFIX = "is"; //$NON-NLS-1$ private final IType _type; + private final HashMap _resolvedSignatures; /** * @param type @@ -56,6 +57,7 @@ public class JDTBeanIntrospector public JDTBeanIntrospector(IType type) { _type = type; + _resolvedSignatures = new HashMap(); } /** @@ -65,6 +67,8 @@ public class JDTBeanIntrospector */ public Map getProperties() { + _resolvedSignatures.clear(); + final Map propertiesWorkingCopy = new HashMap(); final IMethod[] methods = getAllMethods(); @@ -138,7 +142,7 @@ public class JDTBeanIntrospector if (workingCopy == null) { - workingCopy = new JDTBeanPropertyWorkingCopy(_type); + workingCopy = new JDTBeanPropertyWorkingCopy(_type, _resolvedSignatures); properties.put(propertyName, workingCopy); } diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java index f3bdf1408..4179f0901 100644 --- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java +++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/util/JDTBeanPropertyWorkingCopy.java @@ -11,8 +11,10 @@ package org.eclipse.jst.jsf.common.util; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; @@ -35,7 +37,19 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty * the IMethod for the boolean "is" accessor method */ private IMethod _isGetter; + + private final Map _resolvedSignatureMap; + /** + * @param type + * @param resolvedSignatureMap + */ + public JDTBeanPropertyWorkingCopy(IType type, Map resolvedSignatureMap) + { + super(type); + _setters = new ArrayList(); + _resolvedSignatureMap = resolvedSignatureMap; + } /** * Constructor * @param type @@ -44,6 +58,7 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty { super(type); _setters = new ArrayList(); + _resolvedSignatureMap = new HashMap(); } /** @@ -80,36 +95,39 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty beanProp.setGetter(getter); beanProp.setSetter(matchedSetter); return beanProp; + } private IMethod determineMatchedSetter(IMethod getter) { IMethod matchedSetter = null; - try + // if there are no setters, there is no point in proceeding + if (_setters.size() < 1) { - final String getterSig = - TypeUtil.resolveTypeSignature(_type, getter.getReturnType()); + return null; + } + try + { + final String getterSig = getResolvedSignature(_type, getter.getReturnType()); FIND_MATCHING_SETTER:for (final Iterator it = _setters.iterator(); it.hasNext();) { final IMethod setter = (IMethod) it.next(); - if (setter.getNumberOfParameters() == 1) + assert (setter.getNumberOfParameters() == 1); + final String paramSig = + getResolvedSignature + (_type,setter.getParameterTypes()[0]); + + if (paramSig.equals(getterSig)) { - final String paramSig = - TypeUtil.resolveTypeSignature - (_type,setter.getParameterTypes()[0]); - - if (paramSig.equals(getterSig)) - { - // we've found our match since only one - // setter with the same name as the getter - // can have the same matching type for a - // single arg method - matchedSetter = setter; - break FIND_MATCHING_SETTER; - } + // we've found our match since only one + // setter with the same name as the getter + // can have the same matching type for a + // single arg method + matchedSetter = setter; + break FIND_MATCHING_SETTER; } } } @@ -160,4 +178,16 @@ public class JDTBeanPropertyWorkingCopy extends JDTBeanProperty public IMethod getIsGetter() { return _isGetter; } + + private String getResolvedSignature(final IType type, final String unresolved) + { + String resolved = _resolvedSignatureMap.get(unresolved); + + if (resolved == null) + { + resolved = TypeUtil.resolveTypeSignature(_type, unresolved); + _resolvedSignatureMap.put(unresolved, resolved); + } + return resolved; + } } -- cgit v1.2.3