Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
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
 */
27
public class NomenclaturalCodeAwareDataSource extends BasicDataSource {
28
	@SuppressWarnings("unused")
29
	private static final Logger logger = Logger.getLogger(NomenclaturalCodeAwareDataSource.class);
30
	
31
	private NomenclaturalCode nomenclaturalCode;
32

    
33
	public NomenclaturalCode getNomenclaturalCode() {
34
		return nomenclaturalCode;
35
	}
36

    
37
	public void setNomenclaturalCode(NomenclaturalCode nomenclaturalCode) {
38
		this.nomenclaturalCode = nomenclaturalCode;
39
	}
40
	
41
	/* FIXME This is a workaround to solve a problem with dbcp connection pooling.
42
	 * Remove this when dbcp connection pool gets configured correctly
43
	 * 
44
	 * (non-Javadoc)
45
	 * @see org.apache.commons.dbcp.BasicDataSource#createDataSource()
46
	 */
47
	@Override
48
	protected synchronized DataSource createDataSource() throws SQLException {
49
		super.createDataSource();
50
		connectionPool.setWhenExhaustedAction(GenericObjectPool.WHEN_EXHAUSTED_GROW);
51
		return dataSource;
52
	}
53
}
(16-16/20)