com.smartgwt.client.bean

## Interface BeanFactory.MetaFactory

- Enclosing class:
    BeanFactory<BeanClass>

      public static interface BeanFactory.MetaFactory

  An interface which you can extend in order to register classes with the `BeanFactory` reflection mechanism.

  Note: While this mechanism continues to work, there is now an easier way to register classes for reflection, by annotating them with the `BeanFactory.Generate` annotation.

  In order to use a `BeanFactory` for a class, you need to register it by generating a `BeanFactory` subclass for the class. You can use `BeanFactory.CanvasMetaFactory` to scan the class path and register every `Canvas` subclass (including your custom subclasses), or use `BeanFactory.FormItemMetaFactory` to regiser every `FormItem` subclass. However, if you know that you only need to register some classes for reflection, then you can use `BeanFactory.MetaFactory` instead (or, even more conveniently, the `BeanFactory.Generate` annotation).

  Usage of `BeanFactory.MetaFactory` 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 `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 the factory for.
  3. The function must take no arguments.
  4. The name of the function doesn't matter.

  If you want, you can keep a reference to the results of the `GWT.create()`, and call the functions:

  >      MyMetaFactory metaFactory = GWT.create(MyMetaFactory.class);
  >      BeanFactory<TileGrid> myTileGridFactory = myMetaFactory.getTileGridBeanFactory();

  However, you don't have to do that ... you can ignore the results of `GWT.create()` and just use the `BeanFactory` static API:

  >      GWT.create(MyMetaFactory.class);
  >      Object myGrid = BeanFactory.newInstance("TileGrid");
  >      BeanFactory.setProperty(myGrid, "width", 207);

  ... except that "TileGrid" would probably be a variable!

  You can also use the generated classes in `ComponentXML`, by specifying the fully-qualified class name as the constructor for objects.

  Note that the call to `GWT.create()` must occur at run-time before the factories are used. However, you can modularize by creating some factories first and other factories later, as long as each factory is created before being used.

  See Also:
    `BeanFactory.Generate`