Oracle Fusion Middleware
Java API Reference for Oracle PDK Java
11g Release 1 (11.1.1)
E10691-01

oracle.portal.provider.v2.preference
Class DBPreferenceStore

java.lang.Object
  extended by oracle.portal.provider.v2.preference.PreferenceStore
      extended by oracle.portal.provider.v2.preference.DBPreferenceStore
All Implemented Interfaces:
Validateable, InitializableXMLObject

public class DBPreferenceStore
extends PreferenceStore
implements InitializableXMLObject

DBPreferenceStore is an implementation of the PreferenceStore storage mechanism that persists data using a JDBC compatible relational database.

Connections to the database are retrieved from a standard JDBC 2.0 connection pool through JNDI. Therefore, you must ensure that you have made a javax.sql.DataSource for your connection available through JNDI. On OC4J, this is done through the data-sources.xml configuration file (consult the OC4J documentation for more details). The JNDI path to the DataSource for the connection to be used must be registered with a call to setConnection(String), or through a <connection>jndi_path</connection> declaration.

The persisted data is stored in a database table; one row per customization. The name of the database table to be used to store preference data defaults to JPDK_PREFERENCE_STORE2, but can be overriden with a call to setTable(String), or through a <table>TABLE_NAME</table> declaration. A table with this default name can be installed on a database connection using the script in providers/dbPreferenceStore/jpdk_preference_store2.sql. If a table of a different name is to be used, it must conform to the same design.


Field Summary
 
Fields inherited from class oracle.portal.provider.v2.preference.PreferenceStore
DEFAULT_CUSTOMIZATION_TYPE, PATH_SEPARATOR_CHAR, PATH_SEPARATOR_STRING, USER_CUSTOMIZATION_TYPE
 
Constructor Summary
DBPreferenceStore()
          Null Constructor
DBPreferenceStore(boolean fastFailover)
           
 
Method Summary
 void destroy(Preference pref)
          Destroys the data persisted for the given Preference.
 void destroy(java.lang.String context, java.util.List preferenceTypes)
          Destroys all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types.
 boolean exists(Preference pref)
          Returns true if persisted data exists for the given Preference.
 java.io.InputStream getInputStream(Preference pref)
          Gets an InputStream for reading the data of the given Preference.
 java.io.OutputStream getOutputStream(Preference pref, boolean overwrite)
          Gets an OutputStream for writing the data of the given Preference directly into storage.
 java.util.Iterator list(java.lang.String context, java.util.List preferenceTypes)
          Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types.
 void postInitialize()
          Should be called once initialization of this DBPreferenceStore is complete, to complete initialization and perform any necessary validation.
 void preInitialize(java.lang.Object parent)
          Should be called immediately after construction of a DBPreferenceStore to associate it with its parent object (usually a ProviderDefinition).
 void setConnection(java.lang.String dataSourcePath)
          Sets the path to the DataSource from which this DBPreferenceStore should retrieve its database connections.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the actual DataSource from which this DBPreferenceStore should retrieve its database connections.
 void setTable(java.lang.String tableName)
          Sets the name of the database table in which this DBPreferenceStore should store customization data.
 void validate(java.lang.String context, ValidationError errors)
          Validates the internal state of this DBPreferenceStore instance.
 
Methods inherited from class oracle.portal.provider.v2.preference.PreferenceStore
copy, copy, copy, destroy, getName, list, read, setName, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBPreferenceStore

public DBPreferenceStore()
Null Constructor


DBPreferenceStore

public DBPreferenceStore(boolean fastFailover)
Method Detail

preInitialize

public void preInitialize(java.lang.Object parent)
                   throws NodeHandlerException
Should be called immediately after construction of a DBPreferenceStore to associate it with its parent object (usually a ProviderDefinition). Currently, this method does nothing.

Specified by:
preInitialize in interface InitializableXMLObject
Parameters:
parent - the parent object.
Throws:
NodeHandlerException - if the parent object is not suitable.

postInitialize

public void postInitialize()
                    throws NodeHandlerException
Should be called once initialization of this DBPreferenceStore is complete, to complete initialization and perform any necessary validation.

Specified by:
postInitialize in interface InitializableXMLObject
Throws:
NodeHandlerException - if validation is unsuccessful

setConnection

