com.opensymphony.module.propertyset.database
Class JDBCPropertySet
java.lang.Object
com.opensymphony.module.propertyset.AbstractPropertySet
com.opensymphony.module.propertyset.database.JDBCPropertySet
- All Implemented Interfaces:
- PropertySet
- public class JDBCPropertySet
- extends AbstractPropertySet
This is an implementation of a property set manager for JDBC. It relies on
one table, called "os_propertyset" that has four columns: "type" (integer),
"keyValue" (string), "globalKey" (string), and "value" (string). This is not
likely to be enough for people who store BLOBS as properties. Of course,
those people need to get a life.
For Postgres(?):
CREATE TABLE OS_PROPERTYENTRY (GLOBAL_KEY varchar(255), ITEM_KEY varchar(255), ITEM_TYPE smallint, STRING_VALUE varchar(255), DATE_VALUE timestamp, DATA_VALUE oid, FLOAT_VALUE float8, NUMBER_VALUE numeric, primary key (GLOBAL_KEY, ITEM_KEY));
For Oracle (Thanks to Michael G. Slack!):
CREATE TABLE OS_PROPERTYENTRY (GLOBAL_KEY varchar(255), ITEM_KEY varchar(255), ITEM_TYPE smallint, STRING_VALUE varchar(255), DATE_VALUE date, DATA_VALUE long raw, FLOAT_VALUE float, NUMBER_VALUE numeric, primary key (GLOBAL_KEY, ITEM_KEY));
Other databases may require small tweaks to the table creation scripts!
Required Args
- globalKey - the globalKey to use with this PropertySet
Required Configuration
- datasource - JNDI path for the DataSource
- table.name - the table name
- col.globalKey - column name for the globalKey
- col.itemKey - column name for the itemKey
- col.itemType - column name for the itemType
- col.string - column name for the string value
- col.date - column name for the date value
- col.data - column name for the data value
- col.float - column name for the float value
- col.number - column name for the number value
- Version:
- $Revision: 1.13 $
- Author:
- Joseph B. Ottinger, Pat Lightbody
| Fields inherited from interface com.opensymphony.module.propertyset.PropertySet |
BOOLEAN, DATA, DATE, DOUBLE, INT, LONG, OBJECT, PROPERTIES, STRING, TEXT, XML |
|
Method Summary |
protected void |
cleanup(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet result)
|
boolean |
exists(java.lang.String key)
Determine if property exists. |
protected java.lang.Object |
get(int type,
java.lang.String key)
|
protected java.sql.Connection |
getConnection()
|
java.util.Collection |
getKeys(java.lang.String prefix,
int type)
List all keys starting with supplied prefix of certain type. |
int |
getType(java.lang.String key)
Returns type of value. |
void |
init(java.util.Map config,
java.util.Map args)
|
void |
remove()
Remove the propertyset and all it associated keys. |
void |
remove(java.lang.String key)
Removes property. |
protected void |
setImpl(int type,
java.lang.String key,
java.lang.Object value)
|
boolean |
supportsType(int type)
Returns true. |
| Methods inherited from class com.opensymphony.module.propertyset.AbstractPropertySet |
getAsActualType, getBoolean, getData, getDate, getDouble, getInt, getKeys, getKeys, getKeys, getLong, getObject, getProperties, getSchema, getString, getText, getXML, isSettable, setAsActualType, setBoolean, setData, setDate, setDouble, setInt, setLong, setObject, setProperties, setSchema, setString, setText, setXML, supportsTypes, toString, type, type |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
ds
protected javax.sql.DataSource ds
colData
protected java.lang.String colData
colDate
protected java.lang.String colDate
colFloat
protected java.lang.String colFloat
colGlobalKey
protected java.lang.String colGlobalKey
colItemKey
protected java.lang.String colItemKey
colItemType
protected java.lang.String colItemType
colNumber
protected java.lang.String colNumber
colString
protected java.lang.String colString
globalKey
protected java.lang.String globalKey
tableName
protected java.lang.String tableName
closeConnWhenDone
protected boolean closeConnWhenDone
JDBCPropertySet
public JDBCPropertySet()
getKeys
public java.util.Collection getKeys(java.lang.String prefix,
int type)
throws PropertyException
- Description copied from interface:
PropertySet
- List all keys starting with supplied prefix of certain type. See
statics.
- Parameters:
prefix - String that keys must start with. If null, than all
keys shall be returned.type - Type to list. See static class variables. If null, then
all types shall be returned.
- Returns:
- Unmodifiable
Collection of
Strings.
- Throws:
PropertyException
getType
public int getType(java.lang.String key)
throws PropertyException
- Description copied from interface:
PropertySet
- Returns type of value.
- Returns:
- Type of value. See static class variables.
- Throws:
PropertyException
exists
public boolean exists(java.lang.String key)
throws PropertyException
- Description copied from interface:
PropertySet
- Determine if property exists.
- Throws:
PropertyException
init
public void init(java.util.Map config,
java.util.Map args)
- Specified by:
init in interface PropertySet- Overrides:
init in class AbstractPropertySet
remove
public void remove()
throws PropertyException
- Description copied from interface:
PropertySet
- Remove the propertyset and all it associated keys.
- Throws:
PropertyException - if there is an error removing the propertyset.
remove
public void remove(java.lang.String key)
throws PropertyException
- Description copied from interface:
PropertySet
- Removes property.
- Throws:
PropertyException
supportsType
public boolean supportsType(int type)
- Description copied from class:
AbstractPropertySet
- Returns true.
- Specified by:
supportsType in interface PropertySet- Overrides:
supportsType in class AbstractPropertySet
getConnection
protected java.sql.Connection getConnection()
throws java.sql.SQLException
- Throws:
java.sql.SQLException
setImpl
protected void setImpl(int type,
java.lang.String key,
java.lang.Object value)
throws PropertyException
- Specified by:
setImpl in class AbstractPropertySet
- Throws:
PropertyException
cleanup
protected void cleanup(java.sql.Connection connection,
java.sql.Statement statement,
java.sql.ResultSet result)
get
protected java.lang.Object get(int type,
java.lang.String key)
throws PropertyException
- Specified by:
get in class AbstractPropertySet
- Throws:
PropertyException
|