geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r479435 - in /geronimo/xbean/trunk/xbean-reflect/src: main/java/org/apache/xbean/ main/java/org/apache/xbean/propertyeditor/ main/java/org/apache/xbean/recipe/ test/java/org/apache/xbean/recipe/
Date Sun, 26 Nov 2006 22:41:32 GMT
Author: dblevins
Date: Sun Nov 26 14:41:31 2006
New Revision: 479435

URL: http://svn.apache.org/viewvc?view=rev&rev=479435
Log:
(XBEAN-62) Field injection
(XBEAN-61) Injection to non-public properties

Added:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/Classes.java
      - copied, changed from r479384, geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/ClassLoading.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MissingAccessorException.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/Option.java
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/MixedRecipeTest.java
    geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Widget.java
Removed:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/ClassLoading.java
Modified:
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/AbstractConverter.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ArrayConverter.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ClassEditor.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/CollectionUtil.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditors.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ConstructionException.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MapRecipe.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
    geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ValueRecipe.java

Copied: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/Classes.java (from r479384, geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/ClassLoading.java)
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/Classes.java?view=diff&rev=479435&p1=geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/ClassLoading.java&r1=479384&p2=geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/Classes.java&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/ClassLoading.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/Classes.java Sun Nov 26 14:41:31 2006
@@ -20,197 +20,14 @@
 import java.util.HashMap;
 
 /**
- * Utility class for loading classes by a variety of name variations.
- * <p/>
- * Supported names types are:
- * <p/>
- * 1)  Fully qualified class name (e.g., "java.lang.String", "org.apache.xbean.ClassLoading"
- * 2)  Method signature encoding ("Ljava.lang.String;", "J", "I", etc.)
- * 3)  Primitive type names ("int", "boolean", etc.)
- * 4)  Method array signature strings ("[I", "[Ljava.lang.String")
- * 5)  Arrays using Java code format ("int[]", "java.lang.String[][]")
- * <p/>
- * The classes are loaded using the provided class loader.  For the basic types, the primitive
- * reflection types are returned.
+ * Utility for printing class names
  *
  * @version $Rev: 6685 $
  */
