KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > service > ThreadEventNotifier


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

15 package org.apache.hivemind.service;
16
17 /**
18  * Service which acts as a dispatch hub for events about the lifecycle of the current thread.
19  * <p>
20  * Note: prior to release 1.1.1, the ThreadEventNotifier implementation would retain the listeners
21  * after {@link #fireThreadCleanup()}, which could allow certain threads to retain a reference to a
22  * listener, and thus that listener's class loader, even after the an application redeployment,
23  * resulting in a massive memory leak. Starting with release 1.1.1, all listeners are discarded by
24  * {@link #fireThreadCleanup()}.
25  *
26  * @author Howard Lewis Ship
27  */

28 public interface ThreadEventNotifier
29 {
30     /**
31      * Adds the listener. The notifier retains the listener until {@link #fireThreadCleanup()} is
32      * invoked, at which point is discarded.
33      */

34     public void addThreadCleanupListener(ThreadCleanupListener listener);
35
36     /**
37      * Removes the listener, if it has been previously added. If the listener has been added
38      * multiple times, only one instance is removed. Note that this method is rarely used, because
39      * all listeners are automatically removed by {@link #fireThreadCleanup()}.
40      */

41     public void removeThreadCleanupListener(ThreadCleanupListener listener);
42
43     /**
44      * Invokes {@link ThreadCleanupListener#threadDidCleanup()} on all listeners, and discards the
45      * list of listeners.
46      */

47     public void fireThreadCleanup();
48 }
49
Popular Tags