Line | Hits | Source |
---|---|---|
1 | /* | |
2 | Chrysalis Web Framework [http://chrysalis.sourceforge.net] | |
3 | Copyright (c) 2002, 2003, 2004, Paul Strack | |
4 | ||
5 | All rights reserved. | |
6 | ||
7 | Redistribution and use in source and binary forms, with or without | |
8 | modification, are permitted provided that the following conditions are met: | |
9 | ||
10 | 1. Redistributions of source code must retain the above copyright notice, this | |
11 | list of conditions and the following disclaimer. | |
12 | ||
13 | 2. Redistributions in binary form must reproduce the above copyright notice, | |
14 | this list of conditions and the following disclaimer in the documentation | |
15 | and/or other materials provided with the distribution. | |
16 | ||
17 | 3. Neither the name of the copyright holder nor the names of its contributors | |
18 | may be used to endorse or promote products derived from this software without | |
19 | specific prior written permission. | |
20 | ||
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | |
22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | |
25 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | |
28 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
31 | */ | |
32 | ||
33 | package org.chwf.resources; | |
34 | ||
35 | /** | |
36 | * A per-thread resource manager. The system must initialize this resource | |
37 | * manager before any managed resources are used. It is released after all | |
38 | * resource utilization is complete: | |
39 | * | |
40 | * <pre> | |
41 | * ResourceManager.init(); | |
42 | * // resource utilization ... | |
43 | * ResourceManager.release();</pre> | |
44 | * | |
45 | * Resource manager initialization and release is the responsibility of the | |
46 | * <i>System</i>, not developers. Developers should not interact with this | |
47 | * class at all, except for testing purposes. | |
48 | * | |
49 | * @author Paul Strack | |
50 | */ | |
51 | 1 | public class ResourceManager { |
52 | ||
53 | /** | |
54 | * True if management is initialized. | |
55 | * | |
56 | * @return True if management is initialized. | |
57 | */ | |
58 | public static boolean isInitialized() { | |
59 | 18 | return ResourceLocator.isManagementActive(); |
60 | } | |
61 | ||
62 | /** | |
63 | * Initialize resource management for this thread. Developers should not call | |
64 | * this method except for testing. | |
65 | * | |
66 | * @throws ResourceInitException If called while initialized. | |
67 | */ | |
68 | public static void init() throws ResourceInitException { | |
69 | 472 | ResourceLocator.init(); |
70 | 471 | } |
71 | ||
72 | /** | |
73 | * Release all managed resources, and terminate resource management for this | |
74 | * thread. Developers should not call this method except for testing. | |
75 | * | |
76 | * @param error Error status for the thread of execution (null if there were | |
77 | * no errors). | |
78 | * @throws ResourceException If there were failures during the release | |
79 | * operation. This is a chained exception; the full set of errors | |
80 | * can be retrieved via {@link ResourceException#getNextException()} | |
81 | * @throws ResourceInitException If called while not initialized. | |
82 | */ | |
83 | public static void release(Throwable error) | |
84 | throws ResourceException, ResourceInitException { | |
85 | 472 | ResourceLocator.release(error); |
86 | 469 | } |
87 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |