Class DataSourceHelper

java.lang.Object
org.nuxeo.runtime.datasource.DataSourceHelper

public class DataSourceHelper extends Object
Helper class to look up DataSources without having to deal with vendor-specific JNDI prefixes.
Author:
Thierry Delprat, Florent Guillaume
  • Method Details

    • getDataSourceJNDIName

      public static String getDataSourceJNDIName(String name)
      Look up a datasource JNDI name given a partial name.

      For a datasource "jdbc/foo", then it's sufficient to pass "foo" to this method.

      Returns:
      the datasource JNDI name
    • relativize

      protected static String relativize(String name)
    • getDataSource

      public static DataSource getDataSource(String partialName) throws NamingException
      Look up a datasource given a partial name.

      For a datasource "jdbc/foo", then it's sufficient to pass "foo" to this method.

      Parameters:
      partialName - the partial name
      Returns:
      the datasource
      Throws:
      NamingException
    • getDataSource

      public static DataSource getDataSource(String partialName, boolean noSharing) throws NamingException
      Look up a datasource given a partial name.

      For a datasource "jdbc/foo", then it's sufficient to pass "foo" to this method.

      Parameters:
      partialName - the partial name
      noSharing - true to request an unshared datasource
      Returns:
      the datasource
      Throws:
      NamingException
    • getDataSource

      public static <T> T getDataSource(String name, Class<T> clazz) throws NamingException
      Throws:
      NamingException
    • getDataSource

      public static <T> T getDataSource(String name, Class<T> clazz, boolean noSharing) throws NamingException
      Throws:
      NamingException