Package org.nuxeo.runtime.datasource
Class DataSourceHelper
- java.lang.Object
-
- org.nuxeo.runtime.datasource.DataSourceHelper
-
public class DataSourceHelper extends Object
Helper class to look upDataSource
s without having to deal with vendor-specific JNDI prefixes.- Author:
- Thierry Delprat, Florent Guillaume
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DataSource
getDataSource(String partialName)
Look up a datasource given a partial name.static DataSource
getDataSource(String partialName, boolean noSharing)
Look up a datasource given a partial name.static <T> T
getDataSource(String name, Class<T> clazz)
static <T> T
getDataSource(String name, Class<T> clazz, boolean noSharing)
static String
getDataSourceJNDIName(String name)
Look up a datasource JNDI name given a partial name.protected static String
relativize(String name)
-
-
-
Method Detail
-
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
-
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 namenoSharing
-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
-
-