org.formaria.aria.data
Class RegisteredDataBindingFactory

java.lang.Object
  extended by org.formaria.aria.data.DataBindingFactory
      extended by org.formaria.aria.data.RegisteredDataBindingFactory

public class RegisteredDataBindingFactory
extends DataBindingFactory

A data binding factory that loads a specification of data bindings from an XML configuration file

Copyright (c) Formaria Ltd., 2008. See license.txt for licensing details


Field Summary
protected  java.util.ArrayList[] bindingRegisters
          The register of binding adapters for each component type
protected static int changeCounter
          A counter for changes to the registry.
static int CLASS_MATCH
          Match bindings based on the target component class name
protected static java.util.Hashtable configFiles
          The config files used to build the set of component adapters.
static int INSPECTOR_MATCH
          Match bindings based on the results of a user defined comparison
static int INSTANCE_MATCH
          Match bindings based on inheritance from a particular class
static int INTERFACE_MATCH
          Match bindings based on implementation of a particular interface
protected  int localChangeCounter
          Used for tracking changes to the registry spec.
 
Fields inherited from class org.formaria.aria.data.DataBindingFactory
evaluator
 
Method Summary
protected  void addBindingTypes(XmlElement regRoot, int mode)
          Read the component registry.
static void addConfigFile(java.lang.String key, java.lang.Object resource, boolean overwrite)
          Add a configuration file.
 void checkRegistration()
          Check that all the registered components are loaded
protected  void doRead(java.lang.String key, java.lang.Object configFile)
          Read the component registry.
protected  void doRead(java.lang.String key, java.lang.String configFile)
          Read the component registry.
protected  void doRead(java.lang.String key, java.net.URL configFileURL)
          Read the component registry.
 DataBinding getBinding(PageSupport page, java.lang.Object comp, java.util.Hashtable instanceConfig)
          Try to get a binding factory to construct the binding
protected  void read()
          Read the component registry.
 void read(java.lang.String key, java.io.Reader reader)
          Read the component registry.
protected  void read(java.lang.String key, java.lang.String configFile)
          Read the component registry.
static void register(Project currentProject)
          Register an instance of this binding factory.
 void updateConfig()
          Signal that the configuration has been updated.
 
Methods inherited from class org.formaria.aria.data.DataBindingFactory
getEvaluatedAttribute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_MATCH

public static final int CLASS_MATCH
Match bindings based on the target component class name

See Also:
Constant Field Values

INTERFACE_MATCH

public static final int INTERFACE_MATCH
Match bindings based on implementation of a particular interface

See Also:
Constant Field Values

INSTANCE_MATCH

public static final int INSTANCE_MATCH
Match bindings based on inheritance from a particular class

See Also:
Constant Field Values

INSPECTOR_MATCH

public static final int INSPECTOR_MATCH
Match bindings based on the results of a user defined comparison

See Also:
Constant Field Values

bindingRegisters

protected java.util.ArrayList[] bindingRegisters
The register of binding adapters for each component type


configFiles

protected static java.util.Hashtable configFiles
The config files used to build the set of component adapters. Stores the file names


changeCounter

protected static int changeCounter
A counter for changes to the registry. Used to indicate if the registry needs to be rebuilt


localChangeCounter

protected int localChangeCounter
Used for tracking changes to the registry spec.

Method Detail

register

public static void register(Project currentProject)
Register an instance of this binding factory.

Parameters:
currentProject - the owner project

getBinding

public DataBinding getBinding(PageSupport page,
                              java.lang.Object comp,
                              java.util.Hashtable instanceConfig)
Try to get a binding factory to construct the binding

Specified by:
getBinding in class DataBindingFactory
Parameters:
page - the page that will own the binding
comp - the target component
instanceConfig - the attributes of the binding instance
Returns:
the new binding if one could be constructed

addConfigFile

public static void addConfigFile(java.lang.String key,
                                 java.lang.Object resource,
                                 boolean overwrite)
Add a configuration file. If the files have already been loaded then the new file will be loaded

Parameters:
key - the name by which the configuration file is referenced
resource - the name/path of the configuration file or the URL for the file
overwrite - true to overwrite and existing entry matching the specified key

updateConfig

public void updateConfig()
Signal that the configuration has been updated.


read

protected void read()
Read the component registry. The format is described in the components.xsd schema.


read

protected void read(java.lang.String key,
                    java.lang.String configFile)
Read the component registry. The format is described in the components.xsd schema. The config file is also registered.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.lang.Object configFile)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.lang.String configFile)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFile - the name of the configuration file
key - the name by which the configuration file is referenced

doRead

protected void doRead(java.lang.String key,
                      java.net.URL configFileURL)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
configFileURL - the URL of the configuration file
key - the name by which the configuration file is referenced

read

public void read(java.lang.String key,
                 java.io.Reader reader)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
key - the name by which the configuration file is referenced
reader - the reader from which to read the file

addBindingTypes

protected void addBindingTypes(XmlElement regRoot,
                               int mode)
Read the component registry. The format is described in the components.xsd schema.

Parameters:
regRoot - the name by which the configuration file is referenced
mode - the match mode for the new binding types

checkRegistration

public void checkRegistration()
Check that all the registered components are loaded