| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectatg.nucleus.logging.VariableArgumentApplicationLoggingImpl
atg.nucleus.GenericService
atg.service.jdbc.SwitchingDataSource
public class SwitchingDataSource
A DataSource which can switch between two or more underlying
 DataSources. All DataSource method calls are passed through to the
 currentDataSource.
| Field Summary | |
|---|---|
| static java.lang.String | CLASS_VERSIONClass version string | 
| Fields inherited from class atg.nucleus.GenericService | 
|---|
| SERVICE_INFO_KEY | 
| Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging | 
|---|
| DEFAULT_LOG_TRACE_STATUS | 
| Fields inherited from interface atg.nucleus.logging.ApplicationLogging | 
|---|
| DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS | 
| Constructor Summary | |
|---|---|
| SwitchingDataSource()Empty constructor | |
| Method Summary | ||
|---|---|---|
|  void | addSwitchingDataSourceEventListener(atg.service.jdbc.SwitchingDataSourceEventListener l)add a listener | |
| protected  boolean | checkSelectiveCacheInvalidationEnabled() | |
|  void | doStartService()Start the service. | |
|  java.sql.Connection | getConnection()Attempt to establish a database connection | |
|  java.sql.Connection | getConnection(java.lang.String pUser,
              java.lang.String pPassword)Attempt to establish a database connection | |
|  javax.sql.DataSource | getCurrentDataSource()Get the data source currently being used: all DataSource APIs are passed through to the currentDataSource | |
|  java.lang.String | getCurrentDataSourceName()Get property currentDataSourceName | |
|  ServiceMap | getDataSources()Get property dataSources, which is map of data source names
 to DataSource services. | |
|  java.lang.String[] | getDataStoreNames() | |
|  java.lang.Object[] | getDataStores() | |
|  java.lang.String | getInfoForDataSource(java.lang.String pName)Gets an informational String for the dataSource identified by the given pName. | |
|  java.lang.String | getInitialDataSourceName()Get property initialDataSourceName | |
|  java.lang.Object | getLiveDataStore()Returns the 'live' data store. | |
|  java.lang.String | getLiveDataStoreName()Returns the identifier of the 'live' data store. | |
|  int | getLoginTimeout()Gets the maximum time in seconds that this data source will wait while attempting to connect to a database. | |
|  java.io.PrintWriter | getLogWriter()Get the log writer for this data source. | |
|  javax.sql.DataSource | getNextDataSource()Get property nextDataSource, which is the data source that
 will become thecurrentDataSourcewhen #performSwitch() is
 called | |
|  java.lang.String | getNextDataSourceName()Get property nextDataSourceName | |
|  java.lang.String | getPathForDataSource(java.lang.String pName)Gets the absolute name of the dataSource identified by the given pName. | |
|  MutableRepository | getRepository()Get property repository | |
|  java.lang.Object | getStagingDataStore()Returns the 'staging' data store. | |
|  java.lang.String | getStagingDataStoreName()Returns the identifier of the 'staging' data store. | |
|  int | getSwitchingDataSourceEventListenerCount()get the # of listeners | |
|  atg.service.jdbc.SwitchingDataSourceEventListener[] | getSwitchingDataSourceEventListeners()get a copy of listeners | |
|  java.lang.String | getSwitchingDataSourceName()Get property switchingDataSourceName | |
|  boolean | hasListener(atg.service.jdbc.SwitchingDataSourceEventListener pListener)Determine if the specified object is in our listener list | |
|  boolean | isAccessBeforeStart() | |
|  boolean | isSelectiveCacheInvalidationEnabled() | |
|  boolean | isWrapperFor(java.lang.Class<?> pInterface)Returns true if this class implements the pInterface argument | |
|  void | performSwitch()Perform the second and final phase of the switch process. | |
|  void | prepareNextDataSource(java.lang.String pName)Prepare to use the named data source at the next switch. | |
|  void | prepareNextDataSource(java.lang.String pName,
                      boolean pRevert) | |
|  void | prepareNextDataSource(java.lang.String pName,
                      atg.adapter.gsa.SelectiveCacheInvalidationEvent[] pSelectiveCacheInvalidationEvents)Prepare to use the named data source at the next switch. | |
|  void | prepareSwitch()Performs whatever preparations are necessary for an impending data store switch. | |
|  void | prepareSwitch(atg.adapter.gsa.SelectiveCacheInvalidationEvent[] pSelectiveCacheInvalidationEvents)Performs whatever preparations are necessary for an impending data store switch. | |
|  void | removeSwitchingDataSourceEventListener(atg.service.jdbc.SwitchingDataSourceEventListener l)remove a listener | |
|  void | revertPrepareSwitch()Reverts the preparations done by a call to prepareSwitch(). | |
|  void | setAccessBeforeStart(boolean pAccessBeforeStart) | |
|  void | setDataSources(ServiceMap pDataSources)Set property dataSources, which is map of data source names
 to DataSource services. | |
|  void | setInitialDataSourceName(java.lang.String pInitialDataSourceName)Set property initialDataSourceName | |
|  void | setLoginTimeout(int pSeconds)Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. | |
|  void | setLogWriter(java.io.PrintWriter pWriter)Get the log writer for this data source. | |
|  void | setRepository(MutableRepository pRepository)Set property repository | |
|  void | setSwitchingDataSourceName(java.lang.String pSwitchingDataSourceName)Set property switchingDataSourceName | |
| 
 | unwrap(java.lang.Class<T> pInterface)Returns an object that implements the given interface | |
| Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl | 
|---|
| vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static java.lang.String CLASS_VERSION
| Constructor Detail | 
|---|
public SwitchingDataSource()
| Method Detail | 
|---|
public javax.sql.DataSource getCurrentDataSource()
currentDataSource
currentDataSource, guaranteed to not be null
 if this service started successfullypublic java.lang.String getCurrentDataSourceName()
currentDataSourceName
currentDataSourceNamepublic void setDataSources(ServiceMap pDataSources)
dataSources, which is map of data source names
 to DataSource services.
pDataSources - new value to setpublic ServiceMap getDataSources()
dataSources, which is map of data source names
 to DataSource services.
dataSourcespublic void setInitialDataSourceName(java.lang.String pInitialDataSourceName)
initialDataSourceName
pInitialDataSourceName - new value to setpublic java.lang.String getInitialDataSourceName()
initialDataSourceName
initialDataSourceNamepublic javax.sql.DataSource getNextDataSource()
nextDataSource, which is the data source that
 will become the currentDataSource when #performSwitch() is
 called
nextDataSource, which is guaranteed to not be null
 if this service started successfullypublic java.lang.String getNextDataSourceName()
nextDataSourceName
nextDataSourceNamepublic boolean isSelectiveCacheInvalidationEnabled()
isSelectiveCacheInvalidationEnabled in interface atg.deployment.agent.SelectiveCacheInvalidationSwitchablepublic void setRepository(MutableRepository pRepository)
repository
pRepository - new value to setpublic MutableRepository getRepository()
repository
repositorypublic void setSwitchingDataSourceName(java.lang.String pSwitchingDataSourceName)
switchingDataSourceName
pSwitchingDataSourceName - new value to setpublic java.lang.String getSwitchingDataSourceName()
switchingDataSourceName
switchingDataSourceNamepublic void setAccessBeforeStart(boolean pAccessBeforeStart)
public boolean isAccessBeforeStart()
public java.lang.String getPathForDataSource(java.lang.String pName)
pName.
pName - name of data source desired
pName, or null if either no such
  dataSource exists, or if we are unable to determine the absolute
  name.public java.lang.String getInfoForDataSource(java.lang.String pName)
pName.
pName - name of data source desired
pName, or null if either no such
  dataSource exists, or if we are unable to determine either of there
  features.public void addSwitchingDataSourceEventListener(atg.service.jdbc.SwitchingDataSourceEventListener l)
public void removeSwitchingDataSourceEventListener(atg.service.jdbc.SwitchingDataSourceEventListener l)
public atg.service.jdbc.SwitchingDataSourceEventListener[] getSwitchingDataSourceEventListeners()
public int getSwitchingDataSourceEventListenerCount()
public boolean hasListener(atg.service.jdbc.SwitchingDataSourceEventListener pListener)
pListener - listener to look for
public void prepareNextDataSource(java.lang.String pName)
                           throws java.sql.SQLException
pName - name of data source we will switch to next
java.sql.SQLException - if the supplied name is null or does not refer
 to a data source we know about
