KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > resource > ResourceState


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.resource;
24
25 /**
26  * @author
27  */

28 public class ResourceState {
29         private boolean enlisted;
30         private boolean busy;
31         private long timestamp;
32     
33         // This identifies the resource as new (never given out from the pool)
34
// used for setting isolation level on new connections
35

36         // init isNew to true
37
private boolean isNew = true;
38         
39         
40         public boolean isEnlisted() {
41             return enlisted;
42         }
43         
44         public boolean isUnenlisted() {
45             return !enlisted;
46         }
47         
48         public boolean isFree() {
49             return !busy;
50         }
51         
52         public void setEnlisted(boolean enlisted) {
53             this.enlisted = enlisted;
54         }
55         
56         public boolean isBusy() {
57             return busy;
58         }
59         
60         public void setBusy(boolean busy) {
61             this.busy = busy;
62         }
63         
64         public long getTimestamp() {
65             return timestamp;
66         }
67         
68         public void touchTimestamp() {
69             timestamp = System.currentTimeMillis();
70         }
71         
72         public ResourceState() {
73             touchTimestamp();
74         }
75         
76         public boolean isNew() {
77             return isNew;
78         }
79         
80         // There's not way to set isNew to true,
81
// There's no way to revert a state to new
82
public void setNotNew() {
83             isNew = false;
84         }
85
86         public String JavaDoc toString() {
87             return "Enlisted :" + enlisted + " Busy :" + busy;
88         }
89 }
90
Popular Tags