public class SwitchingDataSource extends GenericService implements javax.sql.DataSource, atg.deployment.agent.SelectiveCacheInvalidationSwitchable
currentDataSource.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
SERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
SwitchingDataSource()
Empty constructor
|
| Modifier and Type | Method and Description |
|---|---|
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 the currentDataSource when #performSwitch() is
called |
java.lang.String |
getNextDataSourceName()
Get property
nextDataSourceName |
java.util.logging.Logger |
getParentLogger()
Return the parent Logger of all the Loggers used by this data source.
|
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 |
<T> T |
unwrap(java.lang.Class<T> pInterface)
Returns an object that implements the given interface
|
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic javax.sql.DataSource getCurrentDataSource()
currentDataSourcecurrentDataSource, guaranteed to not be null
if this service started successfullypublic java.lang.String getCurrentDataSourceName()
currentDataSourceNamecurrentDataSourceNamepublic 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)
initialDataSourceNamepInitialDataSourceName - new value to setpublic java.lang.String getInitialDataSourceName()
initialDataSourceNameinitialDataSourceNamepublic javax.sql.DataSource getNextDataSource()
nextDataSource, which is the data source that
will become the currentDataSource when #performSwitch() is
callednextDataSource, which is guaranteed to not be null
if this service started successfullypublic java.lang.String getNextDataSourceName()
nextDataSourceNamenextDataSourceNamepublic boolean isSelectiveCacheInvalidationEnabled()
isSelectiveCacheInvalidationEnabled in interface atg.deployment.agent.SelectiveCacheInvalidationSwitchablepublic void setRepository(MutableRepository pRepository)
repositorypRepository - new value to setpublic MutableRepository getRepository()
repositoryrepositorypublic void setSwitchingDataSourceName(java.lang.String pSwitchingDataSourceName)
switchingDataSourceNamepSwitchingDataSourceName - new value to setpublic java.lang.String getSwitchingDataSourceName()
switchingDataSourceNameswitchingDataSourceNamepublic void setAccessBeforeStart(boolean pAccessBeforeStart)
public boolean isAccessBeforeStart()
public java.lang.String getPathForDataSource(java.lang.String pName)
pName.pName - name of data source desiredpName, 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 desiredpName, 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 forpublic void prepareNextDataSource(java.lang.String pName)
throws java.sql.SQLException
pName - name of data source we will switch to nextjava.sql.SQLException - if the supplied name is null or does not refer
to a data source we know aboutpublic void prepareNextDataSource(java.lang.String pName,
boolean pRevert)
throws java.sql.SQLException
java.sql.SQLExceptionpublic 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 - SelectiveCacheInvalidationEventsjava.sql.SQLException - if the supplied name is null or does not refer
to a data source we know aboutpublic 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 switchingpublic 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.Switchablepublic 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.Exceptionpublic 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 - SelectiveCacheInvalidationEventsjava.lang.Exceptionpublic 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 occurspublic 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 passwordjava.sql.SQLException - if a database-access error occurspublic 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 occurspublic 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
nulljava.sql.SQLException - if a database-access error occurspublic int getLoginTimeout()
throws java.sql.SQLException
getLoginTimeout in interface javax.sql.CommonDataSourcethe - data source login time limitjava.sql.SQLException - if a database-access error occurspublic void setLoginTimeout(int pSeconds)
throws java.sql.SQLException
setLoginTimeout in interface javax.sql.CommonDataSourcethe - data source login time limitjava.sql.SQLException - if a database-access error occurspublic <T> T unwrap(java.lang.Class<T> pInterface)
throws java.sql.SQLException
unwrap in interface java.sql.WrapperpInterface - the interface of the object to returnjava.sql.SQLException - if no object is found that implements
the given interfacepublic boolean isWrapperFor(java.lang.Class<?> pInterface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.WrapperpInterface - the interface to testjava.sql.SQLException - if there's an error determining whether this is
a wrapper for the interfacepublic java.util.logging.Logger getParentLogger()
throws java.sql.SQLFeatureNotSupportedException
getParentLogger in interface javax.sql.CommonDataSourcejava.sql.SQLFeatureNotSupportedException - if the data source does not use java.util.logging.