public class DataSourceInitialContextBinder extends Object implements AutoCloseable
DataSources easily to the usual JNDI
names (java:/comp/env/jdbc/<DataSourceName>).
Sets the Context.INITIAL_CONTEXT_FACTORY
and Context.URL_PKG_PREFIXES system properties when loaded by the
class loader.| Constructor and Description |
|---|
DataSourceInitialContextBinder()
Creates an instance of this class, setting up an
InitialContext
to use. |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(String name,
DataSource dataSource)
Binds a data source to a name.
|
void |
close()
Unbinds all data sources currently bound by this instance of this class.
|
void |
unbind(DataSource dataSource)
Unbinds a data source.
|
void |
unbindAll()
Unbinds all data sources that were previously bound by this instance of
this class.
|
public DataSourceInitialContextBinder()
throws NamingException
InitialContext
to use.NamingException - if an error occurs setting up the
InitialContext.public void bind(String name, DataSource dataSource) throws NamingException
java:/comp/env/jdbc/.name - the name to which to bind the given data source.dataSource - a DataSource.NamingException - if an error occurs during binding.public void unbind(DataSource dataSource) throws NamingException
dataSource - the DataSource to unbind.NamingException - if an error occurs during unbinding.public void unbindAll()
throws NamingException
NamingException - if an error occurs during unbinding.public void close()
throws Exception
InitialContext.close in interface AutoCloseableException - if an error occurs during unbinding or closing.Copyright © 2012–2020 Emory University. All rights reserved.