1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.database;
|
12
|
|
13
|
import java.sql.SQLException;
|
14
|
|
15
|
import javax.sql.DataSource;
|
16
|
|
17
|
import org.apache.commons.dbcp.BasicDataSource;
|
18
|
import org.apache.commons.pool.impl.GenericObjectPool;
|
19
|
import org.apache.log4j.Logger;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created Sep 22, 2009
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class NomenclaturalCodeAwareDataSource extends BasicDataSource {
|
29
|
private static final Logger logger = Logger
|
30
|
.getLogger(NomenclaturalCodeAwareDataSource.class);
|
31
|
|
32
|
private NomenclaturalCode nomenclaturalCode;
|
33
|
|
34
|
public NomenclaturalCode getNomenclaturalCode() {
|
35
|
return nomenclaturalCode;
|
36
|
}
|
37
|
|
38
|
public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
|
39
|
this.nomenclaturalCode = nomenclaturalCode;
|
40
|
}
|
41
|
|
42
|
/* FIXME This is a workaround to solve a problem with dbcp connection pooling.
|
43
|
* Remove this when dbcp connection pool gets configured correctly
|
44
|
*
|
45
|
* (non-Javadoc)
|
46
|
* @see org.apache.commons.dbcp.BasicDataSource#createDataSource()
|
47
|
*/
|
48
|
@Override
|
49
|
protected synchronized DataSource createDataSource() throws SQLException {
|
50
|
super.createDataSource();
|
51
|
connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
|
52
|
return dataSource;
|
53
|
}
|
54
|
}
|