Class DataSourceLinkFactory
java.lang.Object
org.apache.naming.factory.ResourceLinkFactory
org.apache.naming.factory.DataSourceLinkFactory
- All Implemented Interfaces:
ObjectFactory
Object factory for resource links for shared data sources.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple wrapper class that will allow a user to configure a ResourceLink for a data source so that whenDataSource.getConnection()is called, it will invokeDataSource.getConnection(String, String)with the preconfigured username and password. -
Field Summary
Fields inherited from class ResourceLinkFactory
sm -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) Create a new resource instance.static voidsetGlobalContext(Context newGlobalContext) Set the global JNDI context used for lookups.protected ObjectwrapDataSource(Object datasource, String username, String password) Wrap a DataSource with a handler that injects the configured username and password whengetConnection()is called.Methods inherited from class ResourceLinkFactory
deregisterGlobalResourceAccess, deregisterGlobalResourceAccess, registerGlobalResourceAccess
-
Constructor Details
-
DataSourceLinkFactory
public DataSourceLinkFactory()Default constructor.
-
-
Method Details
-
setGlobalContext
Set the global JNDI context used for lookups.- Parameters:
newGlobalContext- The new global context
-
getObjectInstance
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws NamingExceptionDescription copied from class:ResourceLinkFactoryCreate a new resource instance.- Specified by:
getObjectInstancein interfaceObjectFactory- Overrides:
getObjectInstancein classResourceLinkFactory- Parameters:
name- the bound namenameCtx- unusedenvironment- unused- Returns:
- the object instance
- Throws:
NamingException- if an error occur creating the instance
-
wrapDataSource
protected Object wrapDataSource(Object datasource, String username, String password) throws NamingException Wrap a DataSource with a handler that injects the configured username and password whengetConnection()is called.- Parameters:
datasource- The DataSource to wrapusername- The username to injectpassword- The password to inject- Returns:
- the wrapped DataSource proxy
- Throws:
NamingException- if wrapping fails
-