1 package org.apache.turbine.util.pool;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.turbine.services.pool.TurbinePool;
20
21 /***
22 * A support class for recyclable objects implementing default methods.
23 *
24 * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
25 * @version $Id: RecyclableSupport.java 264148 2005-08-29 14:21:04Z henning $
26 */
27 public class RecyclableSupport implements Recyclable
28 {
29 /***
30 * The disposed flag.
31 */
32 private boolean disposed;
33
34 /***
35 * Constructs a new recyclable support and calls the default recycle method.
36 */
37 public void Recyclable()
38 {
39 recycle();
40 }
41
42 /***
43 * Recycles the object by removing its disposed flag.
44 */
45 public void recycle()
46 {
47 disposed = false;
48 }
49
50 /***
51 * Disposes the object by setting its disposed flag.
52 */
53 public void dispose()
54 {
55 disposed = true;
56 }
57
58 /***
59 * Checks whether the object is disposed.
60 *
61 * @return true, if the object is disposed.
62 */
63 public boolean isDisposed()
64 {
65 return disposed;
66 }
67
68 /***
69 * A convenience method allowing a clever recyclable object
70 * to put itself into a pool for recycling.
71 *
72 * @return true, if disposal was accepted by the pool.
73 */
74 protected boolean doDispose()
75 {
76 try
77 {
78 return TurbinePool.putInstance(this);
79 }
80 catch (RuntimeException x)
81 {
82 return false;
83 }
84 }
85 }