Class ReferenceableDataSource
- java.lang.Object
-
- org.apache.derby.jdbc.BasicEmbeddedDataSource40
-
- org.apache.derby.jdbc.ReferenceableDataSource
-
- All Implemented Interfaces:
java.io.Serializable
,java.sql.Wrapper
,javax.naming.spi.ObjectFactory
,javax.sql.CommonDataSource
,javax.sql.DataSource
,EmbeddedDataSourceInterface
- Direct Known Subclasses:
EmbeddedDataSource
public class ReferenceableDataSource extends BasicEmbeddedDataSource40 implements javax.naming.spi.ObjectFactory
The data source factory for Derby embedded driver data sources.This factory reconstructs a Derby data source object when it is retrieved from JNDI. References are needed since many naming services don't have the ability to store Java objects in their serialized form. When a data source object is bound in this type of naming service the
Reference
for that object is actually stored by the JNDI implementation, not the data source object itself.A JNDI administrator is responsible for making sure that both the object factory and data source implementation classes provided by a JDBC driver vendor are accessible to the JNDI service provider at runtime.
An object factory implements the
ObjectFactory
interface. This interface contains a single method,getObjectInstance
which is called by a JNDI service provider to reconstruct an object when that object is retrieved from JNDI. A JDBC driver vendor should provide an object factory as part of their JDBC product.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Class<?>[]
BOOLEAN_ARG
private static java.lang.Class<?>[]
INT_ARG
private static long
serialVersionUID
private static java.lang.Class<?>[]
SHORT_ARG
private static java.lang.Class<?>[]
STRING_ARG
-
Fields inherited from class org.apache.derby.jdbc.BasicEmbeddedDataSource40
attributesAsPassword, connectionAttributes, createDatabase, databaseName, dataSourceName, description, driver, jdbcurl, loginTimeout, shutdownDatabase
-
-
Constructor Summary
Constructors Constructor Description ReferenceableDataSource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameContext, java.util.Hashtable<?,?> environment)
Reconstructs a Derby embedded-driver data source object from a JNDI data source reference.private static void
setBeanProperties(java.lang.Object ds, javax.naming.Reference ref)
-
Methods inherited from class org.apache.derby.jdbc.BasicEmbeddedDataSource40
equals, findDriver, getAttributesAsPassword, getConnection, getConnection, getConnection, getConnectionAttributes, getCreateDatabase, getDatabaseName, getDataSourceName, getDescription, getLoginTimeout, getLogWriter, getParentLogger, getPassword, getShutdownDatabase, getUser, hashCode, isWrapperFor, setAttributesAsPassword, setConnectionAttributes, setCreateDatabase, setDatabaseName, setDataSourceName, setDescription, setLoginTimeout, setLogWriter, setPassword, setShutdownDatabase, setupResourceAdapter, setUser, unwrap, update
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
STRING_ARG
private static final java.lang.Class<?>[] STRING_ARG
-
INT_ARG
private static final java.lang.Class<?>[] INT_ARG
-
BOOLEAN_ARG
private static final java.lang.Class<?>[] BOOLEAN_ARG
-
SHORT_ARG
private static final java.lang.Class<?>[] SHORT_ARG
-
-
Method Detail
-
getObjectInstance
public java.lang.Object getObjectInstance(java.lang.Object refObj, javax.naming.Name name, javax.naming.Context nameContext, java.util.Hashtable<?,?> environment) throws java.lang.Exception
Reconstructs a Derby embedded-driver data source object from a JNDI data source reference.The
getObjectInstance
method is passed a reference that corresponds to the object being retrieved as its first parameter. The other parameters are optional in the case of JDBC data source objects. The object factory should use the information contained in the reference to reconstruct the data source. If for some reason, a data source object cannot be reconstructed from the reference, a value ofnull
may be returned. This allows other object factories that may be registered in JNDI to be tried. If an exception is thrown then no other object factories are tried.- Specified by:
getObjectInstance
in interfacejavax.naming.spi.ObjectFactory
- Parameters:
refObj
- the possiblynull
object containing location or reference information that can be used in creating an objectname
- the name of this object relative tonameContext
, ornull
if no name is specifiednameContext
- context relative to which the name parameter is specified, ornull
if name is relative to the default initial context.environment
- possiblynull
environment that is used in creating the object.- Returns:
- Object created, or
null
if no attempt to create the object is made. - Throws:
java.lang.Exception
- if recreating the object fails
-
setBeanProperties
private static void setBeanProperties(java.lang.Object ds, javax.naming.Reference ref) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-