Skip to content

Instantly share code, notes, and snippets.

@webdevwilson
Created February 29, 2012 18:35
Show Gist options
  • Save webdevwilson/1943378 to your computer and use it in GitHub Desktop.
Save webdevwilson/1943378 to your computer and use it in GitHub Desktop.
public class DataSourceModule extends AbstractModule {
private DataSource dataSource;
private final String jndiName;
public DataSourceModule(final String jndiName)
{
this.jndiName = jndiName;
}
@Override
protected void configure()
{
final Provider<DataSource> provider = new JndiProvider<DataSource>(jndiName);
dataSource = provider.get();
}
@Provides
@Singleton
public DataSource getDataSource()
{
return dataSource;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment