View Javadoc

1   /*
2    * Copyright 2002-2005 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.jencks.factory;
18  
19  import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool;
20  import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
21  import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
22  import org.springframework.beans.factory.FactoryBean;
23  import org.springframework.beans.factory.InitializingBean;
24  
25  /***
26   * This FactoryBean creates the partitionned pool strategy for
27   * the Geronimo connection manager.
28   * <p/>
29   * This class is based on the common pool properties defined in
30   * the AbstractGeronimoPool class and two other properties:
31   * partitionByConnectionRequestInfo to manage pooling with the
32   * request informations and partitionBySubject to manage pooling
33   * with the subjects.
34   *
35   * @author Thierry Templier
36   * @see PartitionedPool
37   * @see AbstractGeronimoPool
38   * @see ConnectionManagerFactoryBean#setPoolingSupport(PoolingSupport)
39   */
40  public class PartitionedPoolFactoryBean extends AbstractGeronimoPool implements FactoryBean, InitializingBean {
41  
42      protected boolean partitionByConnectionRequestInfo;
43      protected boolean partitionBySubject;
44  
45      private PartitionedPool pool;
46  
47      public Object getObject() throws Exception {
48          return pool;
49      }
50  
51      public Class getObjectType() {
52          return SinglePool.class;
53      }
54  
55      public boolean isSingleton() {
56          return true;
57      }
58  
59      /***
60       * Set the partitionByConnectionRequestInfo for the pool.
61       */
62      public void setPartitionByConnectionRequestInfo(boolean partitionByConnectionRequestInfo) {
63          this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo;
64      }
65  
66      /***
67       * Set the partitionBySubject for the pool.
68       */
69      public void setPartitionBySubject(boolean partitionBySubject) {
70          this.partitionBySubject = partitionBySubject;
71      }
72  
73      public void afterPropertiesSet() throws Exception {
74          this.pool = new PartitionedPool(maxSize, minSize, blockingTimeoutMilliseconds,
75                  idleTimeoutMinutes, matchOne, matchAll, selectOneAssumeMatch,
76                  partitionByConnectionRequestInfo, partitionBySubject);
77      }
78  
79  }