Package org.nuxeo.runtime.datasource
Class DataSourceHelper
java.lang.Object
org.nuxeo.runtime.datasource.DataSourceHelper
Helper class to look up
DataSource
s without having to deal with vendor-specific JNDI prefixes.- Author:
- Thierry Delprat, Florent Guillaume
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
getDataSourceJNDIName
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
-
getDataSource
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
- Throws:
NamingException
-
getDataSource
public static <T> T getDataSource(String name, Class<T> clazz, boolean noSharing) throws NamingException - Throws:
NamingException
-