-public class ClassLoading {
+public class Classes {
 
     /**
-     * Table for mapping primitive class names/signatures to the implementing
-     * class object
-     */
-    private static final HashMap PRIMITIVE_CLASS_MAP = new HashMap();
-
-    /**
-     * Table for mapping primitive classes back to their name signature type, which
-     * allows a reverse mapping to be performed from a class object into a resolvable
-     * signature.
-     */
-    private static final HashMap CLASS_TO_SIGNATURE_MAP = new HashMap();
-
-
-    /**
-     * Setup the primitives map.  We make any entry for each primitive class using both the
-     * human readable name and the method signature shorthand type.
-     */
-    static {
-        PRIMITIVE_CLASS_MAP.put("boolean", boolean.class);
-        PRIMITIVE_CLASS_MAP.put("Z", boolean.class);
-        PRIMITIVE_CLASS_MAP.put("byte", byte.class);
-        PRIMITIVE_CLASS_MAP.put("B", byte.class);
-        PRIMITIVE_CLASS_MAP.put("char", char.class);
-        PRIMITIVE_CLASS_MAP.put("C", char.class);
-        PRIMITIVE_CLASS_MAP.put("short", short.class);
-        PRIMITIVE_CLASS_MAP.put("S", short.class);
-        PRIMITIVE_CLASS_MAP.put("int", int.class);
-        PRIMITIVE_CLASS_MAP.put("I", int.class);
-        PRIMITIVE_CLASS_MAP.put("long", long.class);
-        PRIMITIVE_CLASS_MAP.put("J", long.class);
-        PRIMITIVE_CLASS_MAP.put("float", float.class);
-        PRIMITIVE_CLASS_MAP.put("F", float.class);
-        PRIMITIVE_CLASS_MAP.put("double", double.class);
-        PRIMITIVE_CLASS_MAP.put("D", double.class);
-        PRIMITIVE_CLASS_MAP.put("void", void.class);
-        PRIMITIVE_CLASS_MAP.put("V", void.class);
-
-        // Now build a reverse mapping table.  The table above has a many-to-one mapping for
-        // class names.  To do the reverse, we need to pick just one.  As long as the
-        // returned name supports "round tripping" of the requests, this will work fine.
-
-        CLASS_TO_SIGNATURE_MAP.put(boolean.class, "Z");
-        CLASS_TO_SIGNATURE_MAP.put(byte.class, "B");
-        CLASS_TO_SIGNATURE_MAP.put(char.class, "C");
-        CLASS_TO_SIGNATURE_MAP.put(short.class, "S");
-        CLASS_TO_SIGNATURE_MAP.put(int.class, "I");
-        CLASS_TO_SIGNATURE_MAP.put(long.class, "J");
-        CLASS_TO_SIGNATURE_MAP.put(float.class, "F");
-        CLASS_TO_SIGNATURE_MAP.put(double.class, "D");
-        CLASS_TO_SIGNATURE_MAP.put(void.class, "V");
-
-    }
-
-
-    /**
-     * Load a class that matches the requested name, using the provided class loader context.
-     * <p/>
-     * The class name may be a standard class name, the name of a primitive type Java
-     * reflection class (e.g., "boolean" or "int"), or a type in method type signature
-     * encoding.  Array classes in either encoding form are also processed.
-     *
-     * @param className The name of the required class.
-     * @param classLoader The class loader used to resolve the class object.
-     * @return The Class object resolved from "className".
-     * @throws ClassNotFoundException When unable to resolve the class object.
-     * @throws IllegalArgumentException If either argument is null.
-     */
-    public static Class loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
-
-        // the tests require IllegalArgumentExceptions for null values on either of these.
-        if (className == null) {
-            throw new IllegalArgumentException("className is null");
-        }
-
-        if (classLoader == null) {
-            throw new IllegalArgumentException("classLoader is null");
-        }
-        // The easiest case is a proper class name.  We just have the class loader resolve this.
-        // If the class loader throws a ClassNotFoundException, then we need to check each of the
-        // special name encodings we support.
-        try {
-            return classLoader.loadClass(className);
-        } catch (ClassNotFoundException ignore) {
-            // if not found, continue on to the other name forms.
-        }
-
-
-        // The second easiest version to resolve is a direct map to a primitive type name
-        // or method signature.  Check our name-to-class map for one of those.
-        Class resolvedClass = (Class) PRIMITIVE_CLASS_MAP.get(className);
-        if (resolvedClass != null) {
-            return resolvedClass;
-        }
-
-        // Class names in method signature have the format "Lfully.resolved.name;",
-        // so if it ends in a semicolon and begins with an "L", this must be in
-        // this format.  Have the class loader try to load this.  There are no other
-        // options if this fails, so just allow the class loader to throw the
-        // ClassNotFoundException.
-        if (className.endsWith(";") && className.startsWith("L")) {
-            // pick out the name portion
-            String typeName = className.substring(1, className.length() - 1);
-            // and delegate the loading to the class loader.
-            return classLoader.loadClass(typeName);
-        }
-
-        // All we have left now are the array types.  Method signature array types
-        // have a series of leading "[" characters to specify the number of dimensions.
-        // The other array type we handle uses trailing "[]" for the dimensions, just
-        // like the Java language syntax.
-
-        // first check for the signature form ([[[[type).
-        if (className.charAt(0) == '[') {
-            // we have at least one array marker, now count how many leading '['s we have
-            // to get the dimension count.
-            int count = 0;
-            int nameLen = className.length();
-
-            while (count < nameLen && className.charAt(count) == '[') {
-                count++;
-            }
-
-            // pull of the name subtype, which is everything after the last '['
-            String arrayTypeName = className.substring(count, className.length());
-            // resolve the type using a recursive call, which will load any of the primitive signature
-            // types as well as class names.
-            Class arrayType = loadClass(arrayTypeName, classLoader);
-
-            // Resolving array types require a little more work.  The array classes are
-            // created dynamically when the first instance of a given dimension and type is
-            // created.  We need to create one using reflection to do this.
-            return getArrayClass(arrayType, count);
-        }
-
-
-        // ok, last chance.  Now check for an array specification in Java language
-        // syntax.  This will be a type name followed by pairs of "[]" to indicate
-        // the number of dimensions.
-        if (className.endsWith("[]")) {
-            // get the base component class name and the arrayDimensions
-            int count = 0;
-            int position = className.length();
-
-            while (position > 1 && className.substring(position - 2, position).equals("[]")) {
-                // count this dimension
-                count++;
-                // and step back the probe position.
-                position -= 2;
-            }
-
-            // position now points at the location of the last successful test.  This makes it
-            // easy to pick off the class name.
-
-            String typeName = className.substring(0, position);
-
-            // load the base type, again, doing this recursively
-            Class arrayType = loadClass(typeName, classLoader);
-            // and turn this into the class object
-            return getArrayClass(arrayType, count);
-        }
-
-        // We're out of options, just toss an exception over the wall.
-        throw new ClassNotFoundException(className);
-    }
-
-
-    /**
-     * Map a class object back to a class name.  The returned class object
-     * must be "round trippable", which means
-     * <p/>
-     * type == ClassLoading.loadClass(ClassLoading.getClassName(type), classLoader)
-     * <p/>
-     * must be true.  To ensure this, the class name is always returned in
+     * The returns the name of the class object in
      * method signature format.
      *
      * @param type The class object we convert into name form.
@@ -257,7 +74,15 @@
             if (pretty) {
                 name.insert(0, type.getName());
             } else {
-                name.append((String) CLASS_TO_SIGNATURE_MAP.get(type));
+                if (type.equals((boolean.class))) name.append('Z');
+                else if (type.equals((byte.class))) name.append('B');
+                else if (type.equals((char.class))) name.append('C');
+                else if (type.equals((short.class))) name.append('S');
+                else if (type.equals((int.class))) name.append('I');
+                else if (type.equals((long.class))) name.append('J');
+                else if (type.equals((float.class))) name.append('F');
+                else if (type.equals((double.class))) name.append('D');
+                else if (type.equals((void.class))) name.append('V');
             }
         }
         // a "normal" class.  This gets expressing using the "Lmy.class.name;" syntax.
@@ -271,15 +96,6 @@
             }
         }
         return name.toString();
-    }
-
-    private static Class getArrayClass(Class type, int dimension) {
-        // Array.newInstance() requires an array of the requested number of dimensions
-        // that gives the size for each dimension.  We just request 0 in each of the
-        // dimentions, which is not unlike a black hole sigularity.
-        int dimensions[] = new int[dimension];
-        // create an instance and return the associated class object.
-        return Array.newInstance(type, dimensions).getClass();
     }
 }
 

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/AbstractConverter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/AbstractConverter.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/AbstractConverter.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/AbstractConverter.java Sun Nov 26 14:41:31 2006
@@ -18,7 +18,7 @@
 
 import java.beans.PropertyEditorSupport;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 /**
  * A base class for converters.  This class handles all converter methods, and redirects all conversion requests to
@@ -66,7 +66,7 @@
             super.setValue(null);
         }
         if (!type.isInstance(value)) {
-            throw new PropertyEditorException("Value is not an instance of " + ClassLoading.getClassName(type));
+            throw new PropertyEditorException("Value is not an instance of " + Classes.getClassName(type));
         }
         super.setValue(value);
     }
@@ -76,7 +76,7 @@
             return null;
         }
         if (!type.isInstance(value)) {
-            throw new PropertyEditorException("Value is not an instance of " + ClassLoading.getClassName(type) + ": " + value.getClass().getName());
+            throw new PropertyEditorException("Value is not an instance of " + Classes.getClassName(type) + ": " + value.getClass().getName());
         }
         return toStringImpl(value);
     }

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ArrayConverter.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ArrayConverter.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ArrayConverter.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ArrayConverter.java Sun Nov 26 14:41:31 2006
@@ -21,7 +21,7 @@
 import java.util.List;
 import java.util.ListIterator;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 /**
  * Adapter for editing array types.
@@ -33,11 +33,11 @@
         super(type, editor);
 
         if (!type.isArray()) {
-            throw new IllegalArgumentException("type is not an array " + ClassLoading.getClassName(type));
+            throw new IllegalArgumentException("type is not an array " + Classes.getClassName(type));
         }
 
         if (type.getComponentType().isArray()) {
-            throw new IllegalArgumentException("type is a multi-dimensional array " + ClassLoading.getClassName(type, true));
+            throw new IllegalArgumentException("type is a multi-dimensional array " + Classes.getClassName(type, true));
         }
 
         if (editor == null) throw new NullPointerException("editor is null");

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ClassEditor.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ClassEditor.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ClassEditor.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/ClassEditor.java Sun Nov 26 14:41:31 2006
@@ -16,7 +16,7 @@
  */
 package org.apache.xbean.propertyeditor;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 /**
  * A property editor for converting class names into class object instances
@@ -39,7 +39,7 @@
     protected Object toObjectImpl(String text) {
         try {
             // load this using the current thread's context loader.
-            return ClassLoading.loadClass(text, Thread.currentThread().getContextClassLoader());
+            return Class.forName(text, true, Thread.currentThread().getContextClassLoader());
         } catch (Exception e) {
             // not found exceptions are just turned into wrapped property exceptions.
             throw new PropertyEditorException("Unable to resolve class " + text, e);
@@ -48,7 +48,7 @@
 
     protected String toStringImpl(Object value) {
         Class clazz = (Class) value;
-        String text = ClassLoading.getClassName(clazz);
+        String text = Classes.getClassName(clazz);
         return text;
     }
 }

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/CollectionUtil.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/CollectionUtil.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/CollectionUtil.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/CollectionUtil.java Sun Nov 26 14:41:31 2006
@@ -29,7 +29,7 @@
 import java.io.IOException;
 import java.io.ByteArrayOutputStream;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 /**
  * @version $Rev: 6680 $ $Date: 2005-12-24T04:38:27.427468Z $
@@ -140,7 +140,7 @@
             Converter converter = (Converter) componentEditor;
             Class type = converter.getType();
             if (!type.isInstance(value)) {
-                throw new PropertyEditorException("Value is not an instance of " + ClassLoading.getClassName(type) + ": " + value.getClass().getName());
+                throw new PropertyEditorException("Value is not an instance of " + Classes.getClassName(type) + ": " + value.getClass().getName());
             }
             return converter.toString(value);
         } else {

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditors.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditors.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditors.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditors.java Sun Nov 26 14:41:31 2006
@@ -22,7 +22,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 /**
  * The property editor manager.  This orchestrates Geronimo usage of
@@ -127,7 +127,7 @@
         // load using the ClassLoading utility, which also manages arrays and primitive classes.
         Class typeClass = null;
         try {
-            typeClass = ClassLoading.loadClass(type, classLoader);
+            typeClass = Class.forName(type, true, classLoader);
         } catch (ClassNotFoundException e) {
             throw new PropertyEditorException("Type class could not be found: " + type);
         }
@@ -166,7 +166,7 @@
         // fall back to a property editor
         PropertyEditor editor = findEditor(type);
         if (editor == null) {
-            throw new PropertyEditorException("Unable to find PropertyEditor for " + ClassLoading.getClassName(type, true));
+            throw new PropertyEditorException("Unable to find PropertyEditor for " + Classes.getClassName(type, true));
         }
 
         // create the string value
@@ -175,8 +175,8 @@
         try {
             textValue = editor.getAsText();
         } catch (Exception e) {
-            throw new PropertyEditorException("Error while converting a \"" + ClassLoading.getClassName(type, true) + "\" to text " +
-                    " using the property editor " + ClassLoading.getClassName(editor.getClass(), true), e);
+            throw new PropertyEditorException("Error while converting a \"" + Classes.getClassName(type, true) + "\" to text " +
+                    " using the property editor " + Classes.getClassName(editor.getClass(), true), e);
         }
         return textValue;
     }
@@ -189,7 +189,7 @@
         // load using the ClassLoading utility, which also manages arrays and primitive classes.
         Class typeClass = null;
         try {
-            typeClass = ClassLoading.loadClass(type, classLoader);
+            typeClass = Class.forName(type, true, classLoader);
         } catch (ClassNotFoundException e) {
             throw new PropertyEditorException("Type class could not be found: " + type);
         }
@@ -211,7 +211,7 @@
         // fall back to a property editor
         PropertyEditor editor = findEditor(type);
         if (editor == null) {
-            throw new PropertyEditorException("Unable to find PropertyEditor for " + ClassLoading.getClassName(type, true));
+            throw new PropertyEditorException("Unable to find PropertyEditor for " + Classes.getClassName(type, true));
         }
 
         // create the object value
@@ -220,8 +220,8 @@
         try {
             objectValue = editor.getValue();
         } catch (Exception e) {
-            throw new PropertyEditorException("Error while converting \"" + value + "\" to a " + ClassLoading.getClassName(type, true) +
-                    " using the property editor " + ClassLoading.getClassName(editor.getClass(), true), e);
+            throw new PropertyEditorException("Error while converting \"" + value + "\" to a " + Classes.getClassName(type, true) +
+                    " using the property editor " + Classes.getClassName(editor.getClass(), true), e);
         }
         return objectValue;
     }

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/CollectionRecipe.java Sun Nov 26 14:41:31 2006
@@ -25,8 +25,6 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.xbean.ClassLoading;
-
 /**
  * @version $Rev: 6685 $ $Date: 2005-12-28T00:29:37.967210Z $
  */
@@ -95,7 +93,7 @@
     public Object create(ClassLoader classLoader) {
         Class setType = null;
         try {
-            setType = ClassLoading.loadClass(type, classLoader);
+            setType = Class.forName(type, true, classLoader);
         } catch (ClassNotFoundException e) {
             throw new ConstructionException("Type class could not be found: " + type);
         }

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ConstructionException.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ConstructionException.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ConstructionException.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ConstructionException.java Sun Nov 26 14:41:31 2006
@@ -20,6 +20,7 @@
  * @version $Rev: 6680 $ $Date: 2005-12-24T04:38:27.427468Z $
  */
 public class ConstructionException extends RuntimeException {
+
     private String beanName;
     private String attributeName;
 

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MapRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MapRecipe.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MapRecipe.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MapRecipe.java Sun Nov 26 14:41:31 2006
@@ -24,8 +24,6 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
 
-import org.apache.xbean.ClassLoading;
-
 /**
  * @version $Rev: 6687 $ $Date: 2005-12-28T21:08:56.733437Z $
  */
@@ -89,7 +87,7 @@
     public Object create(ClassLoader classLoader) {
         Class mapType = null;
         try {
-            mapType = ClassLoading.loadClass(type, classLoader);
+            mapType = Class.forName(type, true, classLoader);
         } catch (ClassNotFoundException e) {
             throw new ConstructionException("Type class could not be found: " + type);
         }

Added: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MissingAccessorException.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MissingAccessorException.java?view=auto&rev=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MissingAccessorException.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/MissingAccessorException.java Sun Nov 26 14:41:31 2006
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.recipe;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MissingAccessorException extends ConstructionException {
+    private final int matchLevel;
+
+    public MissingAccessorException(String message, int matchLevel) {
+        super(message);
+        this.matchLevel = matchLevel;
+    }
+
+    public int getMatchLevel() {
+        return matchLevel;
+    }
+}

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ObjectRecipe.java Sun Nov 26 14:41:31 2006
@@ -16,19 +16,22 @@
  */
 package org.apache.xbean.recipe;
 
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 import org.apache.xbean.propertyeditor.PropertyEditors;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * @version $Rev: 6688 $ $Date: 2005-12-29T02:08:29.200064Z $
@@ -39,6 +42,7 @@
     private final String[] constructorArgNames;
     private final Class[] constructorArgTypes;
     private final LinkedHashMap properties;
+    private final List options = new ArrayList();
 
     public ObjectRecipe(Class type) {
         this(type.getName());
@@ -101,6 +105,14 @@
         }
     }
 
+    public void allow(Option option){
+        options.add(option);
+    }
+
+    public void disallow(Option option){
+        options.remove(option);
+    }
+
     public Object getProperty(String name) {
         if (name == null) throw new NullPointerException("name is null");
         Object value = properties.get(name);
@@ -134,20 +146,20 @@
         // load the type class
         Class typeClass = null;
         try {
-            typeClass = ClassLoading.loadClass(type, classLoader);
+            typeClass = Class.forName(type, true, classLoader);
         } catch (ClassNotFoundException e) {
             throw new ConstructionException("Type class could not be found: " + type);
         }
 
-        // verify that is is a class we can construct
+        // verify that it is a class we can construct
         if (!Modifier.isPublic(typeClass.getModifiers())) {
-            throw new ConstructionException("Class is not public: " + ClassLoading.getClassName(typeClass, true));
+            throw new ConstructionException("Class is not public: " + Classes.getClassName(typeClass, true));
         }
         if (Modifier.isInterface(typeClass.getModifiers())) {
-            throw new ConstructionException("Class is an interface: " + ClassLoading.getClassName(typeClass, true));
+            throw new ConstructionException("Class is an interface: " + Classes.getClassName(typeClass, true));
         }
         if (Modifier.isAbstract(typeClass.getModifiers())) {
-            throw new ConstructionException("Class is abstract: " + ClassLoading.getClassName(typeClass, true));
+            throw new ConstructionException("Class is abstract: " + Classes.getClassName(typeClass, true));
         }
 
         // get object values for all recipe properties
@@ -170,13 +182,37 @@
             Map.Entry entry = (Map.Entry) iterator.next();
             String propertyName = (String) entry.getKey();
             Object propertyValue = entry.getValue();
-            Method setter = findSetter(typeClass, propertyName, propertyValue);
+
+            MissingAccessorException missingSetter = null;
+            Method setter = null;
             try {
+                setter = findSetter(typeClass, propertyName, propertyValue, options.contains(Option.PRIVATE_PROPERTIES));
                 propertyValue = convert(setter.getParameterTypes()[0], propertyValue);
                 setter.invoke(instance, new Object[]{propertyValue});
+                continue;
+            } catch (MissingAccessorException e) {
+                if (!options.contains(Option.FIELD_INJECTION)){
+                    throw e;
+                }
+                missingSetter = e;
             } catch (Exception e) {
                 throw new ConstructionException("Error setting property: " + setter);
             }
+
+            Field field = null;
+            try {
+                field = findField(typeClass, propertyName, propertyValue, options.contains(Option.PRIVATE_PROPERTIES));
+                propertyValue = convert(field.getType(), propertyValue);
+                field.set(instance, propertyValue);
+            } catch (MissingAccessorException missingField) {
+                if (missingField.getMatchLevel() > missingSetter.getMatchLevel()) {
+                    throw missingField;
+                } else {
+                    throw missingSetter;
+                }
+            } catch (Exception e) {
+                throw new ConstructionException("Error setting property: " + field);
+            }
         }
         return instance;
     }
@@ -194,8 +230,8 @@
                     throw new ConstructionException("Invalid and non-convertable constructor parameter type: " +
                             "name=" + name + ", " +
                             "index=" + i + ", " +
-                            "expected=" + ClassLoading.getClassName(type, true) + ", " +
-                            "actual=" + ClassLoading.getClassName(value, true));
+                            "expected=" + Classes.getClassName(type, true) + ", " +
+                            "actual=" + Classes.getClassName(value, true));
                 }
                 value = convert(type, value);
             } else {
@@ -327,7 +363,7 @@
             }
 
             StringBuffer buffer = new StringBuffer("Unable to find a valid factory method: ");
