1 31 package org.objectweb.proactive.core.event; 32 33 import org.objectweb.proactive.core.body.UniversalBody; 34 35 public class BodyEventProducerImpl extends AbstractEventProducer { 36 37 public BodyEventProducerImpl() {} 38 39 public void fireBodyCreated(UniversalBody b) { 40 if (hasListeners()) 41 notifyAllListeners(new BodyEvent(b, BodyEvent.BODY_CREATED)); 42 } 43 44 public void fireBodyRemoved(UniversalBody b) { 45 if (hasListeners()) 46 notifyAllListeners(new BodyEvent(b, BodyEvent.BODY_DESTROYED)); 47 } 48 49 public void fireBodyChanged(UniversalBody b) { 50 if (hasListeners()) 52 notifyAllListeners(new BodyEvent(b, BodyEvent.BODY_CHANGED)); 53 } 54 55 59 public void addBodyEventListener(BodyEventListener listener) { 60 addListener(listener); 61 } 62 63 public void removeBodyEventListener(BodyEventListener listener) { 64 removeListener(listener); 65 } 66 67 71 protected void notifyOneListener(ProActiveListener listener, ProActiveEvent event) { 72 BodyEvent bodyEvent = (BodyEvent) event; 73 switch (bodyEvent.getType()) { 74 case BodyEvent.BODY_CREATED : 75 ((BodyEventListener) listener).bodyCreated(bodyEvent); 76 break; 77 78 case BodyEvent.BODY_DESTROYED : 79 ((BodyEventListener) listener).bodyDestroyed(bodyEvent); 80 break; 81 82 case BodyEvent.BODY_CHANGED : 83 ((BodyEventListener) listener).bodyChanged(bodyEvent); 84 break; 85 } 86 } 87 88 } | Popular Tags |