public void prepareNextDataSource(java.lang.String pName,
                                  boolean pRevert)
                           throws java.sql.SQLException
java.sql.SQLException
public void prepareNextDataSource(java.lang.String pName,
                                  atg.adapter.gsa.SelectiveCacheInvalidationEvent[] pSelectiveCacheInvalidationEvents)
                           throws java.sql.SQLException
pName - name of data source we will switch to nextpSelectiveCacheInvalidationEvents - SelectiveCacheInvalidationEvents
java.sql.SQLException - if the supplied name is null or does not refer
 to a data source we know about
public void performSwitch()
                   throws java.lang.RuntimeException
nextDataSource be the currentDataSource.
 We do not allow either next or current to be null, so we leave
 nextDataSource as-is. This way is it always safe to call
 this method, but it won't do anything except send an event unless a
 data source has been prepared.
performSwitch in interface atg.deployment.agent.Switchablejava.lang.RuntimeException - if there is a problem switching
public void doStartService()
                    throws ServiceException
doStartService in class GenericServiceServiceException - id this object was not properly configured
 before being startedpublic java.lang.String[] getDataStoreNames()
getDataStoreNames in interface atg.deployment.agent.Switchablepublic java.lang.Object[] getDataStores()
getDataStores in interface atg.deployment.agent.Switchablepublic java.lang.String getLiveDataStoreName()
getLiveDataStoreName in interface atg.deployment.agent.Switchablepublic java.lang.Object getLiveDataStore()
getLiveDataStore in interface atg.deployment.agent.Switchablepublic java.lang.String getStagingDataStoreName()
getStagingDataStoreName in interface atg.deployment.agent.Switchablepublic java.lang.Object getStagingDataStore()
getStagingDataStore in interface atg.deployment.agent.Switchable
public void prepareSwitch()
                   throws java.lang.Exception
Exception is thrown to allow whatever data store native exception that gets thrown to be passed out in tact.
prepareSwitch in interface atg.deployment.agent.Switchablejava.lang.Exception
public void prepareSwitch(atg.adapter.gsa.SelectiveCacheInvalidationEvent[] pSelectiveCacheInvalidationEvents)
                   throws java.lang.Exception
Exception is thrown to allow whatever data store native exception that gets thrown to be passed out in tact.
prepareSwitch in interface atg.deployment.agent.SelectiveCacheInvalidationSwitchablepSelectiveCacheInvalidationEvents - SelectiveCacheInvalidationEvents
java.lang.Exception
public void revertPrepareSwitch()
                         throws java.lang.Exception
revertPrepareSwitch in interface atg.deployment.agent.Switchablejava.lang.Exceptionprotected boolean checkSelectiveCacheInvalidationEnabled()
public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcejava.sql.SQLException - if a database-access error occurs
public java.sql.Connection getConnection(java.lang.String pUser,
                                         java.lang.String pPassword)
                                  throws java.sql.SQLException
getConnection in interface javax.sql.DataSourcepUser - the database user on whose behalf the Connection is being
 madepPassword - the user's password
java.sql.SQLException - if a database-access error occurs
public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.
getLogWriter in interface javax.sql.CommonDataSourcejava.sql.SQLException - if a database-access error occurs
public void setLogWriter(java.io.PrintWriter pWriter)
                  throws java.sql.SQLException
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.
setLogWriter in interface javax.sql.CommonDataSourcethe - the new log writer for this data source: to disable, set to
 null
java.sql.SQLException - if a database-access error occurs
public int getLoginTimeout()
                    throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcethe - data source login time limit
java.sql.SQLException - if a database-access error occurs
public void setLoginTimeout(int pSeconds)
                     throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcethe - data source login time limit
java.sql.SQLException - if a database-access error occurs
public <T> T unwrap(java.lang.Class<T> pInterface)
         throws java.sql.SQLException
unwrap in interface java.sql.WrapperpInterface - the interface of the object to return
java.sql.SQLException - if no object is found that implements
 the given interface
public boolean isWrapperFor(java.lang.Class<?> pInterface)
                     throws java.sql.SQLException
isWrapperFor in interface java.sql.WrapperpInterface - the interface to test
java.sql.SQLException - if there's an error determining whether this is
 a wrapper for the interface| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||