KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > key > passwd > swing > KeyMgmtLifeCycleThread


1 /*
2  * Copyright 2006 Schlichtherle IT Services
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package de.schlichtherle.key.passwd.swing;
18
19 import java.util.logging.*;
20
21 /**
22  * Simulates the typical life cycle of a protected resource and its
23  * associated key using the API in the package {@link de.schlichtherle.key}.
24  *
25  * @author Christian Schlichtherle
26  * @version @version@
27  * @since TrueZIP 6.1
28  */

29 public class KeyMgmtLifeCycleThread extends Thread JavaDoc {
30
31     private static final Logger logger
32             = Logger.getLogger(KeyMgmtLifeCycleThread.class.getName());
33
34     private final KeyMgmtLifeCycle rlc;
35
36     public KeyMgmtLifeCycleThread(final String JavaDoc id) {
37         this(new KeyMgmtLifeCycle(id));
38     }
39
40     public KeyMgmtLifeCycleThread(KeyMgmtLifeCycle rlc) {
41         super(rlc, "Key Management Life Cycle Thread for \"" + rlc.id + "\"");
42         this.rlc = rlc;
43         //setPriority(Thread.MIN_PRIORITY);
44
//setDaemon(true); // thread may die.
45
}
46
47     public String JavaDoc getResourceID() {
48         return rlc.id;
49     }
50
51     /**
52      * Returns non-<code>null</code> if and only if this thread has
53      * terminated because the user cancelled the key prompting.
54      */

55     public Throwable JavaDoc getThrowable() {
56         return rlc.throwable;
57     }
58
59     public void start() {
60         logger.fine(rlc.id + ": Starting Key Management Life Cycle Thread...");
61         super.start();
62     }
63
64     public void run() {
65         super.run();
66         final Throwable JavaDoc t = getThrowable();
67         if (t != null)
68             t.printStackTrace();
69     }
70 }
Popular Tags