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;
  17. /**
  18. * A simple base impementation of {@link ObjectPool}.
  19. * All optional operations are implemented as throwing
  20. * {@link UnsupportedOperationException}.
  21. *
  22. * @author Rodney Waldhoff
  23. * @version $Revision: 1.9 $ $Date: 2004/02/28 11:46:33 $
  24. */
  25. public abstract class BaseKeyedObjectPool implements KeyedObjectPool {
  26. public abstract Object borrowObject(Object key) throws Exception;
  27. public abstract void returnObject(Object key, Object obj) throws Exception;
  28. public abstract void invalidateObject(Object key, Object obj) throws Exception;
  29. /**
  30. * Not supported in this base implementation.
  31. */
  32. public void addObject(Object key) throws Exception, UnsupportedOperationException {
  33. throw new UnsupportedOperationException();
  34. }
  35. /**
  36. * Not supported in this base implementation.
  37. */
  38. public int getNumIdle(Object key) throws UnsupportedOperationException {
  39. throw new UnsupportedOperationException();
  40. }
  41. /**
  42. * Not supported in this base implementation.
  43. */
  44. public int getNumActive(Object key) throws UnsupportedOperationException {
  45. throw new UnsupportedOperationException();
  46. }
  47. /**
  48. * Not supported in this base implementation.
  49. */
  50. public int getNumIdle() throws UnsupportedOperationException {
  51. throw new UnsupportedOperationException();
  52. }
  53. /**
  54. * Not supported in this base implementation.
  55. */
  56. public int getNumActive() throws UnsupportedOperationException {
  57. throw new UnsupportedOperationException();
  58. }
  59. /**
  60. * Not supported in this base implementation.
  61. */
  62. public void clear() throws Exception, UnsupportedOperationException {
  63. throw new UnsupportedOperationException();
  64. }
  65. /**
  66. * Not supported in this base implementation.
  67. */
  68. public void clear(Object key)
  69. throws Exception, UnsupportedOperationException {
  70. throw new UnsupportedOperationException();
  71. }
  72. /**
  73. * Does nothing this base implementation.
  74. */
  75. public void close() throws Exception {
  76. }
  77. /**
  78. * Not supported in this base implementation.
  79. */
  80. public void setFactory(KeyedPoolableObjectFactory factory)
  81. throws IllegalStateException, UnsupportedOperationException {
  82. throw new UnsupportedOperationException();
  83. }
  84. }