|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.boylesoftware.cb2.BLObject com.boylesoftware.cb2.commons.property.PropertySharedBLO
Generic BLO for managing database-stored application properties, that are
used by the application context via
com.boylesoftware.cb2.appProperties.query
property. This BLO
can be deployed as a shared BLO since does not contain any session specific
data. The BLO needs a number of initialization parameters that name the
database table, which contains additional application properties, the column
in the table, which contains property names, and the column, which contains
property values. Here is how the BLO can be deployed in the
blo-config.xml
file:
<blo name="property" shared="true"> <init-param> <param-name>table</param-name> <param-value>Property</param-value> </init-param> <init-param> <param-name>nameColumn</param-name> <param-value>name</param-value> </init-param> <init-param> <param-name>valueColumn</param-name> <param-value>value</param-value> </init-param> </blo>
Note, that if the application does not use database-stored application
properties, that is com.boylesoftware.cb2.appProperties.query
is not set, the init
method of this BLO throws an exception.
Field Summary | |
protected java.lang.String |
dataSourceName
Name of the data source corresponding to the database where the properties are stored. |
protected java.lang.String |
nameColumn
Name of the column, which contains application property names. |
protected static BTreeMap |
NONCHANGABLE_PROPS
Set of name prefixes for application properties that cannot be stored in the database and can be specified only in the cb2app.properties file. |
static int |
PROPTYPE_BASIC
Property type, returned by getPropertyType method, which
indicates that the property comes from the
cb2app.properties file. |
static int |
PROPTYPE_DB
Property type, returned by getPropertyType method, which
indicates that the property comes from the database. |
static int |
PROPTYPE_IMMUTABLE
Property type, returned by getPropertyType method, which
indicates that the property comes from the
cb2app.properties file and its value cannot be changed,
because it is used by the application context before it processes
additional properties from the database. |
static int |
PROPTYPE_OVERRIDDEN
Property type, returned by getPropertyType method, which
indicates that the property comes from the
cb2app.properties file, but its value has been overridden
by a property with the same name stored in the database. |
static int |
PROPTYPE_UNKNOWN
This value is returned by getPropertyType method when type
of a non existant property is requested. |
protected java.lang.String |
table
Name of the database table, which contains application properties. |
protected java.lang.String |
valueColumn
Name of the column, which contains application property values. |
Fields inherited from class com.boylesoftware.cb2.BLObject |
bloc, log |
Constructor Summary | |
PropertySharedBLO()
|
Method Summary | |
java.util.SortedMap |
getProperties()
Gets all application properties as a sorted map. |
int |
getPropertyType(java.lang.String name)
Tells the specified application property's type, which is where its value comes from. |
protected void |
init()
Initializes the BLO. |
void |
resetProperty(java.lang.String name)
Resets an application property's value. |
void |
saveProperties(java.util.Properties newProps)
Saves properties from the specified set of properties that have different from current application properties values to the database. |
Methods inherited from class com.boylesoftware.cb2.BLObject |
activate, destroy, getApplicationContext, getBLO, getBLOContainer, getDAO, getDAO, getDAOConfig, getDAOConfig, getDeploymentName, getInitParameter, getLastErrors, isRollbackOnly, setErrors, setRollbackOnly |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int PROPTYPE_UNKNOWN
getPropertyType
method when type
of a non existant property is requested.
public static final int PROPTYPE_IMMUTABLE
getPropertyType
method, which
indicates that the property comes from the
cb2app.properties
file and its value cannot be changed,
because it is used by the application context before it processes
additional properties from the database.
public static final int PROPTYPE_BASIC
getPropertyType
method, which
indicates that the property comes from the
cb2app.properties
file.
public static final int PROPTYPE_OVERRIDDEN
getPropertyType
method, which
indicates that the property comes from the
cb2app.properties
file, but its value has been overridden
by a property with the same name stored in the database.
public static final int PROPTYPE_DB
getPropertyType
method, which
indicates that the property comes from the database.
protected static final BTreeMap NONCHANGABLE_PROPS
cb2app.properties
file.
protected java.lang.String dataSourceName
init
method from
com.boylesoftware.cb2.appProperties.dataSource
application
property. If the property is not defined, set to "default".
protected java.lang.String table
init
method from the "table" BLO initialization
parameter.
protected java.lang.String nameColumn
init
method from the "nameColumn" BLO initialization
parameter.
protected java.lang.String valueColumn
init
method from the "valueColumn" BLO
initialization parameter.
Constructor Detail |
public PropertySharedBLO()
Method Detail |
protected void init() throws BLException
init
in class BLObject
BLException
- if the BLO cannot be initialized.public int getPropertyType(java.lang.String name)
name
- the application property's name.
PROPTYPE_xxx
values.public java.util.SortedMap getProperties()
public void saveProperties(java.util.Properties newProps) throws BLException
setProperty
on the
applicatrion context for all changed properties.
newProps
- collection of application property values.
BLException
- if a database error happens, or in case of an
attempt to change an immutable property.public void resetProperty(java.lang.String name) throws BLException
cb2app.properties
file. This method has no effect if the
property is not stored in the database and it calls
setProperty
on the application context if any change has
been made.
name
- the application property's name.
BLException
- if a database error happens.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |