pt.ist.fenixframework
Class Config

Package class diagram package Config
java.lang.Object
  extended by pt.ist.fenixframework.Config
Direct Known Subclasses:
FFDAPConfig

public abstract class Config
extends Object

An instance of the Config class bundles together the initialization parameters used by the Fenix Framework. Therefore, before initializing the framework (via the call to the FenixFramework.initialize(Config) method), the programmer should create an instance of Config with the correct values for each of the parameters.

No constructor is provided for this class (other than the default constructor), because the Config class has several parameters, some of which are optional. But, whereas optional parameters do not need to be specified, the parameters that are required must be specified by the programmer before calling the FenixFramework.initialize(Config) method.

Additional configuration parameters may be added by subclassing this class. Subclasses of config can override the init() method. Typically, their own init() should also call super#init() if an hierarchy of configs is used.

To create an instance of this class with the proper values for its parameters, programmers should generally use code like this (assuming one specific backend as an example):

 
 Config config = new MemConfig() { // any subclass of Config should be ok
     {
        this.domainModelURLs = resourceToURLArray("path/to/domain.dml");
        this.appName = "MyAppName";
     }
 };
 
 
Note that the Config takes an array of URLs for the domainModelURLs. Utility methods are provided in this class to convert from other typical representations to their corresponding URL. All of the utility method return the required URL[]. Here are some guidelines: Note the use of the double
 { {} }
 
to delimit an instance initializer block for the anonymous inner class being created. Each of the parameters of the Config class is represented as a protected class field. Look at the documentation of each field to see what is it for, whether it is optional or required, and in the former case, what is its default value.

See Also:
FenixFramework, MemConfig

Field Summary
protected  String appName
          This optional parameter specifies a name for the application.
protected  URL[] domainModelURLs
          This required parameter specifies the URL[] to each file containing the DML code that corresponds to the domain model of the application.
protected static String PROPERTY_CONFIG_CLASS
           
protected static String SETTER_FROM_STRING
           
 
Constructor Summary
Config()
           
 
Method Summary
protected  void appNameFromString(String value)
          Note: Either appNameFromString or domainModelURLsFromString should be used, but not both!
protected  void checkConfig()
          Subclasses of this class can overwrite this method, but they should specifically call super.checkConfig() to check the superclass's configuration.
protected  void checkForDomainModelURLs()
          Check if the value of domainModelURLs is already set.
protected  void checkRequired(Object obj, String fieldName)
           
protected  void domainModelURLsFromString(String value)
          Note: Either appNameFromString or domainModelURLsFromString should be used, but not both!
static URL[] filenamesToURLArray(String... filenames)
           
static URL[] filenameToURLArray(String filename)
           
 String getAppName()
           
abstract  BackEnd getBackEnd()
          Get the current BackEnd in use.
 URL[] getDomainModelURLs()
           
protected abstract  void init()
           
protected  void initialize()
          This method is invoked by the FenixFramework.initialize(Config).
protected static void missingRequired(String fieldName)
           
protected  void populate(Properties props)
           
static URL[] resourcesToURLArray(String... resources)
           
static URL[] resourceToURLArray(String resource)
           
protected  void setProperty(String propName, String value)
           
protected  void shutdown()
          Subclasses of this class can overwrite this method, but they should specifically call super.shutdown() to orderly shutdown the framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_CONFIG_CLASS

protected static final String PROPERTY_CONFIG_CLASS
See Also:
Constant Field Values

SETTER_FROM_STRING

protected static final String SETTER_FROM_STRING
See Also:
Constant Field Values

domainModelURLs

protected URL[] domainModelURLs
This required parameter specifies the URL[] to each file containing the DML code that corresponds to the domain model of the application. A non-empty array must be specified for this parameter.


appName

protected String appName
This optional parameter specifies a name for the application. When using configuration by convention, this name (if set) is used to lookup the <appName>/project.properties file. Additionally, this name will be used by the framework in the statistical logs performed during the application execution. The default value for this parameter is null.

Constructor Detail

Config

public Config()
Method Detail

checkRequired

protected void checkRequired(Object obj,
                             String fieldName)

checkForDomainModelURLs

protected void checkForDomainModelURLs()
Check if the value of domainModelURLs is already set.


checkConfig

protected void checkConfig()
Subclasses of this class can overwrite this method, but they should specifically call super.checkConfig() to check the superclass's configuration.


missingRequired

protected static void missingRequired(String fieldName)

initialize

protected final void initialize()
This method is invoked by the FenixFramework.initialize(Config).


populate

protected final void populate(Properties props)

setProperty

protected final void setProperty(String propName,
                                 String value)

appNameFromString

protected void appNameFromString(String value)
Note: Either appNameFromString or domainModelURLsFromString should be used, but not both!


domainModelURLsFromString

protected void domainModelURLsFromString(String value)
Note: Either appNameFromString or domainModelURLsFromString should be used, but not both!


init

protected abstract void init()

getBackEnd

public abstract BackEnd getBackEnd()
Get the current BackEnd in use.


getDomainModelURLs

public URL[] getDomainModelURLs()

getAppName

public String getAppName()

shutdown

protected void shutdown()
Subclasses of this class can overwrite this method, but they should specifically call super.shutdown() to orderly shutdown the framework.


resourceToURLArray

public static URL[] resourceToURLArray(String resource)

resourcesToURLArray

public static URL[] resourcesToURLArray(String... resources)

filenameToURLArray

public static URL[] filenameToURLArray(String filename)

filenamesToURLArray

public static URL[] filenamesToURLArray(String... filenames)


Copyright © 2013. All Rights Reserved.