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