001 /* 002 * Copyright 2002-2005 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jencks.factory; 018 019 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool; 020 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; 021 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; 022 import org.springframework.beans.factory.FactoryBean; 023 import org.springframework.beans.factory.InitializingBean; 024 025 /** 026 * This FactoryBean creates the partitionned pool strategy for 027 * the Geronimo connection manager. 028 * <p/> 029 * This class is based on the common pool properties defined in 030 * the AbstractGeronimoPool class and two other properties: 031 * partitionByConnectionRequestInfo to manage pooling with the 032 * request informations and partitionBySubject to manage pooling 033 * with the subjects. 034 * 035 * @author Thierry Templier 036 * @see PartitionedPool 037 * @see AbstractGeronimoPool 038 * @see ConnectionManagerFactoryBean#setPoolingSupport(PoolingSupport) 039 */ 040 public class PartitionedPoolFactoryBean extends AbstractGeronimoPool implements FactoryBean, InitializingBean { 041 042 protected boolean partitionByConnectionRequestInfo; 043 protected boolean partitionBySubject; 044 045 private PartitionedPool pool; 046 047 public Object getObject() throws Exception { 048 return pool; 049 } 050 051 public Class getObjectType() { 052 return SinglePool.class; 053 } 054 055 public boolean isSingleton() { 056 return true; 057 } 058 059 /** 060 * Set the partitionByConnectionRequestInfo for the pool. 061 */ 062 public void setPartitionByConnectionRequestInfo(boolean partitionByConnectionRequestInfo) { 063 this.partitionByConnectionRequestInfo = partitionByConnectionRequestInfo; 064 } 065 066 /** 067 * Set the partitionBySubject for the pool. 068 */ 069 public void setPartitionBySubject(boolean partitionBySubject) { 070 this.partitionBySubject = partitionBySubject; 071 } 072 073 public void afterPropertiesSet() throws Exception { 074 this.pool = new PartitionedPool(maxSize, minSize, blockingTimeoutMilliseconds, 075 idleTimeoutMinutes, matchOne, matchAll, selectOneAssumeMatch, 076 partitionByConnectionRequestInfo, partitionBySubject); 077 } 078 079 }