Class ClientDataSourceFactory
- All Implemented Interfaces:
ObjectFactory
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 2.0 product.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Class[]
Reflect lookup for Java bean method taking a single boolean argprivate static final Class[]
Reflect lookup for Java bean method taking a single int argprivate static final Class[]
Reflect lookup for Java bean method taking a single short argprivate static final Class[]
Reflect lookup for Java bean method taking a single String arg -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetObjectInstance
(Object refObj, Name name, Context nameContext, Hashtable environment) Reconstructs a Derby client-driver data source object from a JNDI data source reference.private static void
setBeanProperties
(Object ds, Reference ref) Set the Java bean properties for an object from its Reference.
-
Field Details
-
STRING_ARG
Reflect lookup for Java bean method taking a single String arg -
INT_ARG
Reflect lookup for Java bean method taking a single int arg -
BOOLEAN_ARG
Reflect lookup for Java bean method taking a single boolean arg -
SHORT_ARG
Reflect lookup for Java bean method taking a single short arg
-
-
Constructor Details
-
ClientDataSourceFactory
public ClientDataSourceFactory()
-
-
Method Details
-
getObjectInstance
public Object getObjectInstance(Object refObj, Name name, Context nameContext, Hashtable environment) throws Exception Reconstructs a Derby client-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 interfaceObjectFactory
- 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:
Exception
- if recreating the object fails
-
setBeanProperties
Set the Java bean properties for an object from its Reference. The Reference contains a set of StringRefAddr values with the key being the bean name and the value a String representation of the bean's value. This code looks for setXXX() method where the set method corresponds to the standard bean naming scheme and has a single parameter of type String, int, boolean or short.- Throws:
Exception
-