public void setConnection(java.lang.String dataSourcePath)
                   throws PreferenceStoreException
Sets the path to the DataSource from which this DBPreferenceStore should retrieve its database connections.

Parameters:
dataSourcePath - JNDI path to a DataSource for a pooled database connection
Throws:
PreferenceStoreException - if a DataSource of the given name cannot be retrieved

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Sets the actual DataSource from which this DBPreferenceStore should retrieve its database connections. Causes any path set by setConnection(java.lang.String) to be ignored.

Parameters:
dataSource - a JDBC data source for a pooled database connection

setTable

public void setTable(java.lang.String tableName)
Sets the name of the database table in which this DBPreferenceStore should store customization data. If not set explicitly, the default name is "JPDK_PREFERENCE_STORE2".

Parameters:
tableName - name of the database table storing customization data

list

public java.util.Iterator list(java.lang.String context,
                               java.util.List preferenceTypes)
                        throws PreferenceStoreException
Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types. Note that this listing is 'recursive', in that Preferences stored in context paths below the given one will also be returned. Note also that the data object is not loaded into any of the listed Preferences.

Specified by:
list in class PreferenceStore
Parameters:
context - the context path under which Preferences should be listed.
preferenceTypes - a list of strings, naming the preference types to include, or null if all preference types should be included.
Throws:
PreferenceStoreException - if an error occurs during the operation.

destroy

public void destroy(java.lang.String context,
                    java.util.List preferenceTypes)
             throws PreferenceStoreException
Destroys all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types. Note that this operation is 'recursive', in that Preferences stored in context paths below the given one will also be destroyed.

Specified by:
destroy in class PreferenceStore
Parameters:
context - the context path under which Preferences should be listed.
preferenceTypes - a list of strings, naming the preference types to include, or null if all preference types should be included.
Throws:
PreferenceStoreException - if an error occurs during the operation.

exists

public boolean exists(Preference pref)
               throws PreferenceStoreException
Returns true if persisted data exists for the given Preference.

Specified by:
exists in class PreferenceStore
Returns:
true if persisted data exists for the given Preference, false otherwise.
Throws:
PreferenceStoreException

getInputStream

public java.io.InputStream getInputStream(Preference pref)
                                   throws EntryNotFoundException,
                                          PreferenceStoreException
Gets an InputStream for reading the data of the given Preference.

This method is provided in conjunction with getOutputStream(oracle.portal.provider.v2.preference.Preference, boolean) as a way of streamlining the process of copying data between PreferenceStores, since data can be copied directly from the InputStream of one Preference to the OutputStream of another, without having to instantiate a PreferenceDataObject.

Specified by:
getInputStream in class PreferenceStore
Throws:
EntryNotFoundException - if no data for the given Preference exists.
PreferenceStoreException - if any other error occurs during the operation.

getOutputStream

public java.io.OutputStream getOutputStream(Preference pref,
                                            boolean overwrite)
                                     throws EntryAlreadyExistsException,
                                            PreferenceStoreException
Gets an OutputStream for writing the data of the given Preference directly into storage.

This method is provided in conjunction with getInputStream(oracle.portal.provider.v2.preference.Preference) as a way of streamlining the process of copying data between PreferenceStores, since data can be copied directly from the InputStream of one Preference to the OutputStream of another, without having to instantiate a PreferenceDataObject.

Specified by:
getOutputStream in class PreferenceStore
Throws:
EntryAlreadyExistsException - if overwrite was false and data for the given Preference already exists in storage.
PreferenceStoreException - if any other error occurs during the operation.

destroy

public void destroy(Preference pref)
             throws PreferenceStoreException
Destroys the data persisted for the given Preference.

Specified by:
destroy in class PreferenceStore
Parameters:
pref - the Preference whose persisted data should be destroyed.
Throws:
PreferenceStoreException - if an error occurs during the operation.

validate

public void validate(java.lang.String context,
                     ValidationError errors)
Validates the internal state of this DBPreferenceStore instance. Errors found are reported using the supplied ValidationError instance.

Specified by:
validate in interface Validateable
Overrides:
validate in class PreferenceStore
Parameters:
context - The context of the calling instance.
errors - The current list of errors.

Oracle Fusion Middleware
Java API Reference for Oracle PDK Java
11g Release 1 (11.1.1)
E10691-01

Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.