PTLog API - 1.0

jp.ne.dti.lares.foozy.ptlog.glue
Class PropertiesCompositionConfig

java.lang.Object
  extended byjp.ne.dti.lares.foozy.ptlog.glue.PropertiesCompositionConfig
Direct Known Subclasses:
PropertiesConverterConfig, PropertiesFilterConfig, PropertiesFormatterConfig

public abstract class PropertiesCompositionConfig
extends java.lang.Object

Configuration utility with Properties class.

This help to build composite Object up from java.util.Properties. Object creation is done in steps shown below.

  1. [START OF FACTORY CONFIGURATION]
  2. get property names which start with aliasKeyPrefix
  3. split each property values by delimiter into two parts
  4. get class of factory by Class.forName() with second half
  5. create factory object by Class.newInstance()
  6. remember first half as alias name of the factory object
  7. [END OF FACTORY CONFIGURATION]
  8. [START OF COMPONENT CONFIGURAION]
  9. get property names which start with componentKeyPrefix
  10. sort gotten names in dictionary order(by String#compareTo)
  11. get first property value
  12. split property value by delimiter into two parts
  13. recognize first half of them as alias name of factory
  14. recognize another (or empty string, if property value does not contain delimiter in it) as parameter for factory,
  15. look factory object up by above factory alias name
  16. if factory is not found, and allowFailure is true, then, this throws IllegalArgumentException
  17. invoke addComponent(java.lang.Object, java.lang.Object, java.lang.String) to create component object and add it to container
  18. repeat above steps on rest properties
  19. [END OF COMPONENT CONFIGURAION]
  20. return container

You must concretize below method(s) to have this function.


Constructor Summary
PropertiesCompositionConfig(java.lang.String aliasKeyPrefix, java.lang.String componentKeyPrefix, char delimiter, boolean allowFailure)
          Constructor.
 
Method Summary
protected abstract  void addComponent(java.lang.Object containerObject, java.lang.Object factoryObject, java.lang.String parameter)
           
protected  java.lang.Object create_(java.lang.Object container, java.io.InputStream stream)
          Create Object from specified stream.
protected  java.lang.Object create_(java.lang.Object container, java.util.Properties properties)
          Create Object from specified properties.
protected  java.lang.Object create_(java.lang.Object container, java.lang.String filename)
          Create Object from specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesCompositionConfig

public PropertiesCompositionConfig(java.lang.String aliasKeyPrefix,
                                   java.lang.String componentKeyPrefix,
                                   char delimiter,
                                   boolean allowFailure)
Constructor.

Method Detail

create_

protected final java.lang.Object create_(java.lang.Object container,
                                         java.util.Properties properties)
Create Object from specified properties.

See class description about behavior of this method.

Parameters:
container - of components
properties - containing component configuration

create_

protected final java.lang.Object create_(java.lang.Object container,
                                         java.io.InputStream stream)
                                  throws java.io.IOException
Create Object from specified stream.

ATTENTION:Stream closing is not responsibility of this class but of caller side.

Parameters:
container - of components
stream - to load data into properties.
Throws:
java.io.IOException

create_

protected final java.lang.Object create_(java.lang.Object container,
                                         java.lang.String filename)
                                  throws java.io.IOException
Create Object from specified file.

Parameters:
container - of components
filename - to load data into properties.
Throws:
java.io.IOException

addComponent

protected abstract void addComponent(java.lang.Object containerObject,
                                     java.lang.Object factoryObject,
                                     java.lang.String parameter)

PTLog API - 1.0