%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.util.pool.RecyclableSupport |
|
|
1 | package org.apache.turbine.util.pool; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
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 | 154 | 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 | 0 | recycle(); |
40 | 0 | } |
41 | ||
42 | /** |
|
43 | * Recycles the object by removing its disposed flag. |
|
44 | */ |
|
45 | public void recycle() |
|
46 | { |
|
47 | 2 | disposed = false; |
48 | 2 | } |
49 | ||
50 | /** |
|
51 | * Disposes the object by setting its disposed flag. |
|
52 | */ |
|
53 | public void dispose() |
|
54 | { |
|
55 | 4 | disposed = true; |
56 | 4 | } |
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 | 12 | 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 | 0 | return TurbinePool.putInstance(this); |
79 | } |
|
80 | 0 | catch (RuntimeException x) |
81 | { |
|
82 | 0 | return false; |
83 | } |
|
84 | } |
|
85 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |