Skip to content

Instantly share code, notes, and snippets.

View carlosbarragan's full-sized avatar

Carlos Barragan carlosbarragan

View GitHub Profile
@carlosbarragan
carlosbarragan / DataSourceProducer.java
Created November 29, 2016 16:00
Example for creating a DataSource via CDI
/*
* Please note for this to work you need to add the corresponding dependencies.
* In this case, we use https://github.com/brettwooldridge/HikariCP as connection pool
* and an embedded derby database.
*/
@Produces
public DataSource exposeDataSource() {
Properties props = new Properties();
props.setProperty("dataSource.databaseName", "mydb");
props.put("dataSource.logWriter", new PrintWriter(System.out));