1
2
3
4
5
6
7
8
9
10
11 package psiprobe.beans.accessors;
12
13 import java.sql.SQLException;
14
15 import org.vibur.dbcp.ViburDBCPDataSource;
16
17 import psiprobe.model.DataSourceInfo;
18
19
20
21
22 public class ViburCpDatasourceAccessor implements DatasourceAccessor {
23
24 @Override
25 public DataSourceInfo getInfo(final Object resource) throws SQLException {
26 DataSourceInfo dataSourceInfo = null;
27 if (canMap(resource)) {
28 ViburDBCPDataSource source = (ViburDBCPDataSource) resource;
29
30 dataSourceInfo = new DataSourceInfo();
31 dataSourceInfo.setBusyConnections(source.getPool().taken());
32 dataSourceInfo.setEstablishedConnections(
33 source.getPool().remainingCreated() + source.getPool().taken());
34 dataSourceInfo.setMaxConnections(source.getPoolMaxSize());
35 dataSourceInfo.setJdbcUrl(source.getJdbcUrl());
36 dataSourceInfo.setUsername(source.getUsername());
37 dataSourceInfo.setResettable(false);
38 dataSourceInfo.setType("vibur");
39 }
40 return dataSourceInfo;
41 }
42
43 @Override
44 public boolean reset(final Object resource) {
45 return false;
46 }
47
48 @Override
49 public boolean canMap(final Object resource) {
50 return "org.vibur.dbcp.ViburDBCPDataSource".equals(resource.getClass().getName())
51 && resource instanceof ViburDBCPDataSource;
52 }
53
54 }