[richfaces-svn-commits] JBoss Rich Faces SVN: r4926 - in trunk: cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el and 4 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Dec 19 11:17:42 EST 2007
Author: maksimkaszynski
Date: 2007-12-19 11:17:42 -0500 (Wed, 19 Dec 2007)
New Revision: 4926
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationContext.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java
trunk/cdk/maven-javascript-plugin/
trunk/docs/faq/en/
trunk/extensions/portletbridge/portletbridge-impl/
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
Log:
more thorough property resolution
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java 2007-12-19 16:06:59 UTC (rev 4925)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java 2007-12-19 16:17:42 UTC (rev 4926)
@@ -28,9 +28,13 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.ajax4jsf.builder.config.ClassVisitor;
+import org.ajax4jsf.builder.config.ClassWalkingLogic;
import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
import org.ajax4jsf.templatecompiler.elements.ElementsFactory;
import org.ajax4jsf.templatecompiler.elements.TemplateElement;
@@ -79,7 +83,10 @@
private String[] EncodeChildren;
- private HashMap<String, Class> variables = new HashMap<String, Class>();
+ private Map<String, Map<String, PropertyDescriptor>> resolvedProperties =
+ new HashMap<String, Map<String,PropertyDescriptor>>();
+
+ private HashMap<String, Class<?>> variables = new HashMap<String, Class<?>>();
private static String[] defaultImports = new String[] {
"java.util.Iterator", "java.util.Collection",
@@ -92,7 +99,7 @@
private TemplateElement tree;
- private ArrayList<ElementsFactory> elementFactories = new ArrayList<ElementsFactory>();
+ private List<ElementsFactory> elementFactories = new ArrayList<ElementsFactory>();
/**
@@ -312,14 +319,14 @@
addVariable(variableName, "java.lang.String");
}
- public void addVariable(String variableName, Class clazz) {
+ public void addVariable(String variableName, Class<?> clazz) {
this.variables.put(variableName, clazz);
}
public void addVariable(String variableName, String typeName)
throws CompilationException {
try {
- Class clazz = loadClass(typeName);
+ Class<?> clazz = loadClass(typeName);
this.variables.put(variableName, clazz);
} catch (ClassNotFoundException e) {
// error("Error create variable "+variableName+" with type "+typeName, e);
@@ -331,12 +338,12 @@
return this.variables.containsKey(variableName);
}
- public Class getVariableType(String variableName) {
+ public Class<?> getVariableType(String variableName) {
return this.variables.get(variableName);
}
- public Class loadClass(String className) throws ClassNotFoundException {
- Class clazz = null;
+ public Class<?> loadClass(String className) throws ClassNotFoundException {
+ Class<?> clazz = null;
try {
clazz = this.classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
@@ -362,9 +369,9 @@
"org.ajax4jsf.renderkit.ComponentVariables");
}
- public Class getMethodReturnedClass(Class clazz, String methodName,
- Class[] parametersTypes) {
- Class returnedType = null;
+ public Class<?> getMethodReturnedClass(Class<?> clazz, String methodName,
+ Class<?>[] parametersTypes) {
+ Class<?> returnedType = null;
log.debug("class : " + clazz.getName() + "\n\t method : "
+ methodName + "\n\t paramTypes : "
+ Arrays.asList(parametersTypes).toString());
@@ -383,24 +390,36 @@
return returnedType;
}
- public PropertyDescriptor getPropertyDescriptor(Class clazz,
+ public PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
String propertyName) {
- PropertyDescriptor returnValue = null;
+
+ Map<String, PropertyDescriptor> descriptors =
+ resolvedProperties.get(clazz.getName());
+
+ if (descriptors == null) {
+ descriptors = resolveProperties(clazz);
+ resolvedProperties.put(clazz.getName(), descriptors);
+ }
+
+
+ return descriptors.get(propertyName);
+ }
- PropertyDescriptor[] propertyDescriptors = PropertyUtils
- .getPropertyDescriptors(clazz);
-
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor descriptor = propertyDescriptors[i];
- if (descriptor.getName().equals(propertyName)) {
- returnValue = descriptor;
- break;
+ private Map<String, PropertyDescriptor> resolveProperties(Class<?> clazz) {
+ final Map<String, PropertyDescriptor> descriptors =
+ new HashMap<String, PropertyDescriptor>();
+
+ new ClassWalkingLogic(clazz).walk(new ClassVisitor() {
+ public void visit(Class<?> clazz) {
+ PropertyDescriptor[] pds = PropertyUtils.getPropertyDescriptors(clazz);
+ for (PropertyDescriptor descriptor : pds) {
+ descriptors.put(descriptor.getName(), descriptor);
+ }
}
- }
-
- return returnValue;
+ });
+ return descriptors;
}
-
+
/**
*
*/
@@ -497,5 +516,9 @@
throw new CompilationException(e.getLocalizedMessage());
}
return out.toString();
- }
+ }
+
+ public Map<String, Map<String, PropertyDescriptor>> getResolvedProperties() {
+ return resolvedProperties;
+ }
}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationContext.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationContext.java 2007-12-19 16:06:59 UTC (rev 4925)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationContext.java 2007-12-19 16:17:42 UTC (rev 4926)
@@ -102,23 +102,23 @@
*/
public void addVariable(String variableName) throws CompilationException;
- public void addVariable(String variableName, Class clazz);
+ public void addVariable(String variableName, Class<?> clazz);
public void addVariable(String variableName, String typeName)
throws CompilationException;
public boolean containsVariable(String variableName);
- public Class getVariableType(String variableName);
+ public Class<?> getVariableType(String variableName);
public void setDefaultVariables() throws CompilationException;
- public Class loadClass(String className) throws ClassNotFoundException;
+ public Class<?> loadClass(String className) throws ClassNotFoundException;
- public Class getMethodReturnedClass(Class clazz, String methodName,
- Class[] parametersTypes);
+ public Class<?> getMethodReturnedClass(Class<?> clazz, String methodName,
+ Class<?>[] parametersTypes);
- public PropertyDescriptor getPropertyDescriptor(Class clazz,
+ public PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
String propertyName);
public TemplateElement getTree();
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java 2007-12-19 16:06:59 UTC (rev 4925)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java 2007-12-19 16:17:42 UTC (rev 4926)
@@ -24,14 +24,13 @@
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.el.PropertyNotFoundException;
import org.ajax4jsf.templatecompiler.builder.CompilationContext;
import org.ajax4jsf.templatecompiler.builder.StringUtils;
-import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -78,7 +77,7 @@
private static final Log log = LogFactory.getLog(ELCompiler.class);
- Map functionsMap = new HashMap();
+ Map<String, String> functionsMap = new HashMap<String,String>();
static {
}
@@ -598,29 +597,16 @@
* @param propertyName
* @return
*/
- private PropertyDescriptor getPropertyDescriptor(Class clazz,
- String propertyName) {
- PropertyDescriptor returnValue = null;
-
- PropertyDescriptor[] propertyDescriptors = PropertyUtils
- .getPropertyDescriptors(clazz);
-
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor descriptor = propertyDescriptors[i];
- if (descriptor.getName().equals(propertyName)) {
- returnValue = descriptor;
- break;
- }
- }
-
- return returnValue;
+ private PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
+ String propertyName, CompilationContext compilationContext) {
+ return compilationContext.getPropertyDescriptor(clazz, propertyName);
}
private boolean processingValue(AstValue node, StringBuffer sb,
CompilationContext componentBean) {
- String lastIndexValue = "NULL";
+ String lastIndexValue = "null";
String lastVariableType = null;
- ArrayList names = new ArrayList();
+ List<String> names = new ArrayList<String>();
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
StringBuffer sb1 = new StringBuffer();
@@ -644,10 +630,10 @@
if (lastVariableType != null) {
try {
- Class clazz = componentBean.loadClass(lastVariableType);
+ Class<?> clazz = componentBean.loadClass(lastVariableType);
PropertyDescriptor propertyDescriptor = getPropertyDescriptor(
- clazz, propertyName);
+ clazz, propertyName, componentBean);
if (propertyDescriptor == null) {
throw new PropertyNotFoundException("property: "
@@ -714,8 +700,7 @@
if (names.size() != 0) {
StringBuffer tmpbuf = new StringBuffer();
- for (Iterator iter = names.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
+ for (String element : names) {
if (tmpbuf.length() != 0) {
tmpbuf.append(".");
}
Property changes on: trunk/cdk/maven-javascript-plugin
___________________________________________________________________
Name: svn:ignore
- target
+ target
.classpath
.project
.settings
Property changes on: trunk/docs/faq/en
___________________________________________________________________
Name: svn:ignore
- target
+ target
.project
.settings
Property changes on: trunk/extensions/portletbridge/portletbridge-impl
___________________________________________________________________
Name: svn:ignore
+ .classpath
.project
.settings
target
Modified: trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
--- trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2007-12-19 16:06:59 UTC (rev 4925)
+++ trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2007-12-19 16:17:42 UTC (rev 4926)
@@ -175,7 +175,4 @@
public abstract void setAttachTiming( String attachTiming);
public abstract String getAttachTiming();
-
- public abstract void setDisableDefault(boolean attachTiming);
- public abstract boolean isDisableDefault();
}
More information about the richfaces-svn-commits
mailing list