Use the getListeners
method when notifying listeners. The recommended code sequence for notifying all registered listeners of say, FooListener.eventHappened
, is:
Object[] listeners = myListenerList.getListeners(); for (int i = 0; i < listeners.length; ++i) { ((FooListener) listeners[i]).eventHappened(event); }
This class can be used without OSGi running.
@since org.eclipse.equinox.common 3.2 Note that the add
method checks for and eliminates duplicates based on identity (not equality). Likewise, the remove
method compares based on identity.
Use the getListeners
method when notifying listeners. Note that no garbage is created if no listeners are registered. The recommended code sequence for notifying all registered listeners of say, FooListener.eventHappened
, is:
Object[] listeners = myListenerList.getListeners(); for (int i = 0; i < listeners.length; ++i) { ((FooListener) listeners[i]).eventHappened(event); }@deprecated Please use {@link org.eclipse.core.runtime.ListenerList} instead.Please note that the {@link #ListenerList(int)} and{@link org.eclipse.core.runtime.ListenerList#ListenerList(int)}constructors have different semantics. Please read the javadoc carefully. Also note that the equivalent of {@link #ListenerList()} is actually{@link org.eclipse.core.runtime.ListenerList#ListenerList(int)}with {@link org.eclipse.core.runtime.ListenerList#IDENTITY} asthe argument.
|
|
|
|