Package org.nuxeo.runtime.datasource
Class DataSourceHelper
- java.lang.Object
-
- org.nuxeo.runtime.datasource.DataSourceHelper
-
public class DataSourceHelper extends Object
Helper class to look upDataSources 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 DataSourcegetDataSource(String partialName)Look up a datasource given a partial name.static DataSourcegetDataSource(String partialName, boolean noSharing)Look up a datasource given a partial name.static <T> TgetDataSource(String name, Class<T> clazz)static <T> TgetDataSource(String name, Class<T> clazz, boolean noSharing)static StringgetDataSourceJNDIName(String name)Look up a datasource JNDI name given a partial name.protected static Stringrelativize(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-trueto 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
-
-