1 17 18 package org.apache.geronimo.connector.outbound.connectionmanagerconfig; 19 20 import org.apache.geronimo.connector.outbound.ConnectionInterceptor; 21 import org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor; 22 import org.apache.geronimo.connector.outbound.SinglePoolMatchAllConnectionInterceptor; 23 import org.apache.geronimo.connector.outbound.PoolingAttributes; 24 25 28 public class SinglePool implements PoolingSupport { 29 private int maxSize; 30 private int minSize; 31 private int blockingTimeoutMilliseconds; 32 private int idleTimeoutMinutes; 33 private boolean matchOne; 34 private boolean matchAll; 35 private boolean selectOneAssumeMatch; 36 37 private transient PoolingAttributes pool; 38 39 public SinglePool(int maxSize, int minSize, int blockingTimeoutMilliseconds, int idleTimeoutMinutes, boolean matchOne, boolean matchAll, boolean selectOneAssumeMatch) { 40 this.maxSize = maxSize; 41 this.minSize = minSize; 42 this.blockingTimeoutMilliseconds = blockingTimeoutMilliseconds; 43 this.idleTimeoutMinutes = idleTimeoutMinutes; 44 this.matchOne = matchOne; 45 this.matchAll = matchAll; 46 this.selectOneAssumeMatch = selectOneAssumeMatch; 47 } 48 49 public int getMaxSize() { 50 return maxSize; 51 } 52 53 public void setMaxSize(int maxSize) { 54 this.maxSize = maxSize; 55 } 56 57 public int getMinSize() { 58 return minSize; 59 } 60 61 public void setMinSize(int minSize) { 62 this.minSize = minSize; 63 } 64 65 public int getBlockingTimeoutMilliseconds() { 66 return blockingTimeoutMilliseconds; 67 } 68 69 public void setBlockingTimeoutMilliseconds(int blockingTimeoutMilliseconds) { 70 this.blockingTimeoutMilliseconds = blockingTimeoutMilliseconds; 71 if (pool != null) { 72 pool.setBlockingTimeoutMilliseconds(blockingTimeoutMilliseconds); 73 } 74 } 75 76 public int getIdleTimeoutMinutes() { 77 return idleTimeoutMinutes; 78 } 79 80 public void setIdleTimeoutMinutes(int idleTimeoutMinutes) { 81 this.idleTimeoutMinutes = idleTimeoutMinutes; 82 if (pool != null) { 83 pool.setIdleTimeoutMinutes(idleTimeoutMinutes); 84 } 85 } 86 87 public boolean isMatchOne() { 88 return matchOne; 89 } 90 91 public void setMatchOne(boolean matchOne) { 92 this.matchOne = matchOne; 93 } 94 95 public boolean isMatchAll() { 96 return matchAll; 97 } 98 99 public void setMatchAll(boolean matchAll) { 100 this.matchAll = matchAll; 101 } 102 103 public boolean isSelectOneAssumeMatch() { 104 return selectOneAssumeMatch; 105 } 106 107 public void setSelectOneAssumeMatch(boolean selectOneAssumeMatch) { 108 this.selectOneAssumeMatch = selectOneAssumeMatch; 109 } 110 111 public ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail) { 112 if (isMatchAll()) { 113 SinglePoolMatchAllConnectionInterceptor pool = new SinglePoolMatchAllConnectionInterceptor(tail, 114 getMaxSize(), 115 getMinSize(), 116 getBlockingTimeoutMilliseconds(), 117 getIdleTimeoutMinutes()); 118 this.pool = pool; 119 return pool; 120 121 } else { 122 SinglePoolConnectionInterceptor pool = new SinglePoolConnectionInterceptor(tail, 123 getMaxSize(), 124 getMinSize(), 125 getBlockingTimeoutMilliseconds(), 126 getIdleTimeoutMinutes(), 127 isSelectOneAssumeMatch()); 128 this.pool = pool; 129 return pool; 130 } 131 } 132 133 public int getPartitionCount() { 134 return 1; 135 } 136 137 public int getPartitionMaxSize() { 138 return maxSize; 139 } 140 141 public void setPartitionMaxSize(int maxSize) throws InterruptedException { 142 if (pool != null) { 143 pool.setPartitionMaxSize(maxSize); 144 } 145 this.maxSize = maxSize; 146 } 147 148 public int getPartitionMinSize() { 149 return minSize; 150 } 151 152 public void setPartitionMinSize(int minSize) { 153 if (pool != null) { 154 pool.setPartitionMinSize(minSize); 155 } 156 this.minSize = minSize; 157 } 158 159 public int getIdleConnectionCount() { 160 return pool == null ? 0 : pool.getIdleConnectionCount(); 161 } 162 163 public int getConnectionCount() { 164 return pool == null ? 0 : pool.getConnectionCount(); 165 } 166 } 167 | Popular Tags |