| Context Properties |
|
ContextProperties (com.javelin.generator.dictionary.ContextProperties) JGenerator reads properties from a class called ContextProperties. This is a java.util.Properties class with helpful methods on it. The JGenerator populates the ContextProperties from either a database (using the JdbcReader) or a properties file (using the PropertiesReader). A properties file is always necessary to tell the JGenerator which readers and writers to execute. JGenerator uses a powerful macro parser called the MacroPropertiesParser to make specification of properties easier. See Macro Parser for more details. The ContextProperties class has the following functionality: -
|
|
Default Properties A set of default properties exists that defines a common set of properties across all projects. Default properties are defined in a defaultbdl.properties file in the com.javelin.generator package. The properties specified in the defaultdbl.properties file are read in by the code generator at initialization. These defaults can be overridden by the context properties file. Some of the default properties are listed below. The Default Project Properties require that 3 mandatory macro properties are defined in the context properties file.
In a project file these properties must be defined, for example:- $CONTEXTNAME=Northwind |
|
The default.pathName property refers to the directory where the JSP,web, EJB, SQL is created, this is defaulted to default.pathName=$ROOT/web This can be overridden to a specific directory, to create different versions, and different 'uber-roots'etc. For example: - default.pathName=$ROOT/northwind For different types of files (e.g. SQL) this can be overridden. For example:- sql.PathName=$ROOT/northwind |
|
Class Name Patterns The JGenerator needs to know the fully qualified name of every class. Rather than define every class for every table the macro property parser defines a pattern for each type of class to be created. These class name patterns are defined in the defaultbdl.properties file. A writer in JGenerator will not create a class if that class name is not found in the properties file. These class name patterns are then used by the various Writers to write out the class names into their correct packages, and create the correct import statements etc. Declaring the class name pattern in the properties file doesn't mean that the class will be created, just that all the writers that refer to those classes can access those class name patterns. Each class name pattern is defined using a macro the default properties file. This macro can then be expanded for each specific class. For example the following macros define 3 class name patterns: - $INTERFACE=public interface $PACKAGE.$THIS extends
$BEANS.Bean java.lang.Cloneable These patterns can then be expanded by the macro property parser to create instances of the fully qualified class name using the $CREATE macro (see below for more details). |
|
Creator Properties Defining a class pattern in the default properties file doesn't mean that the class name will be expanded. To expand a class name for a particular class the $CREATE macro is used. The $CREATE macro can define one or more patterns to be expanded for a particular class. In the context properties file this macro can be expanded using the syntax: - $CREATE <Creator Macro> <Table Name> For example 3 class names can be expanded for the Address class as follows: - $CREATE $INTERFACE,$BEANCLASS,$VALIDATOR Address This macro will be expanded to the following classes: - Account=public interface Account extends JBean, Cloneable For example, this defines a macro called $BEANCREATOR which defines all set of classes necessary to create a set of JBeans and their interfaces. Because the macro parser allows recursive expansion groups of class name patterns can be expressed as a single macro to ensure that groups of classes are created together. For example: - $BEANCREATOR=\ For example to define all the Bean classes for the Account table, simple call: - $CREATE $BEANCREATOR Account This macro then (cleverly) expands to: - Account=public interface Account extends JBean The following macro sets have been defined: -
|
|
Logging Logging uses the default logging facility. Documented in the java.util.logging directory. The logger uses the name of the source. By default the logging is WARNING. To change the level of the logging you can either update the jre/lib/logging properties file by adding: <source>.level=SEVERE Alternatively you can set it in the Context directly. GymContext.code.0=Logger.getLogger( "gym" ).setLevel(
Level.SEVERE );
|