KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > outbound > connectionmanagerconfig > PartitionedPool


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

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.MultiPoolConnectionInterceptor;
22 import org.apache.geronimo.connector.outbound.PoolingAttributes;
23
24 /**
25  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
26  */

27 public class PartitionedPool implements PoolingSupport {
28
29     private boolean partitionByConnectionRequestInfo;
30     private boolean partitionBySubject;
31
32     private final SinglePool singlePool;
33
34     private transient PoolingAttributes poolingAttributes;
35
36     public PartitionedPool(int maxSize, int minSize, int blockingTimeoutMilliseconds, int idleTimeoutMinutes, boolean matchOne, boolean matchAll, boolean selectOneAssumeMatch, boolean partitionByConnectionRequestInfo, boolean partitionBySubject) {
37         singlePool = new SinglePool(maxSize, minSize, blockingTimeoutMilliseconds, idleTimeoutMinutes, matchOne, matchAll, selectOneAssumeMatch);
38         this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo;
39         this.partitionBySubject = partitionBySubject;
40     }
41
42     public boolean isPartitionByConnectionRequestInfo() {
43         return partitionByConnectionRequestInfo;
44     }
45
46     public void setPartitionByConnectionRequestInfo(boolean partitionByConnectionRequestInfo) {
47         this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo;
48     }
49
50     public boolean isPartitionBySubject() {
51         return partitionBySubject;
52     }
53
54     public void setPartitionBySubject(boolean partitionBySubject) {
55         this.partitionBySubject = partitionBySubject;
56     }
57
58     public int getMaxSize() {
59         return singlePool.getMaxSize();
60     }
61
62     public void setMaxSize(int maxSize) {
63         singlePool.setMaxSize(maxSize);
64     }
65
66     public int getBlockingTimeoutMilliseconds() {
67         return poolingAttributes.getBlockingTimeoutMilliseconds();
68     }
69
70     public void setBlockingTimeoutMilliseconds(int blockingTimeoutMilliseconds) {
71         poolingAttributes.setBlockingTimeoutMilliseconds(blockingTimeoutMilliseconds);
72     }
73
74     public int getIdleTimeoutMinutes() {
75         return poolingAttributes.getIdleTimeoutMinutes();
76     }
77
78     public void setIdleTimeoutMinutes(int idleTimeoutMinutes) {
79         poolingAttributes.setIdleTimeoutMinutes(idleTimeoutMinutes);
80     }
81
82     public boolean isMatchOne() {
83         return singlePool.isMatchOne();
84     }
85
86     public void setMatchOne(boolean matchOne) {
87         singlePool.setMatchOne(matchOne);
88     }
89
90     public boolean isMatchAll() {
91         return singlePool.isMatchAll();
92     }
93
94     public void setMatchAll(boolean matchAll) {
95         singlePool.setMatchAll(matchAll);
96     }
97
98     public boolean isSelectOneAssumeMatch() {
99         return singlePool.isSelectOneAssumeMatch();
100     }
101
102     public void setSelectOneAssumeMatch(boolean selectOneAssumeMatch) {
103         singlePool.setSelectOneAssumeMatch(selectOneAssumeMatch);
104     }
105
106     public ConnectionInterceptor addPoolingInterceptors(ConnectionInterceptor tail) {
107         MultiPoolConnectionInterceptor pool = new MultiPoolConnectionInterceptor(tail,
108                 singlePool,
109                 isPartitionBySubject(),
110                 isPartitionByConnectionRequestInfo());
111         this.poolingAttributes = pool;
112         return pool;
113     }
114
115     public int getPartitionCount() {
116         return poolingAttributes.getPartitionCount();
117     }
118
119     public int getPartitionMaxSize() {
120         return poolingAttributes.getPartitionMaxSize();
121     }
122
123     public void setPartitionMaxSize(int maxSize) throws InterruptedException JavaDoc {
124         poolingAttributes.setPartitionMaxSize(maxSize);
125     }
126
127     public int getPartitionMinSize() {
128         return poolingAttributes.getPartitionMinSize();
129     }
130
131     public void setPartitionMinSize(int minSize) {
132         poolingAttributes.setPartitionMinSize(minSize);
133     }
134
135     public int getIdleConnectionCount() {
136         return poolingAttributes.getIdleConnectionCount();
137     }
138
139     public int getConnectionCount() {
140         return poolingAttributes.getConnectionCount();
141     }
142 }
143
Popular Tags