|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.ist.fenixframework.FenixFramework
public class FenixFramework
This is the main class for the Fenix Framework. It is the central point for obtaining most of the APIs that the user of the framework (a programmer) should need.
Before being able to use the framework, a program must initialize it, by providing a configuration. There are two (disjoint) alternative methods to initialize the FenixFramework:
Config
or MultiConfig
instance and then explicitly calls the corresponding initialization method: initialize(Config)
or initialize(MultiConfig)
.Using the configuration by convention, the framework will first look up the name of the BackEnd
that generated the domain-specific code (this is done by
instantiating the class CurrentBackEndId
and by requesting
BackEndId.getBackEndName()
) and then use that name to check
for the presence of the file 'fenix-framework-<NNN>.properties
' in the
classpath using Thread.currentThread().getContextClassLoader().getResource()
(where
<NNN>
is the name of the BackEnd). If this file is found, and contains the
correct content, the framework will create the appropriate Config instance and automatically
invoke initialize(Config)
.
The syntax for the configuration file is to have each line in the form:
property=value
where each property
must be the name of an existing configuration field.
Additionally, there is one optional special property named config.class
. By
default, the config parser creates an instance of the BackEndId.getDefaultConfigClass()
provided by the current BackEndId, but this property can be used to choose a different (albeit
compatible) configuration class. The config instance is then populated with each property
(except with the config.class
property), using the following algorithm:
property
. If not
a ConfigError
is thrown.<property>FromString(String)
, then such method will be invoked to set the
property. The String
argument will be the value
.value
String.ConfigError
.The rationale supporting the previous mechanism is to allow the config class to process the
String provided in the value>
using the *FromString
method.
After population of the config finishes with success, the initialize(Config)
method is invoked with the created Config instance. From this
point on, the initialization process continues just as if the programmer had explicitly invoked
that initialization method.
The explicit configuration maintains the original configuration style (since Fenix Framework
1.0) with compile-time checking of the config's attributes. To use it, read the documentation in
the Config
class. It also adds the possibility for the programmer to provide multiple
configurations and then let the initialization process decide which to use based on the current
BackEnd
(see MultiConfig
for more details).
After initialization completes with success, the framework is ready to manage operations on
the domain objects. Also, it is possible to get an instance of the DomainModel
class
representing the structure of the application's domain.
Config
,
DomainModel
Constructor Summary | |
---|---|
FenixFramework()
|
Method Summary | ||
---|---|---|
static Config |
getConfig()
|
|
static DomainModel |
getDomainModel()
Gets the model of the domain classes. |
|
static
|
getDomainObject(String externalId)
Get any DomainObject given its external identifier. |
|
static DomainRoot |
getDomainRoot()
Always gets a well-known singleton instance of DomainRoot . |
|
static Transaction |
getTransaction()
|
|
static TransactionManager |
getTransactionManager()
|
|
static void |
initialize(Config newConfig)
This method initializes the FenixFramework. |
|
static void |
initialize(MultiConfig configs)
|
|
static boolean |
isInitialized()
|
|
static void |
shutdown()
Inform the framework components that the application intends to shutdown. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FenixFramework()
Method Detail |
---|
public static boolean isInitialized()
FenixFramework.initialize
method has
already been invokedpublic static void initialize(Config newConfig)
newConfig
- The configuration that will be used by this instance of the framework.public static void initialize(MultiConfig configs)
public static Config getConfig()
public static DomainModel getDomainModel()
DomainModel
in use.
ConfigError
- If this method is invoked before the framework is initialized or if a
DmlCompilerException
occurs (only possible on first invocation).public static DomainRoot getDomainRoot()
DomainRoot
. The intended use of this
instance is to provide a single entry point to the graph of DomainObject
s. The user
of the framework may connect (via DML) any DomainObject
to this class.
public static <T extends DomainObject> T getDomainObject(String externalId)
DomainObject
given its external identifier.
The external identifier must have been obtained by a previous invocation to DomainObject.getExternalId()
. If the external identifier is tampered with (in which case a
valid DomainObject
cannot be found), the result of calling this method is undefined.
externalId
- The external identifier of the domain object to get
public static TransactionManager getTransactionManager()
public static Transaction getTransaction()
public static void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |