| 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 | 8 | public class PerUserPoolDataSourceFactory |
| 32 | |
extends InstanceKeyObjectFactory |
| 33 | |
{ |
| 34 | 2 | private static final String PER_USER_POOL_CLASSNAME = |
| 35 | |
PerUserPoolDataSource.class.getName(); |
| 36 | |
|
| 37 | |
protected boolean isCorrectClass(String className) { |
| 38 | 4 | return PER_USER_POOL_CLASSNAME.equals(className); |
| 39 | |
} |
| 40 | |
|
| 41 | |
protected InstanceKeyDataSource getNewInstance(Reference ref) |
| 42 | |
throws IOException, ClassNotFoundException { |
| 43 | 0 | PerUserPoolDataSource pupds = new PerUserPoolDataSource(); |
| 44 | 0 | RefAddr ra = ref.get("defaultMaxActive"); |
| 45 | 0 | if (ra != null && ra.getContent() != null) { |
| 46 | 0 | pupds.setDefaultMaxActive( |
| 47 | |
Integer.parseInt(ra.getContent().toString())); |
| 48 | |
} |
| 49 | |
|
| 50 | 0 | ra = ref.get("defaultMaxIdle"); |
| 51 | 0 | if (ra != null && ra.getContent() != null) { |
| 52 | 0 | pupds.setDefaultMaxIdle( |
| 53 | |
Integer.parseInt(ra.getContent().toString())); |
| 54 | |
} |
| 55 | |
|
| 56 | 0 | ra = ref.get("defaultMaxWait"); |
| 57 | 0 | if (ra != null && ra.getContent() != null) { |
| 58 | 0 | pupds.setDefaultMaxWait( |
| 59 | |
Integer.parseInt(ra.getContent().toString())); |
| 60 | |
} |
| 61 | |
|
| 62 | 0 | ra = ref.get("perUserDefaultAutoCommit"); |
| 63 | 0 | if (ra != null && ra.getContent() != null) { |
| 64 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 65 | 0 | pupds.perUserDefaultAutoCommit = (Map) deserialize(serialized); |
| 66 | |
} |
| 67 | |
|
| 68 | 0 | ra = ref.get("perUserDefaultTransactionIsolation"); |
| 69 | 0 | if (ra != null && ra.getContent() != null) { |
| 70 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 71 | 0 | pupds.perUserDefaultTransactionIsolation = |
| 72 | |
(Map) deserialize(serialized); |
| 73 | |
} |
| 74 | |
|
| 75 | 0 | ra = ref.get("perUserMaxActive"); |
| 76 | 0 | if (ra != null && ra.getContent() != null) { |
| 77 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 78 | 0 | pupds.perUserMaxActive = (Map) deserialize(serialized); |
| 79 | |
} |
| 80 | |
|
| 81 | 0 | ra = ref.get("perUserMaxIdle"); |
| 82 | 0 | if (ra != null && ra.getContent() != null) { |
| 83 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 84 | 0 | pupds.perUserMaxIdle = (Map) deserialize(serialized); |
| 85 | |
} |
| 86 | |
|
| 87 | 0 | ra = ref.get("perUserMaxWait"); |
| 88 | 0 | if (ra != null && ra.getContent() != null) { |
| 89 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 90 | 0 | pupds.perUserMaxWait = (Map) deserialize(serialized); |
| 91 | |
} |
| 92 | |
|
| 93 | 0 | ra = ref.get("perUserDefaultReadOnly"); |
| 94 | 0 | if (ra != null && ra.getContent() != null) { |
| 95 | 0 | byte[] serialized = (byte[]) ra.getContent(); |
| 96 | 0 | pupds.perUserDefaultReadOnly = (Map) deserialize(serialized); |
| 97 | |
} |
| 98 | 0 | return pupds; |
| 99 | |
} |
| 100 | |
} |
| 101 | |
|