Package org.fugerit.java.core.cfg.xml
Class GenericListCatalogConfig<T>
- java.lang.Object
-
- org.fugerit.java.core.cfg.helpers.AbstractConfigurableObject
-
- org.fugerit.java.core.cfg.xml.GenericListCatalogConfig<T>
-
- All Implemented Interfaces:
Serializable
,ConfigurableObject
,LogObject
- Direct Known Subclasses:
CustomListCatalogConfig
,DataListCatalogConfig
public class GenericListCatalogConfig<T> extends AbstractConfigurableObject
Class for loading an xml configuration in the form of :<!-- key/value attributes in this list are accessed through the method getGeneralProps() --> <data-catalog-config key1="value1" key2="value"> <!-- Some additional configurations could be loaded through configuration files. All modules will be loaded before the main configuration file. --> <module-list> <module id="module-01" mode="cl" src="class/load/path/to/module"/> </module-list> <!-- data list ids are accessed through the method getIdSet() [ex. 1, 2, 3] while specific entry list through the method getDataList() [ex. 1A, 1B] --> <data-list id="1"> <data id="1A"/> <data id="1B"/> </data-list> <data-list id="2"> <data id="2A"/> </data-list> <data-list id="3"> <data id="3A"/> <data id="3B"/> <data id="3C"/> </data-list> </data-catalog-config>
- Author:
- fugerit
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ATT_BEAN_MODE
Bean population modestatic String
ATT_BEAN_MODE_DEFAULT
Default, bean population mode (by default read only attributes)static String
ATT_CONFIG_PROVIDER_NAME
Name of the config provider to usestatic String
ATT_DATA_CATALOG_CONFIG
Default configuration element for a a data catalog config elementstatic String
ATT_LIST_TYPE
Type to use for the config containers (data-list)static String
ATT_TAG_DATA
Default configuration entry for a data entrystatic String
ATT_TAG_DATA_LIST
Default configuration element for a data liststatic String
ATT_TAG_MODULE
static String
ATT_TAG_MODULE_CONF_ID
Configuration attribute for module 'id'static String
ATT_TAG_MODULE_CONF_MODE
Configuration attribute for module load 'mode'static String
ATT_TAG_MODULE_CONF_MODE_CL
Value for module load mode by class loaderstatic String
ATT_TAG_MODULE_CONF_MODE_FILE
Value for module load mode by filestatic String
ATT_TAG_MODULE_CONF_PATH
Configuration attribute for module src pathstatic String
ATT_TAG_MODULE_CONF_UNSAFE
Configuration attribute for module unsafe module (if unsafe='true' load exception would be ignored and main configuration will proceed )static String
ATT_TAG_MODULE_LIST
static String
ATT_TAG_TYPE_STRING
static String
ATT_TRY_XSD_VALIDATION
True if the catalog should try xsd validation (will be used only if a schema catalog is set)static String
ATT_TRY_XSD_VALIDATION_DEFAULT
static String
ATT_TRY_XSD_VALIDATION_FALSE
static String
ATT_TRY_XSD_VALIDATION_TRUE
static String
ATT_TYPE
Type to use for the for the elements (data)protected String
attTagData
protected String
attTagDataList
static String
CONFIG_CHECK_DUPLICATE_ID
General configurazion property for checking duplicate catalog idstatic String
CONFIG_CHECK_DUPLICATE_ID_DEFAULT
Default vaule for 'check-duplicate-id' property.static String
CONFIG_CHECK_DUPLICATE_ID_FAIL
If 'check-duplicate-id' is se to fail, the duplicate will cause the configuration to failstatic String
CONFIG_CHECK_DUPLICATE_ID_FAIL_ON_SET
If 'check-duplicate-entry-id' is se to fail, the duplicate will cause the configuration to failstatic String
CONFIG_CHECK_DUPLICATE_ID_WARN
If 'check-duplicate-id' is se to warn, the duplicate will only be loggedstatic String
CONFIG_CHECK_ENTRY_DUPLICATE_ID
General configurazion property for checking duplicate entry id-
Fields inherited from class org.fugerit.java.core.cfg.helpers.AbstractConfigurableObject
logger
-
-
Constructor Summary
Constructors Constructor Description GenericListCatalogConfig()
Creates a new DataListCatalogConfig wth default configuration.GenericListCatalogConfig(String attTagDataList, String attTagData)
Creates a new DataListCatalogConfig
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Properties props)
Configure the object.void
configure(Element tag)
Configure the object.protected T
customEntryHandling(String dataListId, T current, Element element)
protected T
customEntryHandling(T current, Element element)
Collection<T>
getDataList(String id)
Returns a collection of data entry contained in a specifed data listprotected Set<String>
getEntryIdCheck()
Set<String>
getIdSet()
Returns the set of data list id contained in this configurationorg.slf4j.Logger
getLogger()
Returnts the logger for this objectboolean
hasDefinition()
Check if the catalog config has a schema definitionstatic <T> GenericListCatalogConfig<T>
load(InputStream is, GenericListCatalogConfig<T> config)
protected Collection<T>
newCollection(Object typeSample, String listType, Element tag, Element current)
SAXErrorHandlerStore
validate(Source source)
-
Methods inherited from class org.fugerit.java.core.cfg.helpers.AbstractConfigurableObject
configureProperties, configureXML, setConfigProvider
-
-
-
-
Field Detail
-
CONFIG_CHECK_DUPLICATE_ID
public static final String CONFIG_CHECK_DUPLICATE_ID
General configurazion property for checking duplicate catalog id- See Also:
- Constant Field Values
-
CONFIG_CHECK_ENTRY_DUPLICATE_ID
public static final String CONFIG_CHECK_ENTRY_DUPLICATE_ID
General configurazion property for checking duplicate entry id- See Also:
- Constant Field Values
-
CONFIG_CHECK_DUPLICATE_ID_FAIL
public static final String CONFIG_CHECK_DUPLICATE_ID_FAIL
If 'check-duplicate-id' is se to fail, the duplicate will cause the configuration to fail- See Also:
- Constant Field Values
-
CONFIG_CHECK_DUPLICATE_ID_FAIL_ON_SET
public static final String CONFIG_CHECK_DUPLICATE_ID_FAIL_ON_SET
If 'check-duplicate-entry-id' is se to fail, the duplicate will cause the configuration to fail- See Also:
- Constant Field Values
-
CONFIG_CHECK_DUPLICATE_ID_WARN
public static final String CONFIG_CHECK_DUPLICATE_ID_WARN
If 'check-duplicate-id' is se to warn, the duplicate will only be logged- See Also:
- Constant Field Values
-
CONFIG_CHECK_DUPLICATE_ID_DEFAULT
public static final String CONFIG_CHECK_DUPLICATE_ID_DEFAULT
Default vaule for 'check-duplicate-id' property. ('warn' for compatibility reason, strongly recommended setting to 'fail' )- See Also:
- Constant Field Values
-
ATT_DATA_CATALOG_CONFIG
public static final String ATT_DATA_CATALOG_CONFIG
Default configuration element for a a data catalog config element- See Also:
- Constant Field Values
-
ATT_TRY_XSD_VALIDATION
public static final String ATT_TRY_XSD_VALIDATION
True if the catalog should try xsd validation (will be used only if a schema catalog is set)- See Also:
- Constant Field Values
-
ATT_TRY_XSD_VALIDATION_TRUE
public static final String ATT_TRY_XSD_VALIDATION_TRUE
- See Also:
- Constant Field Values
-
ATT_TRY_XSD_VALIDATION_FALSE
public static final String ATT_TRY_XSD_VALIDATION_FALSE
- See Also:
- Constant Field Values
-
ATT_TRY_XSD_VALIDATION_DEFAULT
public static final String ATT_TRY_XSD_VALIDATION_DEFAULT
- See Also:
- Constant Field Values
-
ATT_TAG_DATA_LIST
public static final String ATT_TAG_DATA_LIST
Default configuration element for a data list- See Also:
- Constant Field Values
-
ATT_TAG_DATA
public static final String ATT_TAG_DATA
Default configuration entry for a data entry- See Also:
- Constant Field Values
-
ATT_TYPE
public static final String ATT_TYPE
Type to use for the for the elements (data)- See Also:
- Constant Field Values
-
ATT_BEAN_MODE
public static final String ATT_BEAN_MODE
Bean population mode- See Also:
- Constant Field Values
-
ATT_CONFIG_PROVIDER_NAME
public static final String ATT_CONFIG_PROVIDER_NAME
Name of the config provider to use- See Also:
- Constant Field Values
-
ATT_BEAN_MODE_DEFAULT
public static final String ATT_BEAN_MODE_DEFAULT
Default, bean population mode (by default read only attributes)- See Also:
- Constant Field Values
-
ATT_LIST_TYPE
public static final String ATT_LIST_TYPE
Type to use for the config containers (data-list)- See Also:
- Constant Field Values
-
ATT_TAG_TYPE_STRING
public static final String ATT_TAG_TYPE_STRING
- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_LIST
public static final String ATT_TAG_MODULE_LIST
- See Also:
- Constant Field Values
-
ATT_TAG_MODULE
public static final String ATT_TAG_MODULE
- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_ID
public static final String ATT_TAG_MODULE_CONF_ID
Configuration attribute for module 'id'- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_MODE
public static final String ATT_TAG_MODULE_CONF_MODE
Configuration attribute for module load 'mode'- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_MODE_CL
public static final String ATT_TAG_MODULE_CONF_MODE_CL
Value for module load mode by class loader- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_MODE_FILE
public static final String ATT_TAG_MODULE_CONF_MODE_FILE
Value for module load mode by file- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_PATH
public static final String ATT_TAG_MODULE_CONF_PATH
Configuration attribute for module src path- See Also:
- Constant Field Values
-
ATT_TAG_MODULE_CONF_UNSAFE
public static final String ATT_TAG_MODULE_CONF_UNSAFE
Configuration attribute for module unsafe module (if unsafe='true' load exception would be ignored and main configuration will proceed )- See Also:
- Constant Field Values
-
attTagDataList
protected String attTagDataList
-
attTagData
protected String attTagData
-
-
Method Detail
-
load
public static <T> GenericListCatalogConfig<T> load(InputStream is, GenericListCatalogConfig<T> config) throws Exception
- Throws:
Exception
-
newCollection
protected Collection<T> newCollection(Object typeSample, String listType, Element tag, Element current) throws ConfigException
- Throws:
ConfigException
-
customEntryHandling
protected T customEntryHandling(String dataListId, T current, Element element) throws ConfigException
- Throws:
ConfigException
-
customEntryHandling
protected T customEntryHandling(T current, Element element) throws ConfigException
- Throws:
ConfigException
-
configure
public void configure(Element tag) throws ConfigException
Description copied from interface:ConfigurableObject
Configure the object.
- Specified by:
configure
in interfaceConfigurableObject
- Specified by:
configure
in classAbstractConfigurableObject
- Parameters:
tag
- The tag object to use for configuration.- Throws:
ConfigException
- If troubles arise during object configuration.
-
getIdSet
public Set<String> getIdSet()
Returns the set of data list id contained in this configuration- Returns:
- a set of id
-
getDataList
public Collection<T> getDataList(String id)
Returns a collection of data entry contained in a specifed data list- Parameters:
id
- the id of the data list- Returns:
- the data entry in the data list
-
hasDefinition
public boolean hasDefinition()
Check if the catalog config has a schema definition- Returns:
true
if the schemaId exists and has the catalog defined
-
validate
public SAXErrorHandlerStore validate(Source source) throws Exception
- Throws:
Exception
-
getLogger
public org.slf4j.Logger getLogger()
Description copied from interface:LogObject
Returnts the logger for this object- Specified by:
getLogger
in interfaceLogObject
- Overrides:
getLogger
in classAbstractConfigurableObject
- Returns:
- the logger
-
configure
public void configure(Properties props) throws ConfigException
Description copied from interface:ConfigurableObject
Configure the object.
- Specified by:
configure
in interfaceConfigurableObject
- Specified by:
configure
in classAbstractConfigurableObject
- Parameters:
props
- The property object to use for configuration.- Throws:
ConfigException
- If troubles arise during object configuration.
-
-