-            buffer.append("public static Object ").append(ClassLoading.getClassName(typeClass, true)).append(".");
+            buffer.append("public static Object ").append(Classes.getClassName(typeClass, true)).append(".");
             buffer.append(factoryMethod).append(toParameterList(constructorArgTypes));
             throw new ConstructionException(buffer.toString());
         }
@@ -367,12 +403,12 @@
 
             if (matches.size() < 1) {
                 StringBuffer buffer = new StringBuffer("No parameter types supplied; unable to find a potentially valid constructor: ");
-                buffer.append("constructor= public ").append(ClassLoading.getClassName(typeClass, true));
+                buffer.append("constructor= public ").append(Classes.getClassName(typeClass, true));
                 buffer.append(toArgumentList(constructorArgNames));
                 throw new ConstructionException(buffer.toString());
             } else if (matches.size() > 1) {
                 StringBuffer buffer = new StringBuffer("No parameter types supplied; found too many potentially valid constructors: ");
-                buffer.append("constructor= public ").append(ClassLoading.getClassName(typeClass, true));
+                buffer.append("constructor= public ").append(Classes.getClassName(typeClass, true));
                 buffer.append(toArgumentList(constructorArgNames));
                 throw new ConstructionException(buffer.toString());
             }
@@ -403,7 +439,7 @@
             }
 
             StringBuffer buffer = new StringBuffer("Unable to find a valid constructor: ");
