1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  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. package org.apache.commons.net.util;
  17. import java.io.Serializable;
  18. import java.util.Enumeration;
  19. import java.util.EventListener;
  20. import java.util.Vector;
  21. /**
  22. * @author Daniel F. Savarese
  23. */
  24. public class ListenerList implements Serializable
  25. {
  26. private Vector __listeners;
  27. public ListenerList()
  28. {
  29. __listeners = new Vector();
  30. }
  31. public synchronized void addListener(EventListener listener)
  32. {
  33. __listeners.addElement(listener);
  34. }
  35. public synchronized void removeListener(EventListener listener)
  36. {
  37. __listeners.removeElement(listener);
  38. }
  39. public synchronized Enumeration getListeners()
  40. {
  41. return ((Vector)__listeners.clone()).elements();
  42. }
  43. public int getListenerCount()
  44. {
  45. return __listeners.size();
  46. }
  47. }