Class DataSourceLinkFactory

java.lang.Object
org.apache.naming.factory.ResourceLinkFactory
org.apache.naming.factory.DataSourceLinkFactory
All Implemented Interfaces:
ObjectFactory

public class DataSourceLinkFactory extends ResourceLinkFactory

Object factory for resource links for shared data sources.

  • Constructor Details

    • DataSourceLinkFactory

      public DataSourceLinkFactory()
      Default constructor.
  • Method Details

    • setGlobalContext

      public static void setGlobalContext(Context newGlobalContext)
      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 NamingException
      Description copied from class: ResourceLinkFactory
      Create a new resource instance.
      Specified by:
      getObjectInstance in interface ObjectFactory
      Overrides:
      getObjectInstance in class ResourceLinkFactory
      Parameters:
      name - the bound name
      nameCtx - unused
      environment - 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 when getConnection() is called.
      Parameters:
      datasource - The DataSource to wrap
      username - The username to inject
      password - The password to inject
      Returns:
      the wrapped DataSource proxy
      Throws:
      NamingException - if wrapping fails