KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > core > component > lifecycle > test > DestroyOnExceptionTestComponentImpl


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.core.component.lifecycle.test;
19
20 import org.sape.carbon.core.component.Component;
21 import org.sape.carbon.core.component.ComponentConfiguration;
22 import org.sape.carbon.core.component.lifecycle.Configurable;
23 import org.sape.carbon.core.component.lifecycle.Initializable;
24 import org.sape.carbon.core.component.lifecycle.Startable;
25 import org.sape.carbon.core.component.lifecycle.Suspendable;
26
27 /**
28  * @version 1.0
29  * @author
30  */

31 public class DestroyOnExceptionTestComponentImpl
32     implements
33         DestroyOnExceptionTestComponent,
34         Startable,
35         Suspendable,
36         Configurable,
37         Initializable {
38
39     protected boolean crashOnConfigure;
40     protected boolean crashOnResume;
41     protected boolean crashOnSuspend;
42     protected boolean crashOnStart;
43     protected boolean crashOnStop;
44
45     /**
46      * @see DestroyOnExceptionTestComponent#crashOnConfigure()
47      */

48     public void crashOnConfigure() {
49         reset();
50         this.crashOnConfigure = true;
51     }
52
53     /**
54      * @see DestroyOnExceptionTestComponent#crashOnResume()
55      */

56     public void crashOnResume() {
57         reset();
58         this.crashOnResume = true;
59     }
60
61     /**
62      * @see DestroyOnExceptionTestComponent#crashOnStart()
63      */

64     public void crashOnStart() {
65         reset();
66         this.crashOnStart = true;
67     }
68
69     /**
70      * @see DestroyOnExceptionTestComponent#crashOnStop()
71      */

72     public void crashOnStop() {
73         reset();
74         this.crashOnStop = true;
75     }
76
77     /**
78      * @see DestroyOnExceptionTestComponent#crashOnSuspend()
79      */

80     public void crashOnSuspend() {
81         reset();
82         this.crashOnSuspend = true;
83     }
84
85     /**
86      * @see Startable#start()
87      */

88     public void start() throws Exception JavaDoc {
89         if (this.crashOnStart) {
90             throw new Exception JavaDoc();
91         }
92     }
93
94     /**
95      * @see Startable#stop()
96      */

97     public void stop() throws Exception JavaDoc {
98         if (this.crashOnStop) {
99             throw new Exception JavaDoc();
100         }
101     }
102
103     /**
104      * @see Suspendable#resume()
105      */

106     public void resume() throws Exception JavaDoc {
107         if (this.crashOnResume) {
108             throw new Exception JavaDoc();
109         }
110     }
111
112     /**
113      * @see Suspendable#suspend()
114      */

115     public void suspend() throws Exception JavaDoc {
116         if (this.crashOnSuspend) {
117             throw new Exception JavaDoc();
118         }
119     }
120
121     /**
122      * @see Configurable#configure(ComponentConfiguration)
123      */

124     public void configure(ComponentConfiguration configuration)
125         throws Exception JavaDoc {
126
127         if (this.crashOnConfigure) {
128             throw new Exception JavaDoc();
129         }
130     }
131
132     /**
133      * @see Initializable#initialize(org.sape.carbon.core.component.Component)
134      */

135     public void initialize(Component thisComponent) throws Exception JavaDoc {
136         reset();
137     }
138
139     private void reset() {
140         this.crashOnConfigure = false;
141         this.crashOnResume = false;
142         this.crashOnStart = false;
143         this.crashOnStop = false;
144         this.crashOnSuspend = false;
145     }
146 }
Popular Tags