On Nov 29, 2006, at 10:34 AM, Mohammad Nour El-Din wrote:

Hi DBlevins...


On 11/28/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Author: dblevins
Date: Tue Nov 28 11:21:18 2006
New Revision: 480161

URL: http://svn.apache.org/viewvc?view=rev&rev=480161
Log:
Added check for annotated fields and to ensure fields are public


Why public fields only !!?? @see EJB3.0 "Core Contracts and Requirements",
section 16.2.2

This is not related to the EJB spec. It's our internal tree that holds server configuration data.

http://people.apache.org/~dblevins/tmp/openejb/design_configfactory.html

-David

Modified:

incubator/openejb/trunk/openejb3/container/openejb-core/src/test/ java/org/apache/openejb/assembler/classic/ OpenEjbConfigurationValidationTest.java

Modified:
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/ java/org/apache/openejb/assembler/classic/ OpenEjbConfigurationValidationTest.java
URL:
http://svn.apache.org/viewvc/incubator/openejb/trunk/openejb3/ container/openejb-core/src/test/java/org/apache/openejb/assembler/ classic/OpenEjbConfigurationValidationTest.java? view=diff&rev=480161&r1=480160&r2=480161

===================================================================== =========
---
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/ java/org/apache/openejb/assembler/classic/ OpenEjbConfigurationValidationTest.java
(original)
+++
incubator/openejb/trunk/openejb3/container/openejb-core/src/test/ java/org/apache/openejb/assembler/classic/ OpenEjbConfigurationValidationTest.java
Tue Nov 28 11:21:18 2006
@@ -22,6 +22,7 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -62,6 +63,12 @@

        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
+
+ assertTrue("Non-public fields are not allowed: " + simpleName
+ "." + field.getName(), Modifier.isPublic(field.getModifiers()));
+
+            annotations = clazz.getDeclaredAnnotations();
+ assertEquals("annotations are not allowed: " + simpleName +
"." + field.getName(), 0, annotations.length);
+
            Class type = field.getType();
            if (type.isArray()) {
                type = type.getComponentType();
@@ -69,27 +76,27 @@

            if (List.class.isAssignableFrom(type)) {
                type = getGenericType(field);
-                assertNotNull("Lists must have a generic type:
"+simpleName+"."+field.getName(), type);
+                assertNotNull("Lists must have a generic type: " +
simpleName + "." + field.getName(), type);
            }

            if (type.isPrimitive()) {
                continue;
            }

-            if (String.class.isAssignableFrom(type)){
+            if (String.class.isAssignableFrom(type)) {
                continue;
            }

-            if (Properties.class.isAssignableFrom(type)){
+            if (Properties.class.isAssignableFrom(type)) {
                continue;
            }

-            if (InfoObject.class.isAssignableFrom(type)){
+            if (InfoObject.class.isAssignableFrom(type)) {
                validate(type);
                continue;
            }

-            fail("Field is not of an allowed type:
"+simpleName+"."+field.getName());
+ fail("Field is not of an allowed type: " + simpleName + "." +
field.getName());
        }
    }

@@ -104,6 +111,6 @@
            return (Class) genericType;
        } else {
            return null;
-       }
+        }
    }
}





--
Thanks
- Mohammad Nour

Reply via email to