1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.dbcp.datasources;
19
20 import java.io.IOException;
21 import java.util.Map;
22
23 import javax.naming.RefAddr;
24 import javax.naming.Reference;
25
26
27
28
29
30
31 public class PerUserPoolDataSourceFactory
32 extends InstanceKeyObjectFactory
33 {
34 private static final String PER_USER_POOL_CLASSNAME =
35 PerUserPoolDataSource.class.getName();
36
37 protected boolean isCorrectClass(String className) {
38 return PER_USER_POOL_CLASSNAME.equals(className);
39 }
40
41 protected InstanceKeyDataSource getNewInstance(Reference ref)
42 throws IOException, ClassNotFoundException {
43 PerUserPoolDataSource pupds = new PerUserPoolDataSource();
44 RefAddr ra = ref.get("defaultMaxActive");
45 if (ra != null && ra.getContent() != null) {
46 pupds.setDefaultMaxActive(
47 Integer.parseInt(ra.getContent().toString()));
48 }
49
50 ra = ref.get("defaultMaxIdle");
51 if (ra != null && ra.getContent() != null) {
52 pupds.setDefaultMaxIdle(
53 Integer.parseInt(ra.getContent().toString()));
54 }
55
56 ra = ref.get("defaultMaxWait");
57 if (ra != null && ra.getContent() != null) {
58 pupds.setDefaultMaxWait(
59 Integer.parseInt(ra.getContent().toString()));
60 }
61
62 ra = ref.get("perUserDefaultAutoCommit");
63 if (ra != null && ra.getContent() != null) {
64 byte[] serialized = (byte[]) ra.getContent();
65 pupds.perUserDefaultAutoCommit = (Map) deserialize(serialized);
66 }
67
68 ra = ref.get("perUserDefaultTransactionIsolation");
69 if (ra != null && ra.getContent() != null) {
70 byte[] serialized = (byte[]) ra.getContent();
71 pupds.perUserDefaultTransactionIsolation =
72 (Map) deserialize(serialized);
73 }
74
75 ra = ref.get("perUserMaxActive");
76 if (ra != null && ra.getContent() != null) {
77 byte[] serialized = (byte[]) ra.getContent();
78 pupds.perUserMaxActive = (Map) deserialize(serialized);
79 }
80
81 ra = ref.get("perUserMaxIdle");
82 if (ra != null && ra.getContent() != null) {
83 byte[] serialized = (byte[]) ra.getContent();
84 pupds.perUserMaxIdle = (Map) deserialize(serialized);
85 }
86
87 ra = ref.get("perUserMaxWait");
88 if (ra != null && ra.getContent() != null) {
89 byte[] serialized = (byte[]) ra.getContent();
90 pupds.perUserMaxWait = (Map) deserialize(serialized);
91 }
92
93 ra = ref.get("perUserDefaultReadOnly");
94 if (ra != null && ra.getContent() != null) {
95 byte[] serialized = (byte[]) ra.getContent();
96 pupds.perUserDefaultReadOnly = (Map) deserialize(serialized);
97 }
98 return pupds;
99 }
100 }
101