public abstract class BeanFactory<BeanClass>
extends java.lang.Object
Subclasses must be generated for each Class
you want to use. To trigger
the generation of subclasses, see the documentation on
registering classes for reflection
.
Once the appropriate subclass has been created, you can use the class via the static methods.
For the moment, this class only works with subclasses of
BaseWidget
or
FormItem
.
Modifier and Type | Class and Description |
---|---|
static interface |
BeanFactory.AnnotationMetaFactory |
static interface |
BeanFactory.CanvasMetaFactory
Interface used to trigger the generation and registration of reflection
metadata for
Canvas and all
its subclasses found in the classpath (including your custom subclasses). |
static interface |
BeanFactory.FormItemMetaFactory
Interface used to trigger the generation and registration of reflection
metadata for
FormItem and
all its subclasses found in the classpath (including your custom subclasses). |
static interface |
BeanFactory.FrameworkClass |
static interface |
BeanFactory.Generate
Annotation which will trigger the generation of BeanFactories.
|
static interface |
BeanFactory.MetaFactory
An interface which you can extend in order to register classes
with the
BeanFactory reflection mechanism. |
static interface |
BeanFactory.ScClassName |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,BeanProperty<BeanClass>> |
properties |
protected JavaScriptObject |
sgwtFactory |
protected BeanFactory |
superclassFactory |
Modifier | Constructor and Description |
---|---|
protected |
BeanFactory()
The constructor is protected because you should not create BeanFactory
instances directly.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
applyFactoryProperties(BeanClass bean) |
static void |
clearFactoryProperties() |
protected BeanFactory<?> |
createSuperclassFactory() |
abstract JavaScriptObject |
doGetOrCreateJsObj(java.lang.Object bean) |
java.lang.Object |
doGetProperty(java.lang.Object bean,
java.lang.String propertyName) |
java.lang.String |
doGetPropertyAsString(java.lang.Object bean,
java.lang.String propertyName) |
protected abstract BeanClass |
doNewInstance() |
abstract void |
doSetJsObj(java.lang.Object bean,
JavaScriptObject jsObj) |
void |
doSetProperties(java.lang.Object bean,
java.util.Map<java.lang.String,java.lang.Object> properties) |
void |
doSetProperty(java.lang.Object bean,
java.lang.String propertyName,
java.lang.Object value) |
java.lang.String[] |
getAttributes() |
static java.lang.String[] |
getAttributes(java.lang.Class<?> beanClass)
Gets an array of the names of the properties of a class.
|
static java.lang.String[] |
getAttributes(java.lang.String beanClassName)
Gets an array of the names of the properties of a class.
|
abstract java.lang.Class<BeanClass> |
getBeanClass() |
java.lang.String |
getBeanClassName() |
java.lang.String |
getDefaultScClassName() |
static java.lang.String |
getDefaultScClassName(java.lang.Class<?> beanClass)
Gets the default scClassName for the class.
|
static BeanFactory<?> |
getFactory(java.lang.Class<?> klass) |
static BeanFactory<?> |
getFactory(java.lang.Object object) |
static BeanFactory<?> |
getFactory(java.lang.String className) |
static java.util.Map<java.lang.String,java.lang.Object> |
getFactoryProperties() |
static java.lang.Class<?> |
getFactoryPropertiesClass() |
protected abstract java.lang.Object |
getJavascriptProperty(BeanClass bean,
java.lang.String propertyName) |
protected abstract JsArray<JavaScriptObject> |
getMethods() |
static JavaScriptObject |
getOrCreateJsObj(java.lang.Object bean) |
protected abstract BeanProperty<BeanClass>[] |
getProperties(JsArray<JavaScriptObject> methods) |
static java.lang.Object |
getProperty(java.lang.Object bean,
java.lang.String property)
Gets a property of a bean.
|
static java.lang.String |
getPropertyAsString(java.lang.Object bean,
java.lang.String property)
Gets a property of a bean as a String.
|
static JavaScriptObject |
getSGWTModule() |
protected java.lang.Class |
getSuperclass() |
abstract boolean |
isFactoryCreated(BeanClass bean) |
boolean |
isFrameworkClass() |
static boolean |
isFrameworkClass(java.lang.Class<?> beanClass)
Indicates whether the class is defined by the SmartGWT framework.
|
BeanClass |
newInstance() |
static java.lang.Object |
newInstance(java.lang.Class<?> klass)
Create an instance based on the provided class object.
|
static java.lang.Object |
newInstance(java.lang.Class<?> klass,
JavaScriptObject properties)
Create an instance based on the provided class object, and apply the
provided properties to it.
|
static java.lang.Object |
newInstance(java.lang.Class<?> klass,
java.util.Map<java.lang.String,java.lang.Object> properties)
Create an instance based on the provided class object, and apply the
provided properties to it.
|
BeanClass |
newInstance(JavaScriptObject properties) |
BeanClass |
newInstance(java.util.Map<java.lang.String,java.lang.Object> properties) |
static java.lang.Object |
newInstance(java.lang.String className)
Create an instance based on the provided class name.
|
static java.lang.Object |
newInstance(java.lang.String className,
JavaScriptObject properties)
Create an instance based on the provided class name, and apply the
provided properties to it.
|
static java.lang.Object |
newInstance(java.lang.String className,
java.util.Map<java.lang.String,java.lang.Object> properties)
Create an instance based on the provided class name, and apply the
provided properties to it.
|
protected static java.lang.IllegalStateException |
noFactoryException(java.lang.Class<?> klass) |
protected static java.lang.IllegalStateException |
noFactoryException(java.lang.String name) |
void |
registerClassNameWithSGWTFactory() |
protected static void |
registerFactory(BeanFactory<?> factory) |
protected abstract void |
registerValueTypes() |
protected abstract void |
setJavascriptProperty(BeanClass bean,
java.lang.String propertyName,
java.lang.Object value) |
static void |
setJsObj(java.lang.Object bean,
JavaScriptObject jsObj) |
static void |
setProperties(java.lang.Object bean,
java.util.Map<java.lang.String,java.lang.Object> properties)
Applies a Map of property names and values to a bean.
|
static void |
setProperty(java.lang.Object bean,
java.lang.String property,
java.lang.Object value)
Sets a property of a bean to a value.
|
protected void |
triggerStaticInitializers() |
protected BeanFactory superclassFactory
protected java.util.Map<java.lang.String,BeanProperty<BeanClass>> properties
protected JavaScriptObject sgwtFactory
protected BeanFactory()
BeanFactory.MetaFactory
,
BeanFactory.CanvasMetaFactory
or BeanFactory.FormItemMetaFactory
to create bean factories, and then use the static methods on
BeanFactory.public static JavaScriptObject getSGWTModule()
public static java.util.Map<java.lang.String,java.lang.Object> getFactoryProperties()
public static void clearFactoryProperties()
public static java.lang.Class<?> getFactoryPropertiesClass()
public static BeanFactory<?> getFactory(java.lang.String className)
public static BeanFactory<?> getFactory(java.lang.Class<?> klass)
public static BeanFactory<?> getFactory(java.lang.Object object)
protected static void registerFactory(BeanFactory<?> factory)
protected static java.lang.IllegalStateException noFactoryException(java.lang.String name)
protected static java.lang.IllegalStateException noFactoryException(java.lang.Class<?> klass)
public static java.lang.Object newInstance(java.lang.String className)
className
- the class namejava.lang.IllegalStateException
- If no factory has been generated for the classNamepublic static java.lang.Object newInstance(java.lang.Class<?> klass)
klass
- the class objectjava.lang.IllegalStateException
- If no factory has been generated for the klasspublic static java.lang.Object newInstance(java.lang.String className, JavaScriptObject properties)
className
- the class nameproperties
- a JavaScriptObject whose key/value pairs represent
property names and valuesjava.lang.IllegalStateException
- If no factory has been generated for the classNamepublic static java.lang.Object newInstance(java.lang.Class<?> klass, JavaScriptObject properties)
klass
- the class objectproperties
- a JavaScriptObject whose key/value pairs represent
property names and valuesjava.lang.IllegalStateException
- If no factory has been generated for the classpublic static java.lang.Object newInstance(java.lang.String className, java.util.Map<java.lang.String,java.lang.Object> properties)
className
- the class nameproperties
- a Map whose key/value pairs represent
property names and valuesjava.lang.IllegalStateException
- If no factory has been generated for the classNamepublic static java.lang.Object newInstance(java.lang.Class<?> klass, java.util.Map<java.lang.String,java.lang.Object> properties)
klass
- the class objectproperties
- a Map whose key/value pairs represent
property names and valuesjava.lang.IllegalStateException
- If no factory has been generated for the classpublic static void setProperty(java.lang.Object bean, java.lang.String property, java.lang.Object value)
bean
- The object whose property is to be setproperty
- The name of the propertyvalue
- The value to setjava.lang.IllegalStateException
- If no factory has been generated for the bean's classjava.lang.IllegalArgumentException
- If there is no appropriate setter for the valuepublic static void setProperties(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> properties)
bean
- The object whose properties are to be setproperties
- A Map whose key/value pairs represent property names and valuesjava.lang.IllegalStateException
- If no factory has been generated for the bean's classjava.lang.IllegalArgumentException
- If there is no appropriate setter for a valuepublic static java.lang.Object getProperty(java.lang.Object bean, java.lang.String property)
bean
- The object whose property to getproperty
- The name of the propertyjava.lang.IllegalStateException
- If no factory has been generated for the bean's classpublic static java.lang.String getPropertyAsString(java.lang.Object bean, java.lang.String property)
bean
- The object whose property to getproperty
- The name of the propertyjava.lang.IllegalStateException
- If no factory has been generated for the bean's classpublic static java.lang.String[] getAttributes(java.lang.String beanClassName)
beanClassName
- The name of the classjava.lang.IllegalStateException
- If no factory has been generated for the classpublic static java.lang.String[] getAttributes(java.lang.Class<?> beanClass)
beanClass
- The klass objectjava.lang.IllegalStateException
- If no factory has been generated for the classpublic static JavaScriptObject getOrCreateJsObj(java.lang.Object bean)
public static void setJsObj(java.lang.Object bean, JavaScriptObject jsObj)
public static boolean isFrameworkClass(java.lang.Class<?> beanClass)
beanClass
- The Class objectjava.lang.IllegalStateException
- If no factory has been generated for the classpublic static java.lang.String getDefaultScClassName(java.lang.Class<?> beanClass)
beanClass
- The Class objectjava.lang.IllegalStateException
- If no factory has been generated for the classprotected java.lang.Class getSuperclass()
protected BeanFactory<?> createSuperclassFactory()
protected abstract void registerValueTypes()
protected abstract JsArray<JavaScriptObject> getMethods()
protected abstract BeanProperty<BeanClass>[] getProperties(JsArray<JavaScriptObject> methods)
public void registerClassNameWithSGWTFactory()
public abstract java.lang.Class<BeanClass> getBeanClass()
public java.lang.String getBeanClassName()
protected abstract BeanClass doNewInstance()
public BeanClass newInstance()
public BeanClass newInstance(JavaScriptObject properties)
public BeanClass newInstance(java.util.Map<java.lang.String,java.lang.Object> properties)
protected void triggerStaticInitializers()
public void doSetProperty(java.lang.Object bean, java.lang.String propertyName, java.lang.Object value)
public void doSetProperties(java.lang.Object bean, java.util.Map<java.lang.String,java.lang.Object> properties)
public java.lang.String[] getAttributes()
public java.lang.Object doGetProperty(java.lang.Object bean, java.lang.String propertyName)
public java.lang.String doGetPropertyAsString(java.lang.Object bean, java.lang.String propertyName)
protected abstract void setJavascriptProperty(BeanClass bean, java.lang.String propertyName, java.lang.Object value)
protected abstract java.lang.Object getJavascriptProperty(BeanClass bean, java.lang.String propertyName)
public abstract JavaScriptObject doGetOrCreateJsObj(java.lang.Object bean)
public abstract void doSetJsObj(java.lang.Object bean, JavaScriptObject jsObj)
public abstract boolean isFactoryCreated(BeanClass bean)
protected abstract void applyFactoryProperties(BeanClass bean)
public boolean isFrameworkClass()
public java.lang.String getDefaultScClassName()