DataSourceLinkFactory (Apache Tomcat 9.0.106 API Documentation)
Description: declaration: package: org.apache.naming.factory, class: DataSourceLinkFactory

# 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.

- ## 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.

- ## Field Summary

  ### Fields inherited from class org.apache.naming.factory.ResourceLinkFactory

  `sm`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataSourceLinkFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)`
  Create a new resource instance.
  `static void`
  `setGlobalContext(Context newGlobalContext)`
  `protected Object`
  `wrapDataSource(Object datasource, String username, String password)`

  ### Methods inherited from class org.apache.naming.factory.ResourceLinkFactory

  `deregisterGlobalResourceAccess, deregisterGlobalResourceAccess, registerGlobalResourceAccess`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DataSourceLinkFactory

    public DataSourceLinkFactory()

- ## Method Details

  - ### setGlobalContext

    public static void setGlobalContext(Context newGlobalContext)

  - ### 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
    Throws:
      `NamingException`