KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > ConnectorResourceNamingEventNotifier


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.connectors;
24
25 import java.util.ArrayList JavaDoc;
26
27 /**
28  * Notifier for connector resource naming events
29  * @author Jagadish Ramu
30  */

31 class ConnectorResourceNamingEventNotifier implements ConnectorNamingEventNotifier{
32
33      private ArrayList JavaDoc<ConnectorNamingEventListener> listeners;
34      private static ConnectorResourceNamingEventNotifier notifier;
35
36      private ConnectorResourceNamingEventNotifier(){
37         listeners= new ArrayList JavaDoc<ConnectorNamingEventListener>();
38      }
39
40       /**
41        * Returns an instance of event notifier (singleton)
42        * @return ConnectorNamingEventNotifier
43        */

44      public static ConnectorNamingEventNotifier getInstance(){
45          if(notifier == null){
46             notifier = new ConnectorResourceNamingEventNotifier();
47          }
48         return notifier;
49      }
50
51     /**
52      * To add Listener which gets notified when the event happens
53      * @param listener
54      */

55     public void addListener(ConnectorNamingEventListener listener){
56         listeners.add(listener);
57     }
58
59     /**
60      * To remove listener such that it wont be notified anymore.
61      * @param listener
62      */

63     public void removeListener(ConnectorNamingEventListener listener){
64         listeners.remove(listener);
65     }
66
67     /**
68      * Notifies all the registered listeners about the naming event.
69      * @param event
70      */

71     public void notifyListeners(ConnectorNamingEvent event){
72
73         for(ConnectorNamingEventListener listener : listeners){
74             listener.connectorNamingEventPerformed(event);
75         }
76     }
77 }
78
Popular Tags