[jboss-cvs] JBossAS SVN: r70886 - in projects/jboss-reflect/trunk/src: main/org/jboss/beans/info/spi and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Mar 15 16:39:42 EDT 2008
Author: alesj
Date: 2008-03-15 16:39:41 -0400 (Sat, 15 Mar 2008)
New Revision: 70886
Added:
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AllBeanInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/DefaultPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldBeanInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldFilter.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/GetterAndFieldPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/SetterAndFieldPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanAccessMode.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoCreator.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo2.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo3.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo4.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo5.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo6.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo7.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo8.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFields.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo2.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo3.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo4.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField2.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndSetter2.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField2.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateGetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateMixNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateSetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubGetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubMixNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubSetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SetGetHook.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndField.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndSetter.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoSetterAndField.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateGetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateMixNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateSetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubGetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubMixNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubSetterNestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SuperBeanInfoGetterAndSetter.java
Modified:
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoFactory.java
projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/PropertyInfo.java
projects/jboss-reflect/trunk/src/main/org/jboss/config/plugins/AbstractConfiguration.java
projects/jboss-reflect/trunk/src/main/org/jboss/config/spi/Configuration.java
projects/jboss-reflect/trunk/src/main/org/jboss/reflect/plugins/introspection/ReflectFieldInfoImpl.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoMethods.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/NestedBean.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUtilTestCase.java
Log:
JBREFLECT-22; initial access mode impl.
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -26,6 +26,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.HashSet;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.BeanInfoFactory;
@@ -46,34 +47,35 @@
/**
* BeanInfo.
*
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
public class AbstractBeanInfo extends JBossObject implements BeanInfo
{
/** The class name */
- protected String name;
+ private String name;
/** The class adapter */
protected ClassAdapter classAdapter;
/** The properties */
- protected Set<PropertyInfo> properties;
+ private Set<PropertyInfo> properties;
/** The properties by name */
private transient Map<String, PropertyInfo> propertiesByName = Collections.emptyMap();
/** The constructors */
- protected Set<ConstructorInfo> constructors;
+ private Set<ConstructorInfo> constructors;
/** The methods */
- protected Set<MethodInfo> methods;
+ private Set<MethodInfo> methods;
/** The events */
- protected Set<EventInfo> events;
+ private Set<EventInfo> events;
/** The BeanInfoFactory */
- protected BeanInfoFactory beanInfoFactory;
+ private BeanInfoFactory beanInfoFactory;
/**
* Create a new bean info
@@ -85,10 +87,17 @@
* @param methods the methods
* @param events the events
*/
- public AbstractBeanInfo(BeanInfoFactory beanInfoFactory, ClassAdapter classAdapter, Set<PropertyInfo> properties, Set<ConstructorInfo> constructors,
- Set<MethodInfo> methods, Set<EventInfo> events)
+ public AbstractBeanInfo(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
{
this.beanInfoFactory = beanInfoFactory;
+ if (classAdapter == null)
+ throw new IllegalArgumentException("Null class adapter.");
this.name = classAdapter.getClassInfo().getName();
this.classAdapter = classAdapter;
setProperties(properties);
@@ -109,13 +118,14 @@
public void setProperties(Set<PropertyInfo> properties)
{
- this.properties = properties;
if (properties != null && properties.isEmpty() == false)
{
- propertiesByName = new HashMap<String, PropertyInfo>(properties.size());
+ this.properties = new HashSet<PropertyInfo>(properties.size());
+ this.propertiesByName = new HashMap<String, PropertyInfo>(properties.size());
+
for (PropertyInfo property : properties)
{
- PropertyInfo previous = propertiesByName.put(property.getName(), property);
+ PropertyInfo previous = replaceAndAddProperty(property);
if (previous != null)
{
NestedPropertyInfo nestedPropertyInfo;
@@ -131,11 +141,6 @@
}
nestedPropertyInfo.addPropertyInfo(property);
}
- if (property instanceof AbstractPropertyInfo)
- {
- AbstractPropertyInfo ainfo = (AbstractPropertyInfo) property;
- ainfo.beanInfo = this;
- }
}
}
}
@@ -152,12 +157,65 @@
if (name == null)
throw new IllegalArgumentException("Null name");
- PropertyInfo property = propertiesByName.get(name);
+ PropertyInfo property = findPropertyInfo(name);
if (property == null)
throw new IllegalArgumentException("No such property " + name + " for bean " + getName() + " available " + propertiesByName.keySet());
return property;
}
+ /**
+ * Find property
+ *
+ * @param name the property name
+ * @return the property or null if no such property
+ */
+ protected PropertyInfo findPropertyInfo(String name)
+ {
+ return propertiesByName.get(name);
+ }
+
+ /**
+ * Replace and add property.
+ *
+ * @param property the property to add
+ * @return previous property or null if it doesn't exist
+ */
+ protected PropertyInfo replaceAndAddProperty(PropertyInfo property)
+ {
+ property = replaceProperty(property);
+ return addProperty(property);
+ }
+
+ /**
+ * Add property.
+ *
+ * @param property the property to add
+ * @return previous property or null if it doesn't exist
+ */
+ protected PropertyInfo addProperty(PropertyInfo property)
+ {
+ properties.add(property);
+ PropertyInfo previous = propertiesByName.put(property.getName(), property);
+ if (property instanceof AbstractPropertyInfo)
+ {
+ AbstractPropertyInfo ainfo = (AbstractPropertyInfo) property;
+ ainfo.setBeanInfo(this);
+ }
+ return previous;
+ }
+
+ /**
+ * Do we need to replace property due to access mode.
+ * By default we don't do anything, returning original.
+ *
+ * @param original the original property
+ * @return replaced property or original if no replacement neccessary
+ */
+ protected PropertyInfo replaceProperty(PropertyInfo original)
+ {
+ return original;
+ }
+
public ClassInfo getClassInfo()
{
return classAdapter.getClassInfo();
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractBeanInfoFactory.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -30,6 +30,7 @@
import java.util.Set;
import java.util.WeakHashMap;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.BeanInfoFactory;
import org.jboss.beans.info.spi.EventInfo;
@@ -47,13 +48,14 @@
/**
* A bean info factory.
*
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
public class AbstractBeanInfoFactory implements BeanInfoFactory
{
/** The cache */
- protected Map<ClassLoader, Map<String, BeanInfo>> cache = new WeakHashMap<ClassLoader, Map<String, BeanInfo>>();
+ protected Map<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>> cache = new WeakHashMap<ClassLoader, Map<String, Map<BeanAccessMode, BeanInfo>>>();
protected static boolean isGetter(MethodInfo minfo)
{
@@ -119,17 +121,32 @@
public BeanInfo getBeanInfo(ClassAdapter classAdapter)
{
+ return getBeanInfo(classAdapter, BeanAccessMode.STANDARD);
+ }
+
+ public BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode)
+ {
+ if (classAdapter == null)
+ throw new IllegalArgumentException("Null class adapter.");
+ if (accessMode == null)
+ throw new IllegalArgumentException("Null bean access mode.");
+
synchronized (cache)
{
ClassLoader cl = classAdapter.getClassLoader();
ClassInfo classInfo = classAdapter.getClassInfo();
String className = classInfo.getName();
- Map<String, BeanInfo> map = cache.get(cl);
+ Map<String, Map<BeanAccessMode, BeanInfo>> map = cache.get(cl);
+ Map<BeanAccessMode, BeanInfo> modeMap = null;
if (map != null)
{
- BeanInfo info = map.get(className);
- if (info != null)
- return info;
+ modeMap = map.get(className);
+ if (modeMap != null)
+ {
+ BeanInfo info = modeMap.get(accessMode);
+ if (info != null)
+ return info;
+ }
}
Set<ConstructorInfo> constructors = getConstructors(classInfo);
@@ -140,31 +157,43 @@
else
properties = getBeanProperties(methods);
Set<EventInfo> events = getEvents(classInfo);
-
- BeanInfo result = createBeanInfo(classAdapter, properties, constructors, methods, events);
+
+ BeanInfo result = createBeanInfo(classAdapter, accessMode, properties, constructors, methods, events);
if (map == null)
{
- map = new WeakValueHashMap<String, BeanInfo>();
+ map = new WeakValueHashMap<String, Map<BeanAccessMode, BeanInfo>>();
cache.put(cl, map);
}
- map.put(className, result);
+ if (modeMap == null)
+ {
+ modeMap = new WeakValueHashMap<BeanAccessMode, BeanInfo>();
+ map.put(className, modeMap);
+ }
+ modeMap.put(accessMode, result);
return result;
}
}
-
+
/**
* Create the bean info
*
* @param classAdapter the class adapter
+ * @param accessMode the access mode
* @param properties the properties
* @param constructors the constructors
* @param methods the methods
* @param events the events
* @return the bean info
*/
- protected BeanInfo createBeanInfo(ClassAdapter classAdapter, Set<PropertyInfo> properties, Set<ConstructorInfo> constructors, Set<MethodInfo> methods, Set<EventInfo> events)
+ protected BeanInfo createBeanInfo(
+ ClassAdapter classAdapter,
+ BeanAccessMode accessMode,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
{
- return new AbstractBeanInfo(this, classAdapter, properties, constructors, methods, events);
+ return accessMode.create(this, classAdapter, properties, constructors, methods, events);
}
/**
@@ -292,7 +321,7 @@
annotations = merged.toArray(new AnnotationValue[merged.size()]);
}
TypeInfo type = getPropertyType(getter, setter);
- properties.add(new AbstractPropertyInfo(lowerName, name, type, getter, setter, annotations));
+ properties.add(new DefaultPropertyInfo(lowerName, name, type, getter, setter, annotations));
}
}
if (setters.isEmpty() == false)
@@ -307,7 +336,7 @@
TypeInfo pinfo = setter.getParameterTypes()[0];
String lowerName = getLowerPropertyName(name);
AnnotationValue[] annotations = setter.getAnnotations();
- properties.add(new AbstractPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
+ properties.add(new DefaultPropertyInfo(lowerName, name, pinfo, null, setter, annotations));
}
}
}
@@ -349,7 +378,7 @@
if (parameters.length == 0 && PrimitiveInfo.VOID.equals(returnType) == false)
{
String name = method.getName();
- properties.add(new AbstractPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
+ properties.add(new DefaultPropertyInfo(name, name, returnType, method, null, method.getAnnotations()));
}
}
}
@@ -358,7 +387,7 @@
/**
* Get the events
- *
+ *
* @param classInfo the class info
* @return the events
*/
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AbstractPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -27,46 +27,40 @@
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.reflect.plugins.AnnotationHolder;
import org.jboss.reflect.spi.AnnotationValue;
-import org.jboss.reflect.spi.MethodInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.util.JBossStringBuilder;
/**
* Property info.
*
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
-public class AbstractPropertyInfo extends AnnotationHolder
+public abstract class AbstractPropertyInfo extends AnnotationHolder
implements PropertyInfo, Serializable
{
/** The serialVersionUID */
private static final long serialVersionUID = 2;
/** The bean info */
- protected transient BeanInfo beanInfo;
+ private transient BeanInfo beanInfo;
/** The property name */
- protected String name;
+ private String name;
/** The upper property name */
- protected String upperName;
+ private String upperName;
/** The type */
- protected TypeInfo type;
-
- /** The getter */
- protected MethodInfo getter;
-
- /** The setter */
- protected MethodInfo setter;
+ private TypeInfo type;
/**
* Create a new property info
*/
public AbstractPropertyInfo()
{
- this(null, null, null, null, null);
+ this(null, null, null);
}
/**
@@ -76,7 +70,7 @@
*/
public AbstractPropertyInfo(String name)
{
- this(name, name, null, null, null);
+ this(name, name, null);
}
/**
@@ -85,16 +79,10 @@
* @param name the name
* @param upperName the upper case version of the name
* @param type the type
- * @param getter the getter
- * @param setter the setter
*/
- public AbstractPropertyInfo(String name, String upperName, TypeInfo type, MethodInfo getter, MethodInfo setter)
+ public AbstractPropertyInfo(String name, String upperName, TypeInfo type)
{
- this.name = name;
- this.upperName = upperName;
- this.type = type;
- this.getter = getter;
- this.setter = setter;
+ init(name, upperName, type);
}
/**
@@ -103,25 +91,38 @@
* @param name the name
* @param upperName the upper case version of the name
* @param type the type
- * @param getter the getter
- * @param setter the setter
* @param annotations the annotations
*/
- public AbstractPropertyInfo(String name, String upperName, TypeInfo type, MethodInfo getter, MethodInfo setter, AnnotationValue[] annotations)
+ public AbstractPropertyInfo(String name, String upperName, TypeInfo type, AnnotationValue[] annotations)
{
super(annotations);
+ init(name, upperName, type);
+ }
+
+ /**
+ * Initialize fields.
+ *
+ * @param name the name
+ * @param upperName the upper name
+ * @param type the type
+ */
+ protected void init(String name, String upperName, TypeInfo type)
+ {
this.name = name;
this.upperName = upperName;
this.type = type;
- this.getter = getter;
- this.setter = setter;
}
-
+
public BeanInfo getBeanInfo()
{
return beanInfo;
}
-
+
+ void setBeanInfo(BeanInfo beanInfo)
+ {
+ this.beanInfo = beanInfo;
+ }
+
public String getName()
{
return name;
@@ -141,47 +142,7 @@
{
this.type = type;
}
-
- public MethodInfo getGetter()
- {
- return getter;
- }
- public void setGetter(MethodInfo getter)
- {
- this.getter = getter;
- }
-
- public MethodInfo getSetter()
- {
- return setter;
- }
-
- public void setSetter(MethodInfo setter)
- {
- this.setter = setter;
- }
-
- public Object get(Object bean) throws Throwable
- {
- if (bean == null)
- throw new IllegalArgumentException("Null bean");
- if (getter == null)
- throw new IllegalArgumentException("Property is not readable: " + getName() + " for " + beanInfo.getName());
-
- return getter.invoke(bean, null);
- }
-
- public void set(Object bean, Object value) throws Throwable
- {
- if (bean == null)
- throw new IllegalArgumentException("Null bean");
- if (setter == null)
- throw new IllegalArgumentException("Property is not writable: " + getName() + " for " + beanInfo.getName());
-
- setter.invoke(bean, new Object[] { value });
- }
-
@Override
public boolean equals(Object object)
{
@@ -191,10 +152,6 @@
AbstractPropertyInfo other = (AbstractPropertyInfo) object;
if (notEqual(name, other.name))
return false;
- else if (notEqual(getter, other.getter))
- return false;
- else if (notEqual(setter, other.setter))
- return false;
return true;
}
@@ -202,8 +159,6 @@
public void toString(JBossStringBuilder buffer)
{
buffer.append("name=").append(name);
- buffer.append(" getter=").append(getter);
- buffer.append(" setter=").append(setter);
}
@Override
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AllBeanInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AllBeanInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/AllBeanInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.EventInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * All bean info.
+ * @see org.jboss.beans.info.spi.BeanAccessMode#ALL
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AllBeanInfo extends FieldBeanInfo
+{
+ public AllBeanInfo(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ super(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+
+ protected FieldFilter getFieldFilter()
+ {
+ return FieldFilter.ALL;
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/DefaultPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/DefaultPropertyInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/DefaultPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,170 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import org.jboss.reflect.spi.AnnotationValue;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Default property info.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DefaultPropertyInfo extends AbstractPropertyInfo
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1;
+
+ /** The getter */
+ private MethodInfo getter;
+
+ /** The setter */
+ private MethodInfo setter;
+
+ /**
+ * Create a new property info
+ */
+ public DefaultPropertyInfo()
+ {
+ this(null, null, null, null, null);
+ }
+
+ /**
+ * Create a new property info
+ *
+ * @param name the name
+ */
+ public DefaultPropertyInfo(String name)
+ {
+ this(name, name, null, null, null);
+ }
+
+ /**
+ * Create a new property info
+ *
+ * @param name the name
+ * @param upperName the upper case version of the name
+ * @param type the type
+ * @param getter the getter
+ * @param setter the setter
+ */
+ public DefaultPropertyInfo(String name, String upperName, TypeInfo type, MethodInfo getter, MethodInfo setter)
+ {
+ super(name, upperName, type);
+ this.getter = getter;
+ this.setter = setter;
+ }
+
+ /**
+ * Create a new property info
+ *
+ * @param name the name
+ * @param upperName the upper case version of the name
+ * @param type the type
+ * @param getter the getter
+ * @param setter the setter
+ * @param annotations the annotations
+ */
+ public DefaultPropertyInfo(String name, String upperName, TypeInfo type, MethodInfo getter, MethodInfo setter, AnnotationValue[] annotations)
+ {
+ super(name, upperName, type, annotations);
+ this.getter = getter;
+ this.setter = setter;
+ }
+
+ public MethodInfo getGetter()
+ {
+ return getter;
+ }
+
+ public void setGetter(MethodInfo getter)
+ {
+ this.getter = getter;
+ }
+
+ public MethodInfo getSetter()
+ {
+ return setter;
+ }
+
+ public void setSetter(MethodInfo setter)
+ {
+ this.setter = setter;
+ }
+
+ public boolean isReadable()
+ {
+ return getGetter() != null;
+ }
+
+ public boolean isWritable()
+ {
+ return getSetter() != null;
+ }
+
+ public Object get(Object bean) throws Throwable
+ {
+ if (bean == null)
+ throw new IllegalArgumentException("Null bean");
+ if (getter == null)
+ throw new IllegalArgumentException("Property is not readable: " + getName() + " for " + getBeanInfo().getName());
+
+ return getter.invoke(bean, null);
+ }
+
+ public void set(Object bean, Object value) throws Throwable
+ {
+ if (bean == null)
+ throw new IllegalArgumentException("Null bean");
+ if (setter == null)
+ throw new IllegalArgumentException("Property is not writable: " + getName() + " for " + getBeanInfo().getName());
+
+ setter.invoke(bean, new Object[] { value });
+ }
+
+ @Override
+ public boolean equals(Object object)
+ {
+ if (super.equals(object) == false)
+ return false;
+
+ if (object == null || object instanceof DefaultPropertyInfo == false)
+ return false;
+
+ DefaultPropertyInfo other = (DefaultPropertyInfo) object;
+ if (notEqual(getter, other.getter))
+ return false;
+ else if (notEqual(setter, other.setter))
+ return false;
+ return true;
+ }
+
+ @Override
+ public void toString(JBossStringBuilder buffer)
+ {
+ super.toString(buffer);
+ buffer.append(" getter=").append(getter);
+ buffer.append(" setter=").append(setter);
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldBeanInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldBeanInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldBeanInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+
+import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.EventInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Field bean info.
+ * @see org.jboss.beans.info.spi.BeanAccessMode#FIELDS
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FieldBeanInfo extends AbstractBeanInfo
+{
+ /** The fields */
+ protected Map<String, FieldInfo> fieldsByName;
+
+ public FieldBeanInfo(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ super(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+
+ public void setProperties(Set<PropertyInfo> properties)
+ {
+ setFields(getFields(classAdapter.getClassInfo(), getFieldFilter()));
+ super.setProperties(properties);
+ for(FieldInfo field : fieldsByName.values())
+ {
+ PropertyInfo previous = findPropertyInfo(field.getName());
+ if (previous == null)
+ addProperty(new FieldPropertyInfo(field));
+ }
+ }
+
+ protected PropertyInfo replaceProperty(PropertyInfo original)
+ {
+ String name = original.getName();
+
+ if (original.isReadable() == false)
+ {
+ FieldInfo field = getField(name);
+ if (field != null) // TODO - match type?
+ return new SetterAndFieldPropertyInfo(original, field);
+ }
+ else if (original.isWritable() == false)
+ {
+ FieldInfo field = getField(name);
+ if (field != null) // TODO - match type?
+ return new GetterAndFieldPropertyInfo(original, field);
+ }
+ return original;
+ }
+
+ /**
+ * Set fields
+ *
+ * @param fields the fields
+ */
+ protected void setFields(Set<FieldInfo> fields)
+ {
+ if (fields != null && fields.isEmpty() == false)
+ {
+ fieldsByName = new HashMap<String, FieldInfo>(fields.size());
+ for (FieldInfo field : fields)
+ {
+ fieldsByName.put(field.getName(), field);
+ }
+ }
+ else
+ {
+ fieldsByName = Collections.emptyMap();
+ }
+ }
+
+ /**
+ * Get a property
+ *
+ * @param name the property name
+ * @return the property
+ * @throws IllegalArgumentException if there is no such property
+ */
+ protected FieldInfo getField(String name)
+ {
+ return fieldsByName.get(name);
+ }
+
+ /**
+ * Get the fields
+ *
+ * @param classInfo the class info
+ * @param filter the field filter
+ * @return the fields
+ */
+ protected static Set<FieldInfo> getFields(ClassInfo classInfo, FieldFilter filter)
+ {
+ HashSet<FieldInfo> fields = new HashSet<FieldInfo>();
+ while (classInfo != null)
+ {
+ FieldInfo[] finfos = classInfo.getDeclaredFields();
+ if (finfos != null && finfos.length > 0)
+ {
+ for (int i = 0; i < finfos.length; ++i)
+ if (filter.useField(finfos[i]))
+ fields.add(finfos[i]);
+ }
+ classInfo = classInfo.getSuperclass();
+ }
+ return fields;
+ }
+
+ /**
+ * Get the field filter.
+ *
+ * @return the field filter
+ */
+ protected FieldFilter getFieldFilter()
+ {
+ return FieldFilter.PUBLIC;
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldFilter.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldFilter.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldFilter.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import org.jboss.reflect.spi.FieldInfo;
+
+/**
+ * Simple field filter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+interface FieldFilter
+{
+ static final FieldFilter PUBLIC = new IsPublicFieldFilter();
+ static final FieldFilter ALL = new AllFieldFilter();
+
+ /**
+ * Should we use the field.
+ *
+ * @param field the field info
+ * @return true if field should be used
+ */
+ boolean useField(FieldInfo field);
+
+ /**
+ * All field filter.
+ */
+ class AllFieldFilter implements FieldFilter
+ {
+ public boolean useField(FieldInfo field)
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Just public field filter.
+ */
+ class IsPublicFieldFilter implements FieldFilter
+ {
+ public boolean useField(FieldInfo field)
+ {
+ return field.isPublic();
+ }
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldPropertyInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/FieldPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,111 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Field property info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class FieldPropertyInfo extends AbstractPropertyInfo
+{
+ private static final long serialVersionUID = 1L;
+
+ /** The field info */
+ private FieldInfo field;
+
+ public FieldPropertyInfo(FieldInfo field)
+ {
+ if (field == null)
+ throw new IllegalArgumentException("Null field");
+
+ this.field = field;
+ init(field.getName(), field.getName(), field.getType());
+ setupAnnotations(field.getAnnotations());
+ }
+
+ public MethodInfo getGetter()
+ {
+ return null;
+ }
+
+ public void setGetter(MethodInfo getter)
+ {
+ throw new UnsupportedOperationException("Cannot set getter on field property info.");
+ }
+
+ public MethodInfo getSetter()
+ {
+ return null;
+ }
+
+ public void setSetter(MethodInfo setter)
+ {
+ throw new UnsupportedOperationException("Cannot set getter on field property info.");
+ }
+
+ public boolean isReadable()
+ {
+ return true;
+ }
+
+ public boolean isWritable()
+ {
+ return true;
+ }
+
+ public Object get(Object bean) throws Throwable
+ {
+ if (bean == null)
+ throw new IllegalArgumentException("Null bean");
+
+ return field.get(bean);
+ }
+
+ public void set(Object bean, Object value) throws Throwable
+ {
+ if (bean == null)
+ throw new IllegalArgumentException("Null bean");
+
+ field.set(bean, value);
+ }
+
+ @Override
+ public boolean equals(Object object)
+ {
+ if (object == null || object instanceof FieldPropertyInfo == false)
+ return false;
+
+ FieldPropertyInfo other = (FieldPropertyInfo) object;
+ return field.equals(other.field);
+ }
+
+ @Override
+ public void toString(JBossStringBuilder buffer)
+ {
+ buffer.append(" field=").append(field);
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/GetterAndFieldPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/GetterAndFieldPropertyInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/GetterAndFieldPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Combined getter and field property info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class GetterAndFieldPropertyInfo extends FieldPropertyInfo
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Previous property info */
+ private PropertyInfo previous;
+
+ public GetterAndFieldPropertyInfo(PropertyInfo previous, FieldInfo field)
+ {
+ // TODO - what to do with annotations, merge?
+ super(field);
+
+ if (previous == null)
+ throw new IllegalArgumentException("Null previous");
+ this.previous = previous;
+ }
+
+ public Object get(Object bean) throws Throwable
+ {
+ return previous.get(bean);
+ }
+
+ public MethodInfo getGetter()
+ {
+ return previous.getGetter();
+ }
+
+ public void setGetter(MethodInfo getter)
+ {
+ previous.setGetter(getter);
+ }
+}
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/NestedPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -176,6 +176,16 @@
throw new NotImplementedException("setSetter");
}
+ public boolean isReadable()
+ {
+ return false;
+ }
+
+ public boolean isWritable()
+ {
+ return false;
+ }
+
public AnnotationValue[] getAnnotations()
{
throw new IllegalArgumentException("Unable to determine right PropertyInfo on " + beanInfo + " by name: " + name);
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/SetterAndFieldPropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/SetterAndFieldPropertyInfo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/plugins/SetterAndFieldPropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,64 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.plugins;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Combined setter and field property info.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SetterAndFieldPropertyInfo extends FieldPropertyInfo
+{
+ private static final long serialVersionUID = 1L;
+
+ /** Previous property info */
+ private PropertyInfo previous;
+
+ public SetterAndFieldPropertyInfo(PropertyInfo previous, FieldInfo field)
+ {
+ // TODO - what to do with annotations, merge?
+ super(field);
+
+ if (previous == null)
+ throw new IllegalArgumentException("Null previous");
+ this.previous = previous;
+ }
+
+ public void set(Object bean, Object value) throws Throwable
+ {
+ previous.set(bean, value);
+ }
+
+ public MethodInfo getSetter()
+ {
+ return previous.getSetter();
+ }
+
+ public void setSetter(MethodInfo setter)
+ {
+ previous.setSetter(setter);
+ }
+}
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanAccessMode.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanAccessMode.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanAccessMode.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.spi;
+
+import java.util.Set;
+
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Bean access mode.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public enum BeanAccessMode
+{
+ STANDARD(BeanInfoCreator.STANDARD), // Getters and Setters
+ FIELDS(BeanInfoCreator.FIELDS), // Getters/Setters and fields without getters and setters
+ ALL(BeanInfoCreator.ALL); // As above but with non public fields included
+
+ /** The bean info creator */
+ private BeanInfoCreator creator;
+
+ BeanAccessMode(BeanInfoCreator creator)
+ {
+ this.creator = creator;
+ }
+
+ /**
+ * Create the bean info
+ *
+ * @param beanInfoFactory the bean info factory
+ * @param classAdapter the class adapter
+ * @param properties the properties
+ * @param constructors the constructors
+ * @param methods the methods
+ * @param events the events
+ * @return the bean info
+ */
+ public BeanInfo create(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ return creator.create(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+}
\ No newline at end of file
Added: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoCreator.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoCreator.java (rev 0)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoCreator.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,104 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.beans.info.spi;
+
+import java.util.Set;
+
+import org.jboss.beans.info.plugins.AbstractBeanInfo;
+import org.jboss.beans.info.plugins.AllBeanInfo;
+import org.jboss.beans.info.plugins.FieldBeanInfo;
+import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Create the bean info from bean access mode.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+interface BeanInfoCreator
+{
+ static final BeanInfoCreator STANDARD = new StandardBeanInfoCreator();
+ static final BeanInfoCreator FIELDS = new FieldBeanInfoCreator();
+ static final BeanInfoCreator ALL = new AllBeanInfoCreator();
+
+ /**
+ * Create the bean info
+ *
+ * @param beanInfoFactory the bean info factory
+ * @param classAdapter the class adapter
+ * @param properties the properties
+ * @param constructors the constructors
+ * @param methods the methods
+ * @param events the events
+ * @return the bean info
+ */
+ BeanInfo create(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events);
+
+ class StandardBeanInfoCreator implements BeanInfoCreator
+ {
+ public BeanInfo create(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ return new AbstractBeanInfo(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+ }
+
+ class FieldBeanInfoCreator implements BeanInfoCreator
+ {
+ public BeanInfo create(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ return new FieldBeanInfo(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+ }
+
+ class AllBeanInfoCreator implements BeanInfoCreator
+ {
+ public BeanInfo create(
+ BeanInfoFactory beanInfoFactory,
+ ClassAdapter classAdapter,
+ Set<PropertyInfo> properties,
+ Set<ConstructorInfo> constructors,
+ Set<MethodInfo> methods,
+ Set<EventInfo> events)
+ {
+ return new AllBeanInfo(beanInfoFactory, classAdapter, properties, constructors, methods, events);
+ }
+ }
+}
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoFactory.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoFactory.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/BeanInfoFactory.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -26,6 +26,7 @@
/**
* BeanInfo Factory.
*
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision$
*/
@@ -38,4 +39,13 @@
* @return the bean information
*/
BeanInfo getBeanInfo(ClassAdapter classAdapter);
+
+ /**
+ * Retrieve the bean information
+ *
+ * @param classAdapter the classAdapter
+ * @param accessMode the access mode
+ * @return the bean information
+ */
+ BeanInfo getBeanInfo(ClassAdapter classAdapter, BeanAccessMode accessMode);
}
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/PropertyInfo.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/PropertyInfo.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/beans/info/spi/PropertyInfo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -88,8 +88,22 @@
* @param setter the setter
*/
void setSetter(MethodInfo setter);
-
+
/**
+ * Is property readable.
+ *
+ * @return
+ */
+ boolean isReadable();
+
+ /**
+ * Is property writable.
+ *
+ * @return
+ */
+ boolean isWritable();
+
+ /**
* Get the property value
*
* @param bean the bean
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/config/plugins/AbstractConfiguration.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/config/plugins/AbstractConfiguration.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/config/plugins/AbstractConfiguration.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -25,6 +25,7 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.classadapter.spi.ClassAdapter;
import org.jboss.classadapter.spi.ClassAdapterFactory;
import org.jboss.config.spi.Configuration;
@@ -80,6 +81,24 @@
return getBeanInfoFactory().getBeanInfo(classAdapter);
}
+ public BeanInfo getBeanInfo(String className, ClassLoader cl, BeanAccessMode accessMode) throws ClassNotFoundException
+ {
+ ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl);
+ return getBeanInfoFactory().getBeanInfo(classAdapter, accessMode);
+ }
+
+ public BeanInfo getBeanInfo(Class<?> clazz, BeanAccessMode accessMode)
+ {
+ ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(clazz);
+ return getBeanInfoFactory().getBeanInfo(classAdapter, accessMode);
+ }
+
+ public BeanInfo getBeanInfo(TypeInfo typeInfo, BeanAccessMode accessMode)
+ {
+ ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(typeInfo);
+ return getBeanInfoFactory().getBeanInfo(classAdapter, accessMode);
+ }
+
public ClassInfo getClassInfo(String className, ClassLoader cl) throws ClassNotFoundException
{
ClassAdapter classAdapter = getClassAdapterFactory().getClassAdapter(className, cl);
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/config/spi/Configuration.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/config/spi/Configuration.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/config/spi/Configuration.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -25,6 +25,7 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.BeanInfoFactory;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.classadapter.spi.ClassAdapterFactory;
import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
import org.jboss.reflect.spi.ClassInfo;
@@ -68,6 +69,35 @@
BeanInfo getBeanInfo(TypeInfo type);
/**
+ * Get the bean info
+ *
+ * @param className the class name
+ * @param cl the classloader
+ * @param accessMode the bean access mode
+ * @return the bean info
+ * @throws ClassNotFoundException when the class could not be loaded
+ */
+ BeanInfo getBeanInfo(String className, ClassLoader cl, BeanAccessMode accessMode) throws ClassNotFoundException;
+
+ /**
+ * Get the bean info
+ *
+ * @param clazz the class
+ * @param accessMode the bean access mode
+ * @return the bean info
+ */
+ BeanInfo getBeanInfo(Class<?> clazz, BeanAccessMode accessMode);
+
+ /**
+ * Get the bean info
+ *
+ * @param type the type info
+ * @param accessMode the bean access mode
+ * @return the bean info
+ */
+ BeanInfo getBeanInfo(TypeInfo type, BeanAccessMode accessMode);
+
+ /**
* Get the class info for a class
*
* @param className the class name
Modified: projects/jboss-reflect/trunk/src/main/org/jboss/reflect/plugins/introspection/ReflectFieldInfoImpl.java
===================================================================
--- projects/jboss-reflect/trunk/src/main/org/jboss/reflect/plugins/introspection/ReflectFieldInfoImpl.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/main/org/jboss/reflect/plugins/introspection/ReflectFieldInfoImpl.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.lang.reflect.Field;
+import java.lang.reflect.ReflectPermission;
+import java.security.Permission;
import org.jboss.reflect.plugins.FieldInfoImpl;
import org.jboss.reflect.spi.AnnotationValue;
@@ -33,6 +35,7 @@
/**
* A field info
*
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
*/
@@ -41,6 +44,9 @@
/** The serialVersionUID */
private static final long serialVersionUID = 2;
+ /** The permission */
+ private static Permission accessCheck = new ReflectPermission("suppressAccessChecks");
+
/** The field */
protected transient Field field;
@@ -53,7 +59,7 @@
/**
* Create a new FieldInfo.
- *
+ *
* @param annotations the annotations
* @param name the name
* @param type the field type
@@ -67,17 +73,19 @@
/**
* Set the field
- *
+ *
* @param field the field
*/
public void setField(Field field)
{
this.field = field;
+ if (isPublic() == false && field != null)
+ field.setAccessible(true);
}
/**
* Get the field
- *
+ *
* @return the field
*/
public Field getField()
@@ -85,16 +93,31 @@
return field;
}
+ /**
+ * Check access permission.
+ */
+ protected void accessCheck()
+ {
+ if (isPublic() == false)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(accessCheck);
+ }
+ }
+
public Object get(Object target) throws Throwable
{
+ accessCheck();
return ReflectionUtils.getField(field, target);
}
public Object set(Object target, Object value) throws Throwable
{
+ accessCheck();
return ReflectionUtils.setField(field, target, value);
}
-
+
/**
* Read the object, handling field read.
*
@@ -107,6 +130,6 @@
throws IOException, ClassNotFoundException, NoSuchFieldException
{
oistream.defaultReadObject();
- field = ReflectionUtils.findExactField(getDeclaringClass().getType(), name);
+ setField(ReflectionUtils.findExactField(getDeclaringClass().getType(), name));
}
}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo extends BeanInfoFoo
+{
+ public String bar;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo2.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo2.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo2 extends BeanInfoFoo
+{
+ public String getBar() {return null;}
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo3.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo3.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo3.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo3 extends BeanInfoFoo2
+{
+ public String bar;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo4.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo4.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo4.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo4 extends BeanInfoFoo2
+{
+ public String getBar() {return null;}
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo5.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo5.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo5.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo5 extends BeanInfoFoo2
+{
+ protected String bar;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo6.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo6.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo6.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo6 extends BeanInfoFoo3
+{
+ protected String bar;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo7.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo7.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo7.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo7 extends BeanInfoFoo4
+{
+ protected String bar;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo8.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo8.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoExtendsFoo8.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoExtendsFoo8 extends BeanInfoFoo4
+{
+ protected String bar;
+ protected int foo;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFields.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFields.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFields.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+import java.util.Date;
+
+/**
+ * BeanInfoFields
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoFields
+{
+ private String stringPrivate;
+ private Date datePrivate;
+ private long longPrivate;
+ protected String stringProt;
+ protected Date dateProt;
+ protected long longProt;
+ public String stringPublic;
+ public Date datePublic;
+ public long longPublic;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoFoo
+{
+ public int foo;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo2.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo2.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoFoo2
+{
+ protected int foo;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo3.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo3.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo3.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoFoo3
+{
+ public void setFoo(int foo){}
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo4.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo4.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoFoo4.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfo foo | bar.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoFoo4
+{
+ protected void setFoo(int foo){}
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoGetterAndField.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoGetterAndField
+{
+ public int something;
+
+ public int getSomething()
+ {
+ return 0;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField2.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndField2.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoGetterAndField.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoGetterAndField2 extends SuperBeanInfoGetterAndSetter
+{
+ public int getSomething()
+ {
+ return 0;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndSetter2.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndSetter2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoGetterAndSetter2.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoGetterAndSetter2.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoGetterAndSetter2 extends SuperBeanInfoGetterAndSetter
+{
+ public int getSomething()
+ {
+ return 0;
+ }
+
+ public void setSomething(int x)
+ {
+ }
+}
Modified: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoMethods.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoMethods.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoMethods.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -57,10 +57,10 @@
public void voidMethodintStringPublic(int p1, String p2) {}
public long longMethodintStringPublic(int p1, String p2) { return 0; }
public long longMethodintStringThrowsPublic(int p1, String p2) throws IllegalArgumentException, IllegalStateException { return 0; }
- public long a() { return 0; };
- public long ab() { return 0; };
- public boolean is() { return false; };
- public long get() { return 0; };
+ public long a() { return 0; }
+ public long ab() { return 0; }
+ public boolean is() { return false; }
+ public long get() { return 0; }
public void x(long x) {}
public void xy(long xy) {}
public void set(long xy) {}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoSetterAndField.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoSetterAndField
+{
+ public int something;
+
+ public void setSomething(int x)
+ {
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField2.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField2.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/BeanInfoSetterAndField2.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * BeanInfoGetterAndField.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInfoSetterAndField2 extends SuperBeanInfoGetterAndSetter
+{
+ public void setSomething(int x)
+ {
+ }
+}
Modified: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/NestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/NestedBean.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/NestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -24,7 +24,7 @@
/**
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
-public class NestedBean
+public class NestedBean implements SetGetHook<NestedBean>
{
private NestedBean bean;
private String string;
@@ -33,18 +33,28 @@
{
}
- public NestedBean(NestedBean bean)
+ public NestedBean getBean()
{
- this.bean = bean;
+ return bean;
}
- public NestedBean getNestedBean()
+ public void doSetHook(NestedBean child)
{
+ bean = child;
+ }
+
+ public NestedBean doGetHook()
+ {
return bean;
}
- public void setNestedBean(NestedBean bean)
+ public boolean valid()
{
+ return bean != null;
+ }
+
+ public void setBean(NestedBean bean)
+ {
this.bean = bean;
}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateGetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateGetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateGetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PrivateGetterNestedBean<T extends PrivateGetterNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+ private boolean usedGetter;
+
+ public void doSetHook(T child)
+ {
+ bean = child;
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return isUsedGetter() || bean != null;
+ }
+
+ public T getBean()
+ {
+ usedGetter = true;
+ return bean;
+ }
+
+ public boolean isUsedGetter()
+ {
+ return usedGetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateMixNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateMixNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateMixNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PrivateMixNestedBean<T extends PrivateMixNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+ private boolean usedSetterOrGetter;
+
+ public void doSetHook(T child)
+ {
+ setBean(child);
+ }
+
+ public T doGetHook()
+ {
+ return getBean();
+ }
+
+ public boolean valid()
+ {
+ return bean != null;
+ }
+
+ public T getBean()
+ {
+ usedSetterOrGetter = true;
+ return bean;
+ }
+
+ public void setBean(T bean)
+ {
+ usedSetterOrGetter = true;
+ this.bean = bean;
+ }
+
+ public boolean isUsedSetterOrGetter()
+ {
+ return usedSetterOrGetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PrivateNestedBean<T extends PrivateNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+
+ public void doSetHook(T child)
+ {
+ xyz(child);
+ }
+
+ public T doGetHook()
+ {
+ return xyz();
+ }
+
+ public boolean valid()
+ {
+ return bean != null;
+ }
+
+ public void xyz(T bean)
+ {
+ this.bean = bean;
+ }
+
+ public T xyz()
+ {
+ return bean;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateSetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateSetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PrivateSetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PrivateSetterNestedBean<T extends PrivateSetterNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+ private boolean usedSetter;
+
+ public void doSetHook(T child)
+ {
+ setBean(child);
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return isUsedSetter();
+ }
+
+ public void setBean(T bean)
+ {
+ usedSetter = true;
+ this.bean = bean;
+ }
+
+ public boolean isUsedSetter()
+ {
+ return usedSetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubGetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubGetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubGetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PubGetterNestedBean<T extends PubGetterNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+ private boolean usedGetter;
+
+ public PubGetterNestedBean getBean()
+ {
+ usedGetter = true;
+ return bean;
+ }
+
+ public void doSetHook(T child)
+ {
+ bean = child;
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return isUsedGetter();
+ }
+
+ public boolean isUsedGetter()
+ {
+ return usedGetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubMixNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubMixNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubMixNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PubMixNestedBean<T extends PubMixNestedBean> implements SetGetHook<T>
+{
+ public T bean;
+ private boolean usedSetterOrGetter;
+
+ public void doSetHook(T child)
+ {
+ bean = child;
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return isUsedSetterOrGetter();
+ }
+
+ public PubMixNestedBean getBean()
+ {
+ usedSetterOrGetter = true;
+ return bean;
+ }
+
+ public void setBean(T bean)
+ {
+ usedSetterOrGetter = true;
+ this.bean = bean;
+ }
+
+ public boolean isUsedSetterOrGetter()
+ {
+ return usedSetterOrGetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PubNestedBean<T extends PubNestedBean> implements SetGetHook<T>
+{
+ public T bean;
+
+ public void doSetHook(T child)
+ {
+ bean = child;
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return bean != null;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubSetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubSetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/PubSetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PubSetterNestedBean<T extends PubSetterNestedBean> implements SetGetHook<T>
+{
+ private T bean;
+ private boolean usedSetter;
+
+ public void doSetHook(T child)
+ {
+ bean = child;
+ }
+
+ public T doGetHook()
+ {
+ return bean;
+ }
+
+ public boolean valid()
+ {
+ return isUsedSetter();
+ }
+
+ public void setBean(T bean)
+ {
+ usedSetter = true;
+ this.bean = bean;
+ }
+
+ public boolean isUsedSetter()
+ {
+ return usedSetter;
+ }
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SetGetHook.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SetGetHook.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SetGetHook.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @param <T> exact type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface SetGetHook<T>
+{
+ void doSetHook(T child);
+ T doGetHook();
+ boolean valid();
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndField.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndField.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndField.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * SubBeanInfoGetterAndSetter.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubBeanInfoGetterAndField extends BeanInfoGetterOnly
+{
+ public int something;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndSetter.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndSetter.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoGetterAndSetter.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * SubBeanInfoGetterAndSetter.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubBeanInfoGetterAndSetter extends BeanInfoGetterAndSetter
+{
+ public int something;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoSetterAndField.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoSetterAndField.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubBeanInfoSetterAndField.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * SubBeanInfoGetterAndSetter.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubBeanInfoSetterAndField extends BeanInfoSetterOnly
+{
+ public int something;
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateGetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateGetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateGetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPrivateGetterNestedBean extends PrivateGetterNestedBean<SubPrivateGetterNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateMixNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateMixNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateMixNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPrivateMixNestedBean extends PrivateMixNestedBean<SubPrivateMixNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPrivateNestedBean extends PrivateNestedBean<SubPrivateNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateSetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateSetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPrivateSetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPrivateSetterNestedBean extends PrivateSetterNestedBean<SubPrivateSetterNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubGetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubGetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubGetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPubGetterNestedBean extends PubGetterNestedBean<SubPubGetterNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubMixNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubMixNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubMixNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPubMixNestedBean extends PubMixNestedBean<SubPubMixNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPubNestedBean extends PubNestedBean<SubPubNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubSetterNestedBean.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubSetterNestedBean.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SubPubSetterNestedBean.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,29 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SubPubSetterNestedBean extends PubSetterNestedBean<SubPubSetterNestedBean>
+{
+}
Added: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SuperBeanInfoGetterAndSetter.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SuperBeanInfoGetterAndSetter.java (rev 0)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/support/SuperBeanInfoGetterAndSetter.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.beaninfo.support;
+
+/**
+ * SuperBeanInfoGetterAndSetter.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SuperBeanInfoGetterAndSetter
+{
+ public int something;
+}
Modified: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/AbstractBeanInfoTest.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -32,7 +32,11 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.beans.info.plugins.AbstractPropertyInfo;
+import org.jboss.beans.info.plugins.DefaultPropertyInfo;
+import org.jboss.beans.info.plugins.FieldPropertyInfo;
+import org.jboss.beans.info.plugins.SetterAndFieldPropertyInfo;
+import org.jboss.beans.info.plugins.GetterAndFieldPropertyInfo;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
import org.jboss.config.plugins.BasicConfiguration;
@@ -46,6 +50,7 @@
import org.jboss.reflect.spi.PrimitiveInfo;
import org.jboss.reflect.spi.TypeInfo;
import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.reflect.spi.FieldInfo;
import org.jboss.test.classinfo.test.AbstractClassInfoTest;
/**
@@ -65,12 +70,17 @@
protected void assertBeanInfo(BeanInfo beanInfo, Class<?> clazz) throws Throwable
{
+ assertBeanInfo(beanInfo, clazz, BeanAccessMode.STANDARD);
+ }
+
+ protected void assertBeanInfo(BeanInfo beanInfo, Class<?> clazz, BeanAccessMode mode) throws Throwable
+ {
assertEquals(clazz.getName(), beanInfo.getName());
ClassInfo classInfo = beanInfo.getClassInfo();
assertClassInfo(classInfo, clazz);
assertBeanConstructors(beanInfo, clazz);
assertBeanMethods(beanInfo, clazz);
- assertBeanProperties(beanInfo, clazz);
+ assertBeanProperties(beanInfo, clazz, mode);
}
protected void assertBeanConstructors(BeanInfo beanInfo, Class<?> clazz)
@@ -109,7 +119,7 @@
TypeInfoFactory factory = getTypeInfoFactory();
Set<MethodInfo> expected = new HashSet<MethodInfo>();
- Method[] methods = null;
+ Method[] methods;
if (clazz.isAnnotation())
methods = clazz.getDeclaredMethods();
else
@@ -138,13 +148,13 @@
assertEquals(expected, actual);
}
- protected void assertBeanProperties(BeanInfo beanInfo, Class<?> clazz) throws Throwable
+ protected void assertBeanProperties(BeanInfo beanInfo, Class<?> clazz, BeanAccessMode mode) throws Throwable
{
- Set<PropertyInfo> expected = null;
+ Set<PropertyInfo> expected;
if (clazz.isAnnotation())
expected = getExpectedAnnotationProperties(clazz);
else
- expected = getExpectedProperties(clazz);
+ expected = getExpectedProperties(clazz, mode);
Set<PropertyInfo> actual = beanInfo.getProperties();
if (expected.isEmpty())
@@ -153,7 +163,14 @@
return;
}
getLog().debug(clazz + " expected properties=" + expected + " actual=" + actual);
- assertEquals(expected, actual);
+ boolean equals = expected.equals(actual);
+ if (equals == false)
+ {
+ System.out.println("expected = " + expected);
+ System.out.println("actual = " + actual);
+ }
+ assertTrue(equals);
+// assertEquals(expected, actual);
HashMap<String, PropertyInfo> actualProps = new HashMap<String, PropertyInfo>();
for (PropertyInfo prop : actual)
@@ -181,7 +198,7 @@
}
}
- protected Set<PropertyInfo> getExpectedProperties(Class<?> clazz)
+ protected Set<PropertyInfo> getExpectedProperties(Class<?> clazz, BeanAccessMode mode)
{
TypeInfoFactory factory = getTypeInfoFactory();
Method[] methods = clazz.getMethods();
@@ -192,11 +209,14 @@
for (Method method : methods)
{
String name = method.getName();
- String upperName = getUpperPropertyName(name);
if (isGetter(method))
+ {
+ String upperName = getUpperPropertyName(name);
getters.put(upperName, method);
+ }
else if (isSetter(method))
{
+ String upperName = getUpperPropertyName(name);
List<Method> list = setters.get(upperName);
if (list == null)
{
@@ -208,7 +228,7 @@
}
}
- HashSet<PropertyInfo> properties = new HashSet<PropertyInfo>();
+ Map<String, PropertyInfo> properties = new HashMap<String, PropertyInfo>();
if (getters.isEmpty() == false)
{
for (Iterator<Map.Entry<String, Method>> i = getters.entrySet().iterator(); i.hasNext();)
@@ -264,7 +284,7 @@
paramAnnotations[0] = setterAnnotations.toArray(new AnnotationValue[setterAnnotations.size()]);
setterInfo = new MethodInfoImpl(null, setter.getName(), PrimitiveInfo.VOID, new TypeInfo[] { type }, paramAnnotations, null, setter.getModifiers(), declaringType);
}
- properties.add(new AbstractPropertyInfo(lowerName, name, type, getterInfo, setterInfo, annotations));
+ properties.put(lowerName, new DefaultPropertyInfo(lowerName, name, type, getterInfo, setterInfo, annotations));
}
}
if (setters.isEmpty() == false)
@@ -288,11 +308,33 @@
setterAnnotations = getExpectedAnnotations(setter.getParameterAnnotations()[0]);
paramAnnotations[0] = setterAnnotations.toArray(new AnnotationValue[setterAnnotations.size()]);
MethodInfo setterInfo = new MethodInfoImpl(null, setter.getName(), PrimitiveInfo.VOID, new TypeInfo[] { type }, paramAnnotations, null, setter.getModifiers(), declaringType);
- properties.add(new AbstractPropertyInfo(lowerName, name, type, null, setterInfo, annotations));
+ properties.put(lowerName, new DefaultPropertyInfo(lowerName, name, type, null, setterInfo, annotations));
}
}
}
- return properties;
+ if (mode != BeanAccessMode.STANDARD)
+ {
+ ClassInfo classInfo = (ClassInfo)factory.getTypeInfo(clazz);
+ Set<FieldInfo> fields = getFields(classInfo, mode);
+ for(FieldInfo field : fields)
+ {
+ String name = field.getName();
+ PropertyInfo pi = properties.get(name);
+ if (pi == null)
+ {
+ properties.put(name, new FieldPropertyInfo(field));
+ }
+ else if (pi.isReadable() == false)
+ {
+ properties.put(name, new SetterAndFieldPropertyInfo(pi, field));
+ }
+ else if (pi.isWritable() == false)
+ {
+ properties.put(name, new GetterAndFieldPropertyInfo(pi, field));
+ }
+ }
+ }
+ return new HashSet<PropertyInfo>(properties.values());
}
protected Set<PropertyInfo> getExpectedAnnotationProperties(Class<?> clazz)
@@ -312,12 +354,39 @@
Set<AnnotationValue> getterAnnotations = getExpectedAnnotations(method.getAnnotations());
AnnotationValue[] annotations = getterAnnotations.toArray(new AnnotationValue[getterAnnotations.size()]);
MethodInfo getter = new MethodInfoImpl(null, name, returnType, new TypeInfo[0], new AnnotationValue[0][], null, method.getModifiers(), declaringType);
- properties.add(new AbstractPropertyInfo(name, name, returnType, getter, null, annotations));
+ properties.add(new DefaultPropertyInfo(name, name, returnType, getter, null, annotations));
}
}
return properties;
}
+ /**
+ * Get the fields
+ *
+ * @param classInfo the class info
+ * @param mode the mode
+ * @return the fields
+ */
+ protected static Set<FieldInfo> getFields(ClassInfo classInfo, BeanAccessMode mode)
+ {
+ HashSet<FieldInfo> fields = new HashSet<FieldInfo>();
+ while (classInfo != null)
+ {
+ FieldInfo[] finfos = classInfo.getDeclaredFields();
+ if (finfos != null && finfos.length > 0)
+ {
+ for (int i = 0; i < finfos.length; ++i)
+ {
+ FieldInfo field = finfos[i];
+ if ((mode == BeanAccessMode.FIELDS && field.isPublic()) || (mode == BeanAccessMode.ALL))
+ fields.add(field);
+ }
+ }
+ classInfo = classInfo.getSuperclass();
+ }
+ return fields;
+ }
+
protected static String getUpperPropertyName(String name)
{
int start = 3;
@@ -383,6 +452,11 @@
return configuration.getBeanInfo(clazz);
}
+ protected BeanInfo getBeanInfo(Class<?> clazz, BeanAccessMode accessMode) throws Throwable
+ {
+ return configuration.getBeanInfo(clazz, accessMode);
+ }
+
protected Configuration getConfiguration()
{
return configuration;
Modified: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUnitTestCase.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -27,6 +27,7 @@
import junit.framework.Test;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.test.beaninfo.support.BeanInfoAnnotatedGetterAndSetter;
import org.jboss.test.beaninfo.support.BeanInfoAnnotatedGetterAndSetterSimpleMerge;
import org.jboss.test.beaninfo.support.BeanInfoAnnotatedGetterAndSetterWithInterface;
@@ -51,6 +52,24 @@
import org.jboss.test.beaninfo.support.BeanInfoProperties;
import org.jboss.test.beaninfo.support.BeanInfoSetterOnly;
import org.jboss.test.beaninfo.support.BeanInfoUpperPropertyName;
+import org.jboss.test.beaninfo.support.BeanInfoMethods;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoFields;
+import org.jboss.test.beaninfo.support.SubBeanInfoGetterAndSetter;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndSetter2;
+import org.jboss.test.beaninfo.support.BeanInfoGetterAndField2;
+import org.jboss.test.beaninfo.support.SubBeanInfoGetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoSetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoSetterAndField2;
+import org.jboss.test.beaninfo.support.SubBeanInfoSetterAndField;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo2;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo3;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo4;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo5;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo6;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo7;
+import org.jboss.test.beaninfo.support.BeanInfoExtendsFoo8;
/**
* BeanInfo Test Case.
@@ -82,9 +101,14 @@
public void testBeanMethods() throws Throwable
{
- testBean(BeanInfoConstructors.class, null);
+ testBean(BeanInfoMethods.class, null);
}
+ public void testBeanFields() throws Throwable
+ {
+ testBean(BeanInfoFields.class, null);
+ }
+
public void testBeanGetterOnly() throws Throwable
{
testBean(BeanInfoGetterOnly.class, new String[] { "something" });
@@ -95,11 +119,62 @@
testBean(BeanInfoSetterOnly.class, new String[] { "something" });
}
+ public void testBeanGetterAndField() throws Throwable
+ {
+ testBean(BeanInfoGetterAndField.class, new String[] { "something" });
+ testBean(BeanInfoGetterAndField2.class, new String[] { "something" });
+ testBean(SubBeanInfoGetterAndField.class, new String[] { "something" });
+ }
+
+ public void testBeanSetterAndField() throws Throwable
+ {
+ testBean(BeanInfoSetterAndField.class, new String[] { "something" });
+ testBean(BeanInfoSetterAndField2.class, new String[] { "something" });
+ testBean(SubBeanInfoSetterAndField.class, new String[] { "something" });
+ }
+
public void testBeanGetterAndSetter() throws Throwable
{
testBean(BeanInfoGetterAndSetter.class, new String[] { "something" });
+ testBean(BeanInfoGetterAndSetter2.class, new String[] { "something" });
+ testBean(SubBeanInfoGetterAndSetter.class, new String[] { "something" });
}
-
+
+ public void testHierarchyBean() throws Throwable
+ {
+ testBean(BeanInfoExtendsFoo.class, BeanAccessMode.STANDARD, new String[]{});
+ testBean(BeanInfoExtendsFoo.class, BeanAccessMode.FIELDS, new String[]{"foo", "bar"});
+ testBean(BeanInfoExtendsFoo.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo2.class, BeanAccessMode.STANDARD, new String[]{"bar"});
+ testBean(BeanInfoExtendsFoo2.class, BeanAccessMode.FIELDS, new String[]{"foo", "bar"});
+ testBean(BeanInfoExtendsFoo2.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo3.class, BeanAccessMode.STANDARD, new String[]{});
+ testBean(BeanInfoExtendsFoo3.class, BeanAccessMode.FIELDS, new String[]{"bar"});
+ testBean(BeanInfoExtendsFoo3.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo4.class, BeanAccessMode.STANDARD, new String[]{"bar"});
+ testBean(BeanInfoExtendsFoo4.class, BeanAccessMode.FIELDS, new String[]{"bar"});
+ testBean(BeanInfoExtendsFoo4.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo5.class, BeanAccessMode.STANDARD, new String[]{});
+ testBean(BeanInfoExtendsFoo5.class, BeanAccessMode.FIELDS, new String[]{});
+ testBean(BeanInfoExtendsFoo5.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo6.class, BeanAccessMode.STANDARD, new String[]{"foo"});
+ testBean(BeanInfoExtendsFoo6.class, BeanAccessMode.FIELDS, new String[]{"foo"});
+ testBean(BeanInfoExtendsFoo6.class, BeanAccessMode.ALL, new String[]{"foo", "bar"});
+
+ testBean(BeanInfoExtendsFoo7.class, BeanAccessMode.STANDARD, new String[]{});
+ testBean(BeanInfoExtendsFoo7.class, BeanAccessMode.FIELDS, new String[]{});
+ testBean(BeanInfoExtendsFoo7.class, BeanAccessMode.ALL, new String[]{"bar"});
+
+ testBean(BeanInfoExtendsFoo8.class, BeanAccessMode.STANDARD, new String[]{});
+ testBean(BeanInfoExtendsFoo8.class, BeanAccessMode.FIELDS, new String[]{});
+ testBean(BeanInfoExtendsFoo8.class, BeanAccessMode.ALL, new String[]{"bar", "foo"});
+ }
+
public void testBeanBooleanProperties() throws Throwable
{
testBean(BeanInfoBooleanProperties.class, new String[] { "something", "somethingElse" });
@@ -251,8 +326,15 @@
protected void testBean(Class<?> clazz, String[] beanNames) throws Throwable
{
- BeanInfo beanInfo = getBeanInfo(clazz);
- assertBeanInfo(beanInfo, clazz);
+ for (BeanAccessMode mode : BeanAccessMode.values())
+ {
+ testBean(clazz, mode, beanNames);
+ }
+ }
+ protected void testBean(Class<?> clazz, BeanAccessMode mode, String[] beanNames) throws Throwable
+ {
+ BeanInfo beanInfo = getBeanInfo(clazz, mode);
+ assertBeanInfo(beanInfo, clazz, mode);
if (beanNames != null)
{
Set<PropertyInfo> properties = beanInfo.getProperties();
Modified: projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUtilTestCase.java
===================================================================
--- projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUtilTestCase.java 2008-03-15 01:14:19 UTC (rev 70885)
+++ projects/jboss-reflect/trunk/src/tests/org/jboss/test/beaninfo/test/BeanInfoUtilTestCase.java 2008-03-15 20:39:41 UTC (rev 70886)
@@ -22,10 +22,28 @@
package org.jboss.test.beaninfo.test;
import junit.framework.Test;
-import org.jboss.test.beaninfo.support.NestedBean;
import org.jboss.beans.info.plugins.BeanInfoUtil;
+import org.jboss.beans.info.spi.BeanAccessMode;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.test.beaninfo.support.NestedBean;
+import org.jboss.test.beaninfo.support.PrivateGetterNestedBean;
+import org.jboss.test.beaninfo.support.PrivateMixNestedBean;
+import org.jboss.test.beaninfo.support.PrivateNestedBean;
+import org.jboss.test.beaninfo.support.PrivateSetterNestedBean;
+import org.jboss.test.beaninfo.support.PubGetterNestedBean;
+import org.jboss.test.beaninfo.support.PubMixNestedBean;
+import org.jboss.test.beaninfo.support.PubNestedBean;
+import org.jboss.test.beaninfo.support.PubSetterNestedBean;
+import org.jboss.test.beaninfo.support.SetGetHook;
+import org.jboss.test.beaninfo.support.SubPubSetterNestedBean;
+import org.jboss.test.beaninfo.support.SubPubNestedBean;
+import org.jboss.test.beaninfo.support.SubPrivateMixNestedBean;
+import org.jboss.test.beaninfo.support.SubPrivateNestedBean;
+import org.jboss.test.beaninfo.support.SubPrivateSetterNestedBean;
+import org.jboss.test.beaninfo.support.SubPubMixNestedBean;
+import org.jboss.test.beaninfo.support.SubPubGetterNestedBean;
+import org.jboss.test.beaninfo.support.SubPrivateGetterNestedBean;
/**
* BeanInfoUtil Test Case.
@@ -44,52 +62,218 @@
super(name);
}
- protected BeanInfo getBeanInfo() throws Throwable
+ protected <T extends SetGetHook<T>> void checkSimpleGet(Class<T> clazz, BeanAccessMode mode) throws Throwable
{
- return getBeanInfo(NestedBean.class);
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ parent.doSetHook(child);
+ assertSame(child, BeanInfoUtil.get(getBeanInfo(clazz, mode), parent, "bean"));
+ assertTrue(parent.valid());
}
+ protected <T extends SetGetHook<T>> void failSimpleGet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ try
+ {
+ checkSimpleGet(clazz, mode);
+ fail("Should not be here.");
+ }
+ catch(Throwable t)
+ {
+ assertInstanceOf(t, IllegalArgumentException.class);
+ }
+ }
+
public void testSimpleGet() throws Throwable
{
- NestedBean child = new NestedBean();
- NestedBean parent = new NestedBean(child);
- assertSame(child, BeanInfoUtil.get(getBeanInfo(), parent, "nestedBean"));
+ checkSimpleGet(NestedBean.class, BeanAccessMode.STANDARD);
+ checkSimpleGet(NestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleGet(NestedBean.class, BeanAccessMode.ALL);
+
+ checkSimpleGet(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleGet(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleGet(PubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failSimpleGet(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkSimpleGet(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleGet(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleGet(SubPubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failSimpleGet(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkSimpleGet(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(PrivateGetterNestedBean.class, BeanAccessMode.ALL);
+
+ checkSimpleGet(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleGet(SubPrivateGetterNestedBean.class, BeanAccessMode.ALL);
}
+ protected <T extends SetGetHook<T>> void checkSimpleSet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ BeanInfoUtil.set(getBeanInfo(clazz, mode), parent, "bean", child);
+ assertTrue(parent.valid());
+ assertSame(child, parent.doGetHook());
+ }
+
+ protected <T extends SetGetHook<T>> void failSimpleSet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ try
+ {
+ checkSimpleSet(clazz, mode);
+ fail("Should not be here.");
+ }
+ catch(Throwable t)
+ {
+ assertInstanceOf(t, IllegalArgumentException.class);
+ }
+ }
+
public void testSimpleSet() throws Throwable
{
- NestedBean child = new NestedBean();
- NestedBean parent = new NestedBean();
- BeanInfoUtil.set(getBeanInfo(), parent, "nestedBean", child);
- assertSame(child, parent.getNestedBean());
+ checkSimpleSet(NestedBean.class, BeanAccessMode.STANDARD);
+ checkSimpleSet(NestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleSet(NestedBean.class, BeanAccessMode.ALL);
+
+ checkSimpleSet(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleSet(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ failSimpleSet(PubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleSet(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkSimpleSet(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleSet(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ failSimpleSet(SubPubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkSimpleSet(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkSimpleSet(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(PrivateGetterNestedBean.class, BeanAccessMode.ALL);
+
+ checkSimpleSet(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkSimpleSet(SubPrivateGetterNestedBean.class, BeanAccessMode.ALL);
}
+ protected <T extends SetGetHook<T>> void checkNestedGet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ T grandchild = clazz.newInstance();
+ parent.doSetHook(child);
+ child.doSetHook(grandchild);
+ assertSame(grandchild, BeanInfoUtil.get(getBeanInfo(clazz, mode), parent, "bean.bean"));
+ }
+
+ protected <T extends SetGetHook<T>> void failNestedGet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ try
+ {
+ checkNestedGet(clazz, mode);
+ fail("Should not be here.");
+ }
+ catch (Throwable t)
+ {
+ assertInstanceOf(t, IllegalArgumentException.class);
+ }
+ }
+
public void testNestedGet() throws Throwable
{
- NestedBean grandchild = new NestedBean();
- NestedBean child = new NestedBean(grandchild);
- NestedBean parent = new NestedBean(child);
- assertSame(grandchild, BeanInfoUtil.get(getBeanInfo(), parent, "nestedBean.nestedBean"));
+ checkNestedGet(NestedBean.class, BeanAccessMode.STANDARD);
+ checkNestedGet(NestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGet(NestedBean.class, BeanAccessMode.ALL);
+
+ failNestedGet(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGet(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGet(PubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedGet(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ failNestedGet(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGet(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGet(SubPubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedGet(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ failNestedGet(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGet(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ failNestedGet(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGet(PrivateGetterNestedBean.class, BeanAccessMode.ALL);
+
+ failNestedGet(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGet(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ failNestedGet(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGet(SubPrivateGetterNestedBean.class, BeanAccessMode.ALL);
}
+ protected <T extends SetGetHook<T>> void checkNestedSet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ T grandchild = clazz.newInstance();
+ parent.doSetHook(child);
+ BeanInfoUtil.set(getBeanInfo(clazz, mode), parent, "bean.bean", grandchild);
+ assertTrue(parent.valid());
+ assertTrue(child.valid());
+ assertSame(grandchild, parent.doGetHook().doGetHook());
+ }
+
+ protected <T extends SetGetHook<T>> void failNestedSet(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ try
+ {
+ checkNestedSet(clazz, mode);
+ fail("Should not be here.");
+ }
+ catch (Throwable t)
+ {
+ assertInstanceOf(t, IllegalArgumentException.class);
+ }
+ }
+
public void testNestedSet() throws Throwable
{
- NestedBean grandchild = new NestedBean();
- NestedBean child = new NestedBean();
- NestedBean parent = new NestedBean(child);
- BeanInfoUtil.set(getBeanInfo(), parent, "nestedBean.nestedBean", grandchild);
- assertSame(child, parent.getNestedBean());
- assertSame(grandchild, child.getNestedBean());
+ checkNestedSet(NestedBean.class, BeanAccessMode.STANDARD);
+ checkNestedSet(NestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSet(NestedBean.class, BeanAccessMode.ALL);
+
+ failNestedSet(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSet(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedSet(PubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedSet(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ failNestedSet(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSet(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedSet(SubPubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ failNestedSet(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ failNestedSet(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSet(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSet(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ failNestedSet(PrivateGetterNestedBean.class, BeanAccessMode.ALL);
+
+ failNestedSet(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSet(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSet(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ failNestedSet(SubPrivateGetterNestedBean.class, BeanAccessMode.ALL);
}
- public void testNestedGetFail() throws Throwable
+ protected <T extends SetGetHook<T>> void checkNestedGetFail(Class<T> clazz, BeanAccessMode mode) throws Throwable
{
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ T grandchild = clazz.newInstance();
+ T grandgrandchild = clazz.newInstance();
+ parent.doSetHook(child);
+ // missing link
+ grandchild.doSetHook(grandgrandchild);
try
{
- NestedBean grandchild = new NestedBean();
- NestedBean child = new NestedBean(grandchild);
- NestedBean parent = new NestedBean(child);
- assertSame(grandchild, BeanInfoUtil.get(getBeanInfo(), parent, "differentGetter.nestedBean"));
+ BeanInfoUtil.get(getBeanInfo(clazz, mode), parent, "bean.bean.bean");
fail("Should not be here.");
}
catch (Throwable t)
@@ -98,16 +282,43 @@
}
}
- public void testNestedSetFail() throws Throwable
+ public void testNestedGetFail() throws Throwable
{
+ checkNestedGetFail(NestedBean.class, BeanAccessMode.STANDARD);
+ checkNestedGetFail(NestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(NestedBean.class, BeanAccessMode.ALL);
+
+ checkNestedGetFail(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(PubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkNestedGetFail(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(SubPubGetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedGetFail(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkNestedGetFail(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(PrivateGetterNestedBean.class, BeanAccessMode.ALL);
+
+ checkNestedGetFail(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedGetFail(SubPrivateGetterNestedBean.class, BeanAccessMode.ALL);
+ }
+
+ protected <T extends SetGetHook<T>> void checkNestedSetFail(Class<T> clazz, BeanAccessMode mode) throws Throwable
+ {
+ T parent = clazz.newInstance();
+ T child = clazz.newInstance();
+ // missing link
+ T grandgrandchild = clazz.newInstance();
+ parent.doSetHook(child);
try
{
- NestedBean grandchild = new NestedBean();
- NestedBean child = new NestedBean();
- NestedBean parent = new NestedBean(child);
- BeanInfoUtil.set(getBeanInfo(), parent, "differentGetter.nestedBean", grandchild);
- assertSame(child, parent.getNestedBean());
- assertSame(grandchild, child.getNestedBean());
+ BeanInfoUtil.set(getBeanInfo(clazz, mode), parent, "bean.bean.bean", grandgrandchild);
fail("Should not be here.");
}
catch (Throwable t)
@@ -116,14 +327,43 @@
}
}
+ public void testNestedSetFail() throws Throwable
+ {
+ checkNestedSetFail(NestedBean.class, BeanAccessMode.STANDARD);
+ checkNestedSetFail(NestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(NestedBean.class, BeanAccessMode.ALL);
+
+ checkNestedSetFail(PubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(PubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(PubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkNestedSetFail(SubPubNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(SubPubMixNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+ checkNestedSetFail(SubPubSetterNestedBean.class, BeanAccessMode.FIELDS);
+
+ checkNestedSetFail(PrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(PrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(PrivateSetterNestedBean.class, BeanAccessMode.ALL);
+
+ checkNestedSetFail(SubPrivateNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(SubPrivateMixNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ checkNestedSetFail(SubPrivateSetterNestedBean.class, BeanAccessMode.ALL);
+ }
+
public void testNestedPropertyInfo() throws Throwable
{
NestedBean grandchild = new NestedBean();
- NestedBean child = new NestedBean(grandchild);
- NestedBean parent = new NestedBean(child);
- BeanInfo beanInfo = getBeanInfo();
+ NestedBean child = new NestedBean();
+ child.doSetHook(grandchild);
+ NestedBean parent = new NestedBean();
+ parent.doSetHook(child);
+ BeanInfo beanInfo = getBeanInfo(NestedBean.class);
PropertyInfo propertyInfo = beanInfo.getProperty("string");
- PropertyInfo nestedPropertyInfo = BeanInfoUtil.getPropertyInfo(beanInfo, parent, "nestedBean.otherBean.string");
+ PropertyInfo nestedPropertyInfo = BeanInfoUtil.getPropertyInfo(beanInfo, parent, "bean.otherBean.string");
assertEquals(propertyInfo, nestedPropertyInfo);
}
@@ -132,9 +372,10 @@
try
{
NestedBean child = new NestedBean();
- NestedBean parent = new NestedBean(child);
- BeanInfo beanInfo = getBeanInfo();
- BeanInfoUtil.getPropertyInfo(beanInfo, parent, "nestedBean.differentGetter.string");
+ NestedBean parent = new NestedBean();
+ parent.doSetHook(child);
+ BeanInfo beanInfo = getBeanInfo(NestedBean.class);
+ BeanInfoUtil.getPropertyInfo(beanInfo, parent, "bean.differentGetter.string");
fail("Should not be here.");
}
catch (Throwable t)
More information about the jboss-cvs-commits
mailing list