org.apache.jetspeed.components.rdbms.ojb
Class ConnectionRepositoryEntry
java.lang.Object
org.apache.commons.dbcp.BasicDataSource
org.apache.jetspeed.components.rdbms.ojb.ConnectionRepositoryEntry
- All Implemented Interfaces:
- DataSource, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
public class ConnectionRepositoryEntry
- extends org.apache.commons.dbcp.BasicDataSource
- implements org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean
A JavaBean that configures an entry in OJB's ConnectionRepository
according to its properties. If a JCD alias is not specified, it defaults
to the bean's name in the Spring configuration. If the JDBC connection
descriptor already exists (e.g. because it has been defined in OJB's
configuration) the properties are merged into the existing descriptor
(see note about "platform" below), else the JDBC connection descriptor
is created.
If a JNDI name is set, the bean automatically configures a JDBC connection
descriptor with a connection factory of type
ConnectionFactoryManagedImpl
, else it uses
ConectionFactoryDBCPImpl
. This may be overridden my setting
the connection factory property explicitly.
Properties "driverClassName", "url", "username" and "password" are used
only if no JNDI name is set, i.e. if the connection factory uses the
driver to create data sources.
The bean derives the RDBMS platform setting from the configured
data source or database driver using OJB's JdbcMetadataUtils
class. At least until OJB 1.0.3, however, this class does not properly
distinguish the platforms "Oracle" and "Oracle9i"; it always assigns
"Oracle". In case of "Oracle", this bean therefore opens a connection,
obtains the version information from the database server and adjusts the
platform accordingly. This behaviour may be overridden by setting the
platform
property of the bean explicitly. Note that the
attribute "platform" of an already existing JCD is ignored. An already
existing JCD stems most likely from a configuration file "repository.xml".
As the DTD for "repository.xml" ("repository.dtd") defines a default
value for attribute "platform" ("Hsqldb"), it is in general impossible
to find out whether the platform attribute of an existing JCD has been set
explicitly or has simply assumed its default value.
- Version:
- $Id$
- Author:
- Michael Lipp
Fields inherited from class org.apache.commons.dbcp.BasicDataSource |
connectionPool, connectionProperties, dataSource, defaultAutoCommit, defaultCatalog, defaultReadOnly, defaultTransactionIsolation, initialSize, logWriter, maxActive, maxIdle, maxOpenPreparedStatements, maxWait, minEvictableIdleTimeMillis, minIdle, numTestsPerEvictionRun, poolPreparedStatements, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, validationQuery |
Methods inherited from class org.apache.commons.dbcp.BasicDataSource |
addConnectionProperty, close, createDataSource, getDefaultAutoCommit, getDefaultCatalog, getDefaultReadOnly, getDefaultTransactionIsolation, getInitialSize, getLogAbandoned, getLoginTimeout, getLogWriter, getMaxActive, getMaxIdle, getMaxOpenPreparedStatements, getMaxWait, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getRemoveAbandoned, getRemoveAbandonedTimeout, getTestOnBorrow, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getValidationQuery, isAccessToUnderlyingConnectionAllowed, isPoolPreparedStatements, removeConnectionProperty, setAccessToUnderlyingConnectionAllowed, setDefaultAutoCommit, setDefaultCatalog, setDefaultReadOnly, setDefaultTransactionIsolation, setInitialSize, setLogAbandoned, setLoginTimeout, setLogWriter, setMaxActive, setMaxIdle, setMaxOpenPreparedStatements, setMaxWait, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setPoolPreparedStatements, setRemoveAbandoned, setRemoveAbandonedTimeout, setTestOnBorrow, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setValidationQuery |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
private static final org.apache.commons.logging.Log log
jcdAlias
private String jcdAlias
platform
private String platform
connectionFactoryClass
private String connectionFactoryClass
jndiName
private String jndiName
driverClassName
private String driverClassName
url
private String url
username
private String username
password
private String password
jetspeedEngineScoped
private boolean jetspeedEngineScoped
externalDs
private DataSource externalDs
ConnectionRepositoryEntry
public ConnectionRepositoryEntry()
setBeanName
public void setBeanName(String beanName)
- Specified by:
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
- See Also:
BeanNameAware.setBeanName(java.lang.String)
getJcdAlias
public String getJcdAlias()
- Returns:
- Returns the jcdAlias.
setJcdAlias
public void setJcdAlias(String jcdAlias)
- Parameters:
jcdAlias
- The jcdAlias to set.
getJndiName
public String getJndiName()
- Returns:
- Returns the jndiName.
setJndiName
public void setJndiName(String jndiName)
- Parameters:
jndiName
- The jndiName to set.
getDriverClassName
public String getDriverClassName()
- Overrides:
getDriverClassName
in class org.apache.commons.dbcp.BasicDataSource
- Returns:
- Returns the driverClassName.
setDriverClassName
public void setDriverClassName(String driverClassName)
- Overrides:
setDriverClassName
in class org.apache.commons.dbcp.BasicDataSource
- Parameters:
driverClassName
- The driverClassName to set.
getPassword
public String getPassword()
- Overrides:
getPassword
in class org.apache.commons.dbcp.BasicDataSource
- Returns:
- Returns the password.
setPassword
public void setPassword(String password)
- Overrides:
setPassword
in class org.apache.commons.dbcp.BasicDataSource
- Parameters:
password
- The password to set.
getUrl
public String getUrl()
- Overrides:
getUrl
in class org.apache.commons.dbcp.BasicDataSource
- Returns:
- Returns the url.
setUrl
public void setUrl(String url)
- Overrides:
setUrl
in class org.apache.commons.dbcp.BasicDataSource
- Parameters:
url
- The url to set.
getUsername
public String getUsername()
- Overrides:
getUsername
in class org.apache.commons.dbcp.BasicDataSource
- Returns:
- Returns the username.
setUsername
public void setUsername(String username)
- Overrides:
setUsername
in class org.apache.commons.dbcp.BasicDataSource
- Parameters:
username
- The username to set.
getPlatform
public String getPlatform()
- Returns:
- Returns the platform.
setPlatform
public void setPlatform(String platform)
- Set the platform attribute of the JCD. Setting this property overrides
the value derived from the data source or database driver.
- Parameters:
platform
- The platform to set.
isJetspeedEngineScoped
public boolean isJetspeedEngineScoped()
- Returns:
- Returns if Jetspeed engine's ENC is used for JNDI lookups.
- See Also:
setJetspeedEngineScoped
setJetspeedEngineScoped
public void setJetspeedEngineScoped(boolean jetspeedEngineScoped)
- Sets the attribute "
org.apache.jetspeed.engineScoped
"
of the JDBC connection descriptor to "true
" or
"false
". If set, JNDI lookups of the connection will
be done using the environment naming context (ENC) of the Jetspeed
engine.
- Parameters:
jetspeedEngineScoped
- whether to use Jetspeed engine's ENC.
afterPropertiesSet
public void afterPropertiesSet()
throws Exception
- Specified by:
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
- Throws:
Exception
updateOraclePlatform
private void updateOraclePlatform(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor jcd,
DataSource ds)
throws org.apache.ojb.broker.accesslayer.LookupException,
IllegalAccessException,
InstantiationException,
SQLException
- Parameters:
jcd
-
- Throws:
org.apache.ojb.broker.accesslayer.LookupException
IllegalAccessException
InstantiationException
- throws SQLException
SQLException
getConnection
public Connection getConnection()
throws SQLException
- Specified by:
getConnection
in interface DataSource
- Overrides:
getConnection
in class org.apache.commons.dbcp.BasicDataSource
- Throws:
SQLException
getConnection
public Connection getConnection(String username,
String password)
throws SQLException
- Specified by:
getConnection
in interface DataSource
- Overrides:
getConnection
in class org.apache.commons.dbcp.BasicDataSource
- Throws:
SQLException
Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.