KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > tests > jfun > yan > testmodel > StatefulResource


1 /*
2  * Created on Mar 16, 2005
3  *
4  * Author Ben Yu
5  * ZBS
6  */

7 package tests.jfun.yan.testmodel;
8
9 /**
10  * Zephyr Business Solution
11  *
12  * @author Ben Yu
13  *
14  */

15 public class StatefulResource implements SimpleResource,
16 Engine{
17   private int init = 0;
18   private int destroyed = 0;
19   private final Engine sr;
20   public StatefulResource(final Engine sr) {
21     this.sr = sr;
22   }
23   
24   public int getDestroyedCount() {
25     return destroyed;
26   }
27   public int getInitCount() {
28     return init;
29   }
30   
31   public void destroy() {
32     if(sr.isDestroyed()){
33       throw new IllegalStateException JavaDoc("parts destroyed prematurely");
34     }
35     destroyed ++;
36   }
37   public void initialize() {
38     if(!sr.isInitialized())
39       throw new IllegalStateException JavaDoc("parts not initialized yet");
40     init++;
41   }
42   public boolean isInitialized(){
43     return init>0;
44   }
45   public boolean isDestroyed(){
46     return destroyed > 0;
47   }
48   public void start(){
49     throw new UnsupportedOperationException JavaDoc("start");
50   }
51
52   public void stop(){
53     throw new UnsupportedOperationException JavaDoc("stop");
54   }
55   public boolean isStarted(){
56     throw new UnsupportedOperationException JavaDoc("isStarted");
57   }
58
59   public boolean isStopped(){
60     throw new UnsupportedOperationException JavaDoc("isStopped");
61   }
62   
63 }
64
Popular Tags