Introduction
For maximum efficiency, GWT compiles your Java source into a monolithic script. Now gwt-ent provide a reflection implement by gwt code generator mechanism.
This Framework support
- Class http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/ClassType.java
- Field http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/Field.java
- Method http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/Method.java
- Constructor http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/Constructor.java
- Metedata http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/HasMetaData.java
- Annotation http://code.google.com/p/gwt-ent/source/browse/trunk/gwtent/src/main/java/com/gwtent/reflection/client/HasAnnotations.java
How to use
# add Annotation Or Reflection Marker interface into your pojo class
@Reflectable public class TestReflection{ } public class TestReflection implements Reflection{ } @Reflect_Domain public class TestReflection{ }
# get ClassType.
ClassType classType = TypeOracle.Instance.getClassType(TestReflection.class);
For example:
public void testReflection(){ TestReflection test = new TestReflection(); ClassType classType = TypeOracle.Instance.getClassType(TestReflection.class); test.setString("set by code"); System.out.println("after SetByCode:" + test.getString()); System.out.println("after SetByCode:" + classType.invoke(test, "getString", null)); classType.invoke(test, "setString", new Object[]{"set by invoke"}); System.out.println("after SetByInvoke:" + classType.invoke(test, "getString", null)); } }
The output is :
after SetByCode:set by code after SetByCode:set by code after SetByInvoke:set by invoke
Control you javascript size
GWTENT provide you more power to control how much reflection information created.
The Class Scope
You can control whether have:
- Class Annotation
- Fields
- Methods
- Constructors
- Field and Method Annotations
- Relation Types(The field type, the return type of method, the type of Parameters)
- Super Classes ( all the super classes of this class will generate reflection information)
- Assignable Classes (all assignable classes. if annotate to a class, this is mean All subClasses will generate reflection information; if annotate to a interface, then all implement classes will generate reflection information; if annotate to an annotation, then all types annotated by this annotation will generate reflection information)
Click Here For more Information
The Field/Method Scope
You can control whether have:
- Annotations
- Field Type
- Method Return Type
- Method Parameter Type
Click Here For more Information