1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  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. package org.apache.commons.pool.impl;
  17. import org.apache.commons.pool.KeyedObjectPool;
  18. import org.apache.commons.pool.KeyedObjectPoolFactory;
  19. import org.apache.commons.pool.KeyedPoolableObjectFactory;
  20. /**
  21. * A factory for creating {@link StackKeyedObjectPool} instances.
  22. *
  23. * @see StackKeyedObjectPool
  24. * @see KeyedObjectPoolFactory
  25. *
  26. * @author Rodney Waldhoff
  27. * @version $Revision: 1.6 $ $Date: 2004/02/28 12:16:21 $
  28. */
  29. public class StackKeyedObjectPoolFactory implements KeyedObjectPoolFactory {
  30. public StackKeyedObjectPoolFactory() {
  31. this((KeyedPoolableObjectFactory)null,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
  32. }
  33. public StackKeyedObjectPoolFactory(int max) {
  34. this((KeyedPoolableObjectFactory)null,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
  35. }
  36. public StackKeyedObjectPoolFactory(int max, int init) {
  37. this((KeyedPoolableObjectFactory)null,max,init);
  38. }
  39. public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory) {
  40. this(factory,StackKeyedObjectPool.DEFAULT_MAX_SLEEPING,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
  41. }
  42. public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max) {
  43. this(factory,max,StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY);
  44. }
  45. public StackKeyedObjectPoolFactory(KeyedPoolableObjectFactory factory, int max, int init) {
  46. _factory = factory;
  47. _maxSleeping = max;
  48. _initCapacity = init;
  49. }
  50. public KeyedObjectPool createPool() {
  51. return new StackKeyedObjectPool(_factory,_maxSleeping,_initCapacity);
  52. }
  53. protected KeyedPoolableObjectFactory _factory = null;
  54. protected int _maxSleeping = StackKeyedObjectPool.DEFAULT_MAX_SLEEPING;
  55. protected int _initCapacity = StackKeyedObjectPool.DEFAULT_INIT_SLEEPING_CAPACITY;
  56. }