1
2
3
4
5
6
7
8
9
10
11 package psiprobe.beans.accessors;
12
13 import org.apache.tomee.jdbc.TomEEDataSourceCreator;
14
15 import psiprobe.model.DataSourceInfo;
16
17
18
19
20
21 public class TomEeJdbcPoolDatasourceAccessor implements DatasourceAccessor {
22
23 @Override
24 public DataSourceInfo getInfo(Object resource) {
25 DataSourceInfo dataSourceInfo = null;
26 if (canMap(resource)) {
27 TomEEDataSourceCreator.TomEEDataSource source =
28 (TomEEDataSourceCreator.TomEEDataSource) resource;
29 dataSourceInfo = new DataSourceInfo();
30 dataSourceInfo.setBusyConnections(source.getNumActive());
31 dataSourceInfo.setEstablishedConnections(source.getNumIdle() + source.getNumActive());
32 dataSourceInfo.setMaxConnections(source.getMaxActive());
33 dataSourceInfo.setJdbcUrl(source.getUrl());
34 dataSourceInfo.setUsername(source.getUsername());
35 dataSourceInfo.setResettable(false);
36 dataSourceInfo.setType("tomcat-jdbc");
37 }
38 return dataSourceInfo;
39 }
40
41 @Override
42 public boolean reset(Object resource) {
43 return false;
44 }
45
46 @Override
47 public boolean canMap(Object resource) {
48 return "org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource"
49 .equals(resource.getClass().getName())
50 && resource instanceof TomEEDataSourceCreator.TomEEDataSource;
51 }
52
53 }