1 package org.apache.beehive.controls.runtime.bean; 2 19 20 import java.util.TooManyListenersException ; 21 22 26 public class UnicastEventNotifier implements java.io.Serializable 27 { 28 34 synchronized public void addListener(Object listener) throws TooManyListenersException 35 { 36 if (_listener != null) 37 throw new TooManyListenersException ("Callback listener is already registered"); 38 _listener = listener; 39 } 40 41 44 synchronized public void removeListener(Object listener) 45 { 46 if (_listener != listener) 47 { 48 throw new IllegalStateException ("Invalid listener, not currently registered"); 49 } 50 _listener = null; 51 } 52 53 56 public Object getListener() 57 { 58 return _listener; 59 } 60 61 64 public int getListenerCount() 65 { 66 return (_listener != null) ? 1 : 0; 67 } 68 69 72 public void getListeners(Object [] listeners) 73 { 74 if (_listener != null) 75 listeners[0] = _listener; 76 } 77 78 private Object _listener; 79 } 80 | Popular Tags |