1 16 package net.sf.dozer.util.mapping.event; 17 18 import java.util.List ; 19 20 import net.sf.dozer.util.mapping.MappingException; 21 import net.sf.dozer.util.mapping.util.MapperConstants; 22 23 27 public class DozerEventManager implements EventManagerIF { 28 private final List eventListeners; 29 30 public DozerEventManager(List eventListeners) { 31 this.eventListeners = eventListeners; 32 } 33 34 public void fireEvent(DozerEvent event) { 35 if (eventListeners == null) { 37 return; 38 } 39 String eventType = event.getType(); 40 int size = eventListeners.size(); 41 for (int i = 0; i < size; i++) { 42 DozerEventListener listener = (DozerEventListener) eventListeners.get(i); 43 if(eventType.equals(MapperConstants.MAPPING_STARTED_EVENT)) { 44 listener.mappingStarted(event); 45 } else if (eventType.equals(MapperConstants.MAPPING_PRE_WRITING_DEST_VALUE)) { 46 listener.preWritingDestinationValue(event); 47 } else if (eventType.equals(MapperConstants.MAPPING_POST_WRITING_DEST_VALUE)) { 48 listener.postWritingDestinationValue(event); 49 } else if (eventType.equals(MapperConstants.MAPPING_FINISHED_EVENT)) { 50 listener.mappingFinished(event); 51 } else { 52 throw new MappingException("Unsupported event type: " + eventType); 53 } 54 } 55 } 56 57 } 58 | Popular Tags |