Author: remy.maucherat(a)jboss.com
Date: 2007-12-07 12:39:11 -0500 (Fri, 07 Dec 2007)
New Revision: 377
Modified:
trunk/java/javax/el/BeanELResolver.java
trunk/java/javax/el/ResourceBundleELResolver.java
Log:
- Forgotten API fixes.
Modified: trunk/java/javax/el/BeanELResolver.java
===================================================================
--- trunk/java/javax/el/BeanELResolver.java 2007-12-07 16:46:44 UTC (rev 376)
+++ trunk/java/javax/el/BeanELResolver.java 2007-12-07 17:39:11 UTC (rev 377)
@@ -34,299 +34,311 @@
public class BeanELResolver extends ELResolver {
- private final boolean readOnly;
+ private final boolean readOnly;
- private final ConcurrentCache<String, BeanProperties> cache = new
ConcurrentCache<String, BeanProperties>(
- 1000);
+ private final ConcurrentCache<String, BeanProperties> cache = new
ConcurrentCache<String, BeanProperties>(
+ 1000);
- public BeanELResolver() {
- this.readOnly = false;
- }
+ public BeanELResolver() {
+ this.readOnly = false;
+ }
- public BeanELResolver(boolean readOnly) {
- this.readOnly = readOnly;
- }
+ public BeanELResolver(boolean readOnly) {
+ this.readOnly = readOnly;
+ }
- public Object getValue(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
- if (base == null || property == null) {
- return null;
- }
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return null;
+ }
- context.setPropertyResolved(true);
- Method m = this.property(context, base, property).read(context);
- try {
- return m.invoke(base, (Object[]) null);
- } catch (IllegalAccessException e) {
- throw new ELException(e);
- } catch (InvocationTargetException e) {
- throw new ELException(message(context, "propertyReadError",
- new Object[] { base.getClass().getName(),
- property.toString() }), e.getCause());
- } catch (Exception e) {
- throw new ELException(e);
- }
- }
+ context.setPropertyResolved(true);
+ Method m = this.property(context, base, property).read(context);
+ try {
+ return m.invoke(base, (Object[]) null);
+ } catch (IllegalAccessException e) {
+ throw new ELException(e);
+ } catch (InvocationTargetException e) {
+ throw new ELException(message(context, "propertyReadError",
+ new Object[] { base.getClass().getName(),
+ property.toString() }), e.getCause());
+ } catch (Exception e) {
+ throw new ELException(e);
+ }
+ }
- public Class<?> getType(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
- if (base == null || property == null) {
- return null;
- }
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return null;
+ }
- context.setPropertyResolved(true);
- return this.property(context, base, property).getType();
- }
+ context.setPropertyResolved(true);
+ return this.property(context, base, property).getPropertyType();
+ }
- public void setValue(ELContext context, Object base, Object property,
- Object value) throws NullPointerException,
- PropertyNotFoundException, PropertyNotWritableException,
- ELException {
- if (context == null) {
- throw new NullPointerException();
- }
- if (base == null || property == null) {
- return;
- }
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return;
+ }
- context.setPropertyResolved(true);
+ context.setPropertyResolved(true);
- if (this.readOnly) {
- throw new PropertyNotWritableException(message(context,
- "resolverNotWriteable", new Object[] { base.getClass()
- .getName() }));
- }
+ if (this.readOnly) {
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
- Method m = this.property(context, base, property).write(context);
- try {
- m.invoke(base, new Object[] { value });
- } catch (IllegalAccessException e) {
- throw new ELException(e);
- } catch (InvocationTargetException e) {
- throw new ELException(message(context, "propertyWriteError",
- new Object[] { base.getClass().getName(),
- property.toString() }), e.getCause());
- } catch (Exception e) {
- throw new ELException(e);
- }
- }
+ Method m = this.property(context, base, property).write(context);
+ try {
+ m.invoke(base, value);
+ } catch (IllegalAccessException e) {
+ throw new ELException(e);
+ } catch (InvocationTargetException e) {
+ throw new ELException(message(context, "propertyWriteError",
+ new Object[] { base.getClass().getName(),
+ property.toString() }), e.getCause());
+ } catch (Exception e) {
+ throw new ELException(e);
+ }
+ }
- public boolean isReadOnly(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
- if (base == null || property == null) {
- return false;
- }
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (base == null || property == null) {
+ return false;
+ }
- context.setPropertyResolved(true);
- return this.readOnly
- || this.property(context, base, property).isReadOnly();
- }
+ context.setPropertyResolved(true);
+ return this.readOnly
+ || this.property(context, base, property).isReadOnly();
+ }
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object
base) {
- if (context == null) {
- throw new NullPointerException();
- }
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context,
Object base) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
- if (base == null) {
- return null;
- }
+ if (base == null) {
+ return null;
+ }
- try {
- BeanInfo info = Introspector.getBeanInfo(base.getClass());
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- for (int i = 0; i < pds.length; i++) {
- pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
- pds[i].setValue(TYPE, pds[i].getPropertyType());
- }
- return Arrays.asList((FeatureDescriptor[]) pds).iterator();
- } catch (IntrospectionException e) {
- //
- }
+ try {
+ BeanInfo info = Introspector.getBeanInfo(base.getClass());
+ PropertyDescriptor[] pds = info.getPropertyDescriptors();
+ for (int i = 0; i < pds.length; i++) {
+ pds[i].setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ pds[i].setValue(TYPE, pds[i].getPropertyType());
+ }
+ return Arrays.asList((FeatureDescriptor[]) pds).iterator();
+ } catch (IntrospectionException e) {
+ //
+ }
- return null;
- }
+ return null;
+ }
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
- if (context == null) {
- throw new NullPointerException();
- }
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
- if (base != null) {
- return Object.class;
- }
+ if (base != null) {
+ return Object.class;
+ }
- return null;
- }
+ return null;
+ }
- protected final static class BeanProperties {
- private final Map<String, BeanProperty> properties;
+ protected final static class BeanProperties {
+ private final Map<String, BeanProperty> properties;
- private final Class<?> type;
+ private final Class<?> type;
- public BeanProperties(Class<?> type) throws ELException {
- this.type = type;
- this.properties = new HashMap<String, BeanProperty>();
- try {
- BeanInfo info = Introspector.getBeanInfo(this.type);
- PropertyDescriptor[] pds = info.getPropertyDescriptors();
- for (int i = 0; i < pds.length; i++) {
- this.properties.put(pds[i].getName(), new BeanProperty(
- type, pds[i]));
- }
- } catch (IntrospectionException ie) {
- throw new ELException(ie);
- }
- }
+ public BeanProperties(Class<?> type) throws ELException {
+ this.type = type;
+ this.properties = new HashMap<String, BeanProperty>();
+ try {
+ BeanInfo info = Introspector.getBeanInfo(this.type);
+ PropertyDescriptor[] pds = info.getPropertyDescriptors();
+ for (int i = 0; i < pds.length; i++) {
+ this.properties.put(pds[i].getName(), new BeanProperty(
+ type, pds[i]));
+ }
+ } catch (IntrospectionException ie) {
+ throw new ELException(ie);
+ }
+ }
- public BeanProperty get(ELContext ctx, String name) {
- BeanProperty property = this.properties.get(name);
- if (property == null) {
- throw new PropertyNotFoundException(message(ctx,
- "propertyNotFound",
- new Object[] { type.getName(), name }));
- }
- return property;
- }
+ private BeanProperty get(ELContext ctx, String name) {
+ BeanProperty property = this.properties.get(name);
+ if (property == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotFound",
+ new Object[] { type.getName(), name }));
+ }
+ return property;
+ }
+
+ public BeanProperty getBeanProperty(String name) {
+ return get(null, name);
+ }
- public Class<?> getType() {
+ private Class<?> getType() {
return type;
}
- }
+ }
protected final static class BeanProperty {
- private final Class type;
+ private final Class type;
- private final Class owner;
+ private final Class owner;
- private final PropertyDescriptor descriptor;
+ private final PropertyDescriptor descriptor;
- private Method read;
+ private Method read;
- private Method write;
+ private Method write;
- public BeanProperty(Class owner, PropertyDescriptor descriptor) {
- this.owner = owner;
- this.descriptor = descriptor;
- this.type = descriptor.getPropertyType();
- }
+ public BeanProperty(Class<?> owner, PropertyDescriptor descriptor) {
+ this.owner = owner;
+ this.descriptor = descriptor;
+ this.type = descriptor.getPropertyType();
+ }
- public Class<?> getType() {
- return this.type;
- }
+ public Class getPropertyType() {
+ return this.type;
+ }
- public boolean isReadOnly() {
- return this.write == null
- && (null == (this.write = getMethod(this.owner,
descriptor.getWriteMethod())));
- }
+ public boolean isReadOnly() {
+ return this.write == null
+ && (null == (this.write = getMethod(this.owner,
descriptor.getWriteMethod())));
+ }
- public Method write(ELContext ctx) {
- if (this.write == null) {
- this.write = getMethod(this.owner, descriptor.getWriteMethod());
- if (this.write == null) {
- throw new PropertyNotFoundException(message(ctx,
- "propertyNotWritable", new Object[] {
- type.getName(), descriptor.getName() }));
- }
- }
- return this.write;
- }
+ public Method getWriteMethod() {
+ return write(null);
+ }
- public Method read(ELContext ctx) {
- if (this.read == null) {
- this.read = getMethod(this.owner, descriptor.getReadMethod());
- if (this.read == null) {
- throw new PropertyNotFoundException(message(ctx,
- "propertyNotReadable", new Object[] {
- type.getName(), descriptor.getName() }));
- }
- }
- return this.read;
- }
- }
+ public Method getReadMethod() {
+ return this.read(null);
+ }
- private final BeanProperty property(ELContext ctx, Object base,
- Object property) {
- Class<?> type = base.getClass();
- String prop = property.toString();
+ private Method write(ELContext ctx) {
+ if (this.write == null) {
+ this.write = getMethod(this.owner, descriptor.getWriteMethod());
+ if (this.write == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotWritable", new Object[] {
+ type.getName(), descriptor.getName() }));
+ }
+ }
+ return this.write;
+ }
- BeanProperties props = this.cache.get(type.getName());
- if (props == null || type != props.getType()) {
- props = new BeanProperties(type);
- this.cache.put(type.getName(), props);
- }
+ private Method read(ELContext ctx) {
+ if (this.read == null) {
+ this.read = getMethod(this.owner, descriptor.getReadMethod());
+ if (this.read == null) {
+ throw new PropertyNotFoundException(message(ctx,
+ "propertyNotReadable", new Object[] {
+ type.getName(), descriptor.getName() }));
+ }
+ }
+ return this.read;
+ }
+ }
- return props.get(ctx, prop);
- }
+ private final BeanProperty property(ELContext ctx, Object base,
+ Object property) {
+ Class<?> type = base.getClass();
+ String prop = property.toString();
- private final static Method getMethod(Class type, Method m) {
- if (m == null || Modifier.isPublic(type.getModifiers())) {
- return m;
- }
- Class[] inf = type.getInterfaces();
- Method mp = null;
- for (int i = 0; i < inf.length; i++) {
- try {
- mp = inf[i].getMethod(m.getName(), (Class[]) m.getParameterTypes());
- mp = getMethod(mp.getDeclaringClass(), mp);
- if (mp != null) {
- return mp;
- }
- } catch (NoSuchMethodException e) {
- }
- }
- Class sup = type.getSuperclass();
- if (sup != null) {
- try {
- mp = sup.getMethod(m.getName(), (Class[]) m.getParameterTypes());
- mp = getMethod(mp.getDeclaringClass(), mp);
- if (mp != null) {
- return mp;
- }
- } catch (NoSuchMethodException e) {
- }
- }
- return null;
- }
-
- private final static class ConcurrentCache<K,V> {
+ BeanProperties props = this.cache.get(type.getName());
+ if (props == null || type != props.getType()) {
+ props = new BeanProperties(type);
+ this.cache.put(type.getName(), props);
+ }
- private final int size;
- private final Map<K,V> eden;
- private final Map<K,V> longterm;
-
- public ConcurrentCache(int size) {
- this.size = size;
- this.eden = new ConcurrentHashMap<K,V>(size);
- this.longterm = new WeakHashMap<K,V>(size);
- }
-
- public V get(K key) {
- V value = this.eden.get(key);
- if (value == null) {
- value = this.longterm.get(key);
- if (value != null) {
- this.eden.put(key, value);
- }
- }
- return value;
- }
-
- public void put(K key, V value) {
- if (this.eden.size() >= this.size) {
- this.longterm.putAll(this.eden);
- this.eden.clear();
- }
- this.eden.put(key, value);
- }
+ return props.get(ctx, prop);
+ }
- }
+ private final static Method getMethod(Class type, Method m) {
+ if (m == null || Modifier.isPublic(type.getModifiers())) {
+ return m;
+ }
+ Class[] inf = type.getInterfaces();
+ Method mp = null;
+ for (int i = 0; i < inf.length; i++) {
+ try {
+ mp = inf[i].getMethod(m.getName(), (Class[]) m.getParameterTypes());
+ mp = getMethod(mp.getDeclaringClass(), mp);
+ if (mp != null) {
+ return mp;
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ Class sup = type.getSuperclass();
+ if (sup != null) {
+ try {
+ mp = sup.getMethod(m.getName(), (Class[]) m.getParameterTypes());
+ mp = getMethod(mp.getDeclaringClass(), mp);
+ if (mp != null) {
+ return mp;
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ return null;
+ }
+
+ private final static class ConcurrentCache<K,V> {
+
+ private final int size;
+ private final Map<K,V> eden;
+ private final Map<K,V> longterm;
+
+ public ConcurrentCache(int size) {
+ this.size = size;
+ this.eden = new ConcurrentHashMap<K,V>(size);
+ this.longterm = new WeakHashMap<K,V>(size);
+ }
+
+ public V get(K key) {
+ V value = this.eden.get(key);
+ if (value == null) {
+ value = this.longterm.get(key);
+ if (value != null) {
+ this.eden.put(key, value);
+ }
+ }
+ return value;
+ }
+
+ public void put(K key, V value) {
+ if (this.eden.size() >= this.size) {
+ this.longterm.putAll(this.eden);
+ this.eden.clear();
+ }
+ this.eden.put(key, value);
+ }
+
+ }
}
Modified: trunk/java/javax/el/ResourceBundleELResolver.java
===================================================================
--- trunk/java/javax/el/ResourceBundleELResolver.java 2007-12-07 16:46:44 UTC (rev 376)
+++ trunk/java/javax/el/ResourceBundleELResolver.java 2007-12-07 17:39:11 UTC (rev 377)
@@ -27,102 +27,102 @@
public class ResourceBundleELResolver extends ELResolver {
- public ResourceBundleELResolver() {
- super();
- }
+ public ResourceBundleELResolver() {
+ super();
+ }
- public Object getValue(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
+ public Object getValue(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
- if (property != null) {
- try {
- return ((ResourceBundle) base).getObject(property
- .toString());
- } catch (MissingResourceException mre) {
- return "???" + property.toString() + "???";
- }
- }
- }
+ if (property != null) {
+ try {
+ return ((ResourceBundle) base).getObject(property
+ .toString());
+ } catch (MissingResourceException mre) {
+ return "???" + property.toString() + "???";
+ }
+ }
+ }
- return null;
- }
+ return null;
+ }
- public Class<?> getType(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
- }
-
- return null;
- }
+ public Class<?> getType(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ }
+
+ return null;
+ }
- public void setValue(ELContext context, Object base, Object property,
- Object value) throws NullPointerException,
- PropertyNotFoundException, PropertyNotWritableException,
- ELException {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
- throw new PropertyNotWritableException(message(context,
- "resolverNotWriteable", new Object[] { base.getClass()
- .getName() }));
- }
- }
+ public void setValue(ELContext context, Object base, Object property,
+ Object value) throws NullPointerException,
+ PropertyNotFoundException, PropertyNotWritableException,
+ ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ throw new PropertyNotWritableException(message(context,
+ "resolverNotWriteable", new Object[] { base.getClass()
+ .getName() }));
+ }
+ }
- public boolean isReadOnly(ELContext context, Object base, Object property)
- throws NullPointerException, PropertyNotFoundException, ELException {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (base instanceof ResourceBundle) {
- context.setPropertyResolved(true);
- }
-
- return true;
- }
+ public boolean isReadOnly(ELContext context, Object base, Object property)
+ throws NullPointerException, PropertyNotFoundException, ELException {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ if (base instanceof ResourceBundle) {
+ context.setPropertyResolved(true);
+ }
+
+ return true;
+ }
- public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object
base) {
- if (base instanceof ResourceBundle) {
- List<FeatureDescriptor> feats = new ArrayList<FeatureDescriptor>();
- Enumeration e = ((ResourceBundle) base).getKeys();
- FeatureDescriptor feat;
- String key;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- feat = new FeatureDescriptor();
- feat.setDisplayName(key);
- feat.setExpert(false);
- feat.setHidden(false);
- feat.setName(key);
- feat.setPreferred(true);
- feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
- feat.setValue(TYPE, String.class);
- feats.add(feat);
- }
- return feats.iterator();
- }
- return null;
- }
+ public Iterator getFeatureDescriptors(ELContext context, Object base) {
+ if (base instanceof ResourceBundle) {
+ List<FeatureDescriptor> feats = new
ArrayList<FeatureDescriptor>();
+ Enumeration e = ((ResourceBundle) base).getKeys();
+ FeatureDescriptor feat;
+ String key;
+ while (e.hasMoreElements()) {
+ key = (String) e.nextElement();
+ feat = new FeatureDescriptor();
+ feat.setDisplayName(key);
+ feat.setExpert(false);
+ feat.setHidden(false);
+ feat.setName(key);
+ feat.setPreferred(true);
+ feat.setValue(RESOLVABLE_AT_DESIGN_TIME, Boolean.TRUE);
+ feat.setValue(TYPE, String.class);
+ feats.add(feat);
+ }
+ return feats.iterator();
+ }
+ return null;
+ }
- public Class<?> getCommonPropertyType(ELContext context, Object base) {
- if (base instanceof ResourceBundle) {
- return String.class;
- }
- return null;
- }
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ if (base instanceof ResourceBundle) {
+ return String.class;
+ }
+ return null;
+ }
}