com.smartgwt.client.docs

## Interface Reflection

-     public interface Reflection

  ### Registering Classes for Reflection

  In order to specify a SmartGWT class as a constructor in `Component XML` or `Component Schema`, or for other purposes, such as for `autoChildren` or for `DataSourceField.setEditorType(Class)`, you must first register the class with the `BeanFactory` reflection mechanism. You can do this in `onModuleLoad()`, or at some later point before the constructor is used.

  If you want to register `Canvas` and all its subclasses found in the classpath (including your custom subclasses), you can use the `BeanFactory.CanvasMetaFactory` interface to do this automatically:

  >       GWT.create(BeanFactory.CanvasMetaFactory.class);

  Similarly, to register `FormItem` and all its subclasses found in the classpath (including your custom subclasses), you can use the `BeanFactory.FormItemMetaFactory`.

  >       GWT.create(BeanFactory.FormItemMetaFactory.class);

  Alternatively, if only specific classes need to be instantiated and configured dynamically, you can register just those classes by using the `BeanFactory.MetaFactory` interface instead. Usage is most easily explained with an example. First, you define an interface. (Note that it can be an inner interface.)

  >       public interface MyMetaFactory extends BeanFactory.MetaFactory {
  >           BeanFactory<ListGrid> getListGridFactory();
  >           BeanFactory<TileGrid> getTileGridBeanFactory();
  >       }

  ... and then you trigger the generation process:

  >       GWT.create(MyMetaFactory.class);

  Each function in the interface you define will result in the creation of one registered `BeanFactory` ... so, in this case, we would end up with bean factories for `ListGrid` and `TileGrid`. The rules are as follows:

  1. The interface must extend `BeanFactory.MetaFactory`
  2. The return type for each function must be `BeanFactory`, with a generic type that is the class you want to register for reflection.
  3. The function must take no arguments.
  4. The name of the function doesn't matter.

  If there are only a limited number of classes which require dynamic configuration, it will save code size to use the `BeanFactory.MetaFactory` interface to generate factories for those specific types, rather than using `BeanFactory.CanvasMetaFactory` or `BeanFactory.FormItemMetaFactory`. Once a factory is generated for a class, GWT's opportunities to prune dead code are more limited for that class, since it cannot know what properties will be set or retrieved at run-time.