-            buffer.append("constructor= public ").append(ClassLoading.getClassName(typeClass, true));
+            buffer.append("constructor= public ").append(Classes.getClassName(typeClass, true));
             buffer.append(toParameterList(constructorArgTypes));
             throw new ConstructionException(buffer.toString());
         }
@@ -415,7 +451,7 @@
         for (int i = 0; i < parameterTypes.length; i++) {
             Class type = parameterTypes[i];
             if (i > 0) buffer.append(", ");
-            buffer.append(ClassLoading.getClassName(type, true));
+            buffer.append(Classes.getClassName(type, true));
         }
         buffer.append(")");
         return buffer.toString();
@@ -433,7 +469,7 @@
         return buffer.toString();
     }
 
-    public static Method findSetter(Class typeClass, String propertyName, Object propertyValue) {
+    public static Method findSetter(Class typeClass, String propertyName, Object propertyValue, boolean allowPrivate) {
         if (propertyName == null) throw new NullPointerException("name is null");
         if (propertyName.length() == 0) throw new IllegalArgumentException("name is an empty string");
 
@@ -442,8 +478,9 @@
             setterName += propertyName.substring(1);
         }
 
+
         int matchLevel = 0;
-        ConstructionException missException = null;
+        MissingAccessorException missException = null;
 
         List methods = new ArrayList(Arrays.asList(typeClass.getMethods()));
         methods.addAll(Arrays.asList(typeClass.getDeclaredMethods()));
@@ -453,7 +490,7 @@
                 if (method.getParameterTypes().length == 0) {
                     if (matchLevel < 1) {
                         matchLevel = 1;
-                        missException = new ConstructionException("Setter takes no parameters: " + method);
+                        missException = new MissingAccessorException("Setter takes no parameters: " + method, matchLevel);
                     }
                     continue;
                 }
@@ -461,7 +498,7 @@
                 if (method.getParameterTypes().length > 1) {
                     if (matchLevel < 1) {
                         matchLevel = 1;
-                        missException = new ConstructionException("Setter takes more then one parameter: " + method);
+                        missException = new MissingAccessorException("Setter takes more then one parameter: " + method, matchLevel);
                     }
                     continue;
                 }
@@ -469,7 +506,7 @@
                 if (method.getReturnType() != Void.TYPE) {
                     if (matchLevel < 2) {
                         matchLevel = 2;
-                        missException = new ConstructionException("Setter returns a value: " + method);
+                        missException = new MissingAccessorException("Setter returns a value: " + method, matchLevel);
                     }
                     continue;
                 }
@@ -477,15 +514,15 @@
                 if (Modifier.isAbstract(method.getModifiers())) {
                     if (matchLevel < 3) {
                         matchLevel = 3;
-                        missException = new ConstructionException("Setter is abstract: " + method);
+                        missException = new MissingAccessorException("Setter is abstract: " + method, matchLevel);
                     }
                     continue;
                 }
 
-                if (!Modifier.isPublic(method.getModifiers())) {
+                if (!allowPrivate && !Modifier.isPublic(method.getModifiers())) {
                     if (matchLevel < 4) {
                         matchLevel = 4;
-                        missException = new ConstructionException("Setter is not public: " + method);
+                        missException = new MissingAccessorException("Setter is not public: " + method, matchLevel);
                     }
                     continue;
                 }
@@ -493,7 +530,7 @@
                 if (Modifier.isStatic(method.getModifiers())) {
                     if (matchLevel < 4) {
                         matchLevel = 4;
-                        missException = new ConstructionException("Setter is static: " + method);
+                        missException = new MissingAccessorException("Setter is static: " + method, matchLevel);
                     }
                     continue;
                 }
@@ -502,8 +539,8 @@
                 if (methodParameterType.isPrimitive() && propertyValue == null) {
                     if (matchLevel < 6) {
                         matchLevel = 6;
-                        missException = new ConstructionException("Null can not be assigned to " +
-                                ClassLoading.getClassName(methodParameterType, true) + ": " + method);
+                        missException = new MissingAccessorException("Null can not be assigned to " +
+                                Classes.getClassName(methodParameterType, true) + ": " + method, matchLevel);
                     }
                     continue;
                 }
@@ -512,11 +549,16 @@
                 if (!isInstance(methodParameterType, propertyValue) && !isConvertable(methodParameterType, propertyValue)) {
                     if (matchLevel < 5) {
                         matchLevel = 5;
-                        missException = new ConstructionException(ClassLoading.getClassName(propertyValue, true) + " can not be assigned or converted to " +
-                                ClassLoading.getClassName(methodParameterType, true) + ": " + method);
+                        missException = new MissingAccessorException(Classes.getClassName(propertyValue, true) + " can not be assigned or converted to " +
+                                Classes.getClassName(methodParameterType, true) + ": " + method, matchLevel);
                     }
                     continue;
                 }
+
+                if (allowPrivate && !Modifier.isPublic(method.getModifiers())) {
+                    setAccessible(method);
+                }
+
                 return method;
             }
 
@@ -526,9 +568,82 @@
             throw missException;
         } else {
             StringBuffer buffer = new StringBuffer("Unable to find a valid setter method: ");
-            buffer.append("public void ").append(ClassLoading.getClassName(typeClass, true)).append(".");
-            buffer.append(setterName).append("(").append(ClassLoading.getClassName(propertyValue, true)).append(")");
-            throw new ConstructionException(buffer.toString());
+            buffer.append("public void ").append(Classes.getClassName(typeClass, true)).append(".");
+            buffer.append(setterName).append("(").append(Classes.getClassName(propertyValue, true)).append(")");
+            throw new MissingAccessorException(buffer.toString(), -1);
+        }
+    }
+
+    public static Field findField(Class typeClass, String propertyName, Object propertyValue, boolean allowPrivate) {
+        if (propertyName == null) throw new NullPointerException("name is null");
+        if (propertyName.length() == 0) throw new IllegalArgumentException("name is an empty string");
+
+        int matchLevel = 0;
+        MissingAccessorException missException = null;
+
+        List fields = new ArrayList(Arrays.asList(typeClass.getDeclaredFields()));
+        Class parent = typeClass.getSuperclass();
+        while (parent != null){
+            fields.addAll(Arrays.asList(parent.getDeclaredFields()));
+            parent = parent.getSuperclass();
+        }
+
+        for (Iterator iterator = fields.iterator(); iterator.hasNext();) {
+            Field field = (Field) iterator.next();
+            if (field.getName().equals(propertyName)) {
+
+                if (!allowPrivate && !Modifier.isPublic(field.getModifiers())) {
+                    if (matchLevel < 4) {
+                        matchLevel = 4;
+                        missException = new MissingAccessorException("Field is not public: " + field, matchLevel);
+                    }
+                    continue;
+                }
+
+                if (Modifier.isStatic(field.getModifiers())) {
+                    if (matchLevel < 4) {
+                        matchLevel = 4;
+                        missException = new MissingAccessorException("Field is static: " + field, matchLevel);
+                    }
+                    continue;
+                }
+
+                Class fieldType = field.getType();
+                if (fieldType.isPrimitive() && propertyValue == null) {
+                    if (matchLevel < 6) {
+                        matchLevel = 6;
+                        missException = new MissingAccessorException("Null can not be assigned to " +
+                                Classes.getClassName(fieldType, true) + ": " + field, matchLevel);
+                    }
+                    continue;
+                }
+
+
+                if (!isInstance(fieldType, propertyValue) && !isConvertable(fieldType, propertyValue)) {
+                    if (matchLevel < 5) {
+                        matchLevel = 5;
+                        missException = new MissingAccessorException(Classes.getClassName(propertyValue, true) + " can not be assigned or converted to " +
+                                Classes.getClassName(fieldType, true) + ": " + field, matchLevel);
+                    }
+                    continue;
+                }
+
+                if (allowPrivate && !Modifier.isPublic(field.getModifiers())) {
+                    setAccessible(field);
+                }
+
+                return field;
+            }
+
+        }
+
+        if (missException != null) {
+            throw missException;
+        } else {
+            StringBuffer buffer = new StringBuffer("Unable to find a valid field: ");
+            buffer.append("public ").append(" ").append(Classes.getClassName(propertyValue, true));
+            buffer.append(" ").append(propertyName).append(";");
+            throw new MissingAccessorException(buffer.toString(), -1);
         }
     }
 
@@ -607,5 +722,23 @@
             }
         }
         return true;
+    }
+
+    private static void setAccessible(final Method method) {
+        AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                method.setAccessible(true);
+                return null;
+            }
+        });
+    }
+
+    private static void setAccessible(final Field field) {
+        AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                field.setAccessible(true);
+                return null;
+            }
+        });
     }
 }

Added: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/Option.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/Option.java?view=auto&rev=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/Option.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/Option.java Sun Nov 26 14:41:31 2006
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.recipe;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Option {
+
+    public static final Option PRIVATE_PROPERTIES = new Option("PRIVATE_PROPERTIES");
+    public static final Option FIELD_INJECTION = new Option("FIELD_INJECTION"); 
+
+    private final String name;
+
+    public Option(String name) {
+        this.name = name;
+    }
+
+    public String toString() {
+        return name;
+    }
+}

Modified: geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ValueRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ValueRecipe.java?view=diff&rev=479435&r1=479434&r2=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ValueRecipe.java (original)
+++ geronimo/xbean/trunk/xbean-reflect/src/main/java/org/apache/xbean/recipe/ValueRecipe.java Sun Nov 26 14:41:31 2006
@@ -18,7 +18,7 @@
 
 import org.apache.xbean.propertyeditor.PropertyEditors;
 import org.apache.xbean.propertyeditor.PropertyEditorException;
-import org.apache.xbean.ClassLoading;
+import org.apache.xbean.Classes;
 
 
 /**
@@ -31,7 +31,7 @@
     public ValueRecipe(Class type, String value) {
         if (type == null) throw new NullPointerException("type is null");
         if (!PropertyEditors.canConvert(type)) {
-            throw new IllegalArgumentException("No converter available for " + ClassLoading.getClassName(type));
+            throw new IllegalArgumentException("No converter available for " + Classes.getClassName(type));
         }
         this.type = type.getName();
         this.value = value;

Added: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/MixedRecipeTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/MixedRecipeTest.java?view=auto&rev=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/MixedRecipeTest.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/MixedRecipeTest.java Sun Nov 26 14:41:31 2006
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.recipe;
+
+import junit.framework.TestCase;
+import org.apache.xbean.propertyeditor.PropertyEditors;
+
+import java.net.URL;
+
+public class MixedRecipeTest extends TestCase {
+
+    protected void setUp() throws Exception {
+        PropertyEditors.class.getName();
+    }
+
+    public void testAll() throws Exception {
+        Widget expected = new Widget("uno", 2, true, "quatro", Object.class, "seis");
+
+        ObjectRecipe objectRecipe = new ObjectRecipe(Widget.class, new String[]{"one", "two"}, new Class[]{String.class, int.class});
+        objectRecipe.allow(Option.PRIVATE_PROPERTIES);
+        objectRecipe.allow(Option.FIELD_INJECTION);
+        objectRecipe.setProperty("one", "uno");
+        objectRecipe.setProperty("two", "2");
+        objectRecipe.setProperty("three", "true");
+        objectRecipe.setProperty("four", "quatro");
+        objectRecipe.setProperty("five", "java.lang.Object");
+        objectRecipe.setProperty("six", "seis");
+
+        Widget actual = (Widget) objectRecipe.create(Widget.class.getClassLoader());
+        assertEquals("widget", expected, actual);
+    }
+
+}

Added: geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Widget.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Widget.java?view=auto&rev=479435
==============================================================================
--- geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Widget.java (added)
+++ geronimo/xbean/trunk/xbean-reflect/src/test/java/org/apache/xbean/recipe/Widget.java Sun Nov 26 14:41:31 2006
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.recipe;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Widget {
+
+    private final String one;
+    private final int two;
+    private boolean three;
+    private String four;
+    private Class five;
+    public String six;
+
+    public Widget(String one, int two, boolean three, String four, Class five, String six) {
+        this.five = five;
+        this.four = four;
+        this.one = one;
+        this.six = six;
+        this.three = three;
+        this.two = two;
+    }
+
+    public Widget(String one, int two) {
+        this.one = one;
+        this.two = two;
+    }
+
+    public void setThree(boolean three) {
+        this.three = three;
+    }
+
+    private void setFour(String four) {
+        this.four = four;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final Widget widget = (Widget) o;
+
+        if (three != widget.three) return false;
+        if (two != widget.two) return false;
+        if (five != null ? !five.equals(widget.five) : widget.five != null) return false;
+        if (four != null ? !four.equals(widget.four) : widget.four != null) return false;
+        if (one != null ? !one.equals(widget.one) : widget.one != null) return false;
+        if (six != null ? !six.equals(widget.six) : widget.six != null) return false;
+
+        return true;
+    }
+}



Mime
View raw message