Applications built using the JDistil framework are defined using configuration data. This configuration data
includes the details of all fields, actions, pages, and domain object bindings encompassing an application.
The details include action and field validation rules, field converters supporting formatting and parsing of field values,
action specific field mappings, action specific processor mappings, field to domain object property bindings, and
page resource mappings.
Configuration data is provided by implementing the "com.bws.jdistil.core.configuration.IConfiguration"
interface and specifying a reference to the implementing class using the "application.configuration" property
in the "core.properties" file. Multiple configuration classes can be specified in the "core.properties" file
for a single application but this feature is intended to support pluggable application modules. Applications
created using the JDistil Plug-in leverage the multiple configurations feature to include the codes and security
module configurations. The configuration data section below provides an example of a configuration implementation
and an example of registering the implementation with the framework using the "core.properties" file.
The "com.bws.jdistil.core.configuration.ConfigurationManager" class is responsible for providing centralized access to all
application defined configuration data. This class loads and consolidates the configuration data of all configuration classes
defined in the "core.properties" file and provides a single point of entry to access the information. Framework components
leverage this class for access to application configuration data and it can also be used by application specific classes
when needed. The configuration manager section of this page provides an overview of the methods available in the ConfigurationManager class.
Configuration
Configuration Data
The following provides an example of an application configuration implementation. Instead of implementing the
"com.bws.jdistil.core.configuration.IConfiguration" interface, the implementation extends "com.bws.jdistil.core.configuration.Configuration"
which is an abstract implementation of the interface provided by the framework. This is a convenience class that provides a default empty
implementation of each interface method allowing a developer to only implement the methods required by the configuration.
public class CompanyConfiguration extends com.bws.jdistil.core.configuration.Configuration {
The following is an example implementation of the "registerFields" method. Each field is composed of a unique ID, field data type, default display name, and converter if needed. Additionally, one or more field rules can also be registered with the field. These will be used during field validation.
@Override public void registerFields(Setfields) { super.registerFields(fields); Field companyId = new Field(FieldIds.COMPANY_ID, Field.INTEGER, "ID", NumberConverter.getInstance()); fields.add(companyId); Field companyVersion = new Field(FieldIds.COMPANY_VERSION, Field.LONG, "Version", NumberConverter.getInstance()); fields.add(companyVersion); Field companyName = new Field(FieldIds.COMPANY_NAME, Field.STRING, "Name", null); fields.add(companyName); Field companyActive = new Field(FieldIds.COMPANY_ACTIVE, Field.BOOLEAN, "Active", BooleanConverter.getInstance()); fields.add(companyActive); Field companyCreated = new Field(FieldIds.COMPANY_CREATED, Field.DATE, "Created", DateConverter.getInstance()); companyCreated.addRule(new ConverterRule()); fields.add(companyCreated); Field companyType = new Field(FieldIds.COMPANY_TYPE, Field.INTEGER, "Type", NumberConverter.getInstance()); fields.add(companyType); ... }
The following is an example implementation of the "registerActions" method. Each action is composed of a unique ID and default display name. Additionally, one or more processors and all supported fields are also registered with the action. A boolean value is specified with each registered field indicating whether or not the field is required.
@Override public void registerActions(Setactions) { super.registerActions(actions); Action saveCompany = new Action(ActionIds.SAVE_COMPANY, "Save"); saveCompany.addProcessorFactory(new SingletonPojoFactory(SaveCompany.class)); saveCompany.addField(FieldIds.COMPANY_ID, false); saveCompany.addField(FieldIds.COMPANY_VERSION, false); saveCompany.addField(FieldIds.COMPANY_NAME, true); saveCompany.addField(FieldIds.COMPANY_ACTIVE, false); saveCompany.addField(FieldIds.COMPANY_CREATED, false); saveCompany.addField(FieldIds.COMPANY_TYPE, true); actions.add(saveCompany); ... }
The following is an example implementation of the "registerPages" method. Each page is composed of a unique ID, resource name, default display name, and secure indicator. Pages defined as secure ensure only authenticated users can access the page. This provides added security if attempts are made to directly access pages.
@Override public void registerPages(Setpages) { super.registerPages(pages); Page companies = new Page(PageIds.COMPANIES, "/company/Companies.jsp", "Companies", true); pages.add(companies); Page company = new Page(PageIds.COMPANY, "/company/Company.jsp", "Company", true); pages.add(company); ... }
The following is an example implementation of the "registerObjectBindings" method. Each object binding is composed of a target domain object class and one or more field bindings. Each field binding is composed of a unique ID and associated domain object property name.
@Override public void registerObjectBindings(SetobjectBindings) { super.registerObjectBindings(objectBindings); ObjectBinding company = new ObjectBinding(Company.class); company.addFieldBinding(FieldIds.COMPANY_ID, "Id"); company.addFieldBinding(FieldIds.COMPANY_VERSION, "Version"); company.addFieldBinding(FieldIds.COMPANY_NAME, "Name"); company.addFieldBinding(FieldIds.COMPANY_ACTIVE, "Active"); company.addFieldBinding(FieldIds.COMPANY_CREATED, "Created"); company.addFieldBinding(FieldIds.COMPANY_TYPE, "Type"); objectBindings.add(company); ... }
The following is an example implementation of the "registerFactoryProviders" method. This method is provided to support integration and can be used to map factory providers to packages or specific classes if desired. This allow control over how class instances are created by the framework.
@Override public void registerFactoryProviders(Map> factoryProviders) { super.registerFactoryProviders(factoryProviders); factoryProviders.put("com.bws.test", PojoFactoryProvider); factoryProviders.put("com.bws.test.TestClass", PooledFactoryProvider); ... }
Configuration Manager
The following highlights the public methods available in the "com.bws.jdistil.core.configuration.ConfigurationManager"
class. These methods provide access to all consolidated configuration data for an application.
public class ConfigurationManager { public static Action getWelcomeAction(); public static Action getLogonAction(); public static Action getErrorAction(); public static IFactory getFactory(Class> targetClass); public static Action getAction(String actionId); public static Field getField(String fieldId); public static Page getPage(String pageId); public static ObjectBinding getObjectBinding(Class> targetClass); }