forked from IQSS/dataverse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide @DataSourceDefinition for app-level DB config. IQSS#7418
The JNDI names have been changed to be conform with Java EE 7. See https://github.com/javaee-samples/javaee7-samples/tree/master/jpa/datasourcedefinition-applicationxml-pu and others for working examples. (Staying with the old name was not successfull.)
- Loading branch information
1 parent
3fcc239
commit 9dfe7b8
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/edu/harvard/iq/dataverse/util/DataSourceProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package edu.harvard.iq.dataverse.util; | ||
|
||
import javax.annotation.Resource; | ||
import javax.annotation.sql.DataSourceDefinition; | ||
import javax.enterprise.inject.Produces; | ||
import javax.inject.Singleton; | ||
import javax.sql.DataSource; | ||
|
||
@Singleton | ||
@DataSourceDefinition( | ||
name = "java:app/jdbc/dataverse", | ||
// Using PGXADataSource instead of deprecated PGPoolingDataSource | ||
className = "org.postgresql.xa.PGXADataSource", | ||
user = "dataverse", | ||
password = "${ALIAS=db_password_alias}", | ||
serverName = "postgresql", | ||
portNumber = 5432, | ||
databaseName = "dataverse", | ||
minPoolSize = 10, | ||
maxPoolSize = 200) | ||
public class DataSourceProducer { | ||
|
||
@Resource(lookup="java:app/jdbc/dataverse") | ||
DataSource ds; | ||
|
||
@Produces | ||
public DataSource getDatasource() { | ||
return ds; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters