StateChangedServiceImpl.java |
1 /* 2 * Copyright 2000-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 17 /* 18 19 */ 20 21 package org.apache.wsrp4j.util; 22 23 import java.util.ArrayList; 24 import java.util.Iterator; 25 26 /** 27 * This class implements the StateChangedService interface and is 28 * the parent of all classes with StateChangeService functionality. 29 * 30 * @author <a href="mailto:Ralf.Altrichter@de.ibm.com">Ralf Altrichter</a> 31 * 32 * @version 1.0 33 */ 34 35 public class StateChangedServiceImpl implements StateChangedService { 36 37 // internal list of StateChangedListeners 38 private ArrayList _listeners = new ArrayList(); 39 40 /** 41 * Constructor 42 */ 43 public StateChangedServiceImpl() { 44 45 } 46 47 /** 48 * Adds a StateChangedListener object to the internal 49 * array list. 50 * 51 * @param changeListener to be added 52 */ 53 public void addListener(StateChangedListener changeListener) { 54 55 _listeners.add(changeListener); 56 57 } 58 59 /** 60 * Notifies all registered listeners by calling the 61 * stateChanged(StateChangedEvent e) method on the 62 * target object. 63 */ 64 public void stateChanged() { 65 Iterator iterator = _listeners.iterator(); 66 while (iterator.hasNext()) { 67 StateChangedListener listener = (StateChangedListener) iterator 68 .next(); 69 listener.stateChanged(new StateChangedEvent(this)); 70 } 71 } 72 }