Class DataSourceLinkFactory

  • All Implemented Interfaces:
    javax.naming.spi.ObjectFactory

    public class DataSourceLinkFactory
    extends ResourceLinkFactory

    Object factory for resource links for shared data sources.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DataSourceLinkFactory.DataSourceHandler
      Simple wrapper class that will allow a user to configure a ResourceLink for a data source so that when DataSource.getConnection() is called, it will invoke DataSource.getConnection(String, String) with the preconfigured username and password.
    • Constructor Detail

      • DataSourceLinkFactory

        public DataSourceLinkFactory()
        Default constructor.
    • Method Detail

      • setGlobalContext

        public static void setGlobalContext​(javax.naming.Context newGlobalContext)
        Set the global JNDI context used for lookups.
        Parameters:
        newGlobalContext - The new global context
      • getObjectInstance

        public java.lang.Object getObjectInstance​(java.lang.Object obj,
                                                  javax.naming.Name name,
                                                  javax.naming.Context nameCtx,
                                                  java.util.Hashtable<?,​?> environment)
                                           throws javax.naming.NamingException
        Description copied from class: ResourceLinkFactory
        Create a new resource instance.
        Specified by:
        getObjectInstance in interface javax.naming.spi.ObjectFactory
        Overrides:
        getObjectInstance in class ResourceLinkFactory
        name - the bound name
        nameCtx - unused
        environment - unused
        Returns:
        the object instance
        Throws:
        javax.naming.NamingException - if an error occur creating the instance
      • wrapDataSource

        protected java.lang.Object wrapDataSource​(java.lang.Object datasource,
                                                  java.lang.String username,
                                                  java.lang.String password)
                                           throws javax.naming.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:
        javax.naming.NamingException - if wrapping fails