1 16 package org.apache.cocoon.portal.event.subscriber.impl; 17 18 import java.util.Iterator ; 19 import java.util.List ; 20 21 import org.apache.cocoon.portal.PortalService; 22 import org.apache.cocoon.portal.coplet.CopletData; 23 import org.apache.cocoon.portal.coplet.CopletInstanceData; 24 import org.apache.cocoon.portal.event.CopletDataEvent; 25 import org.apache.cocoon.portal.event.Event; 26 import org.apache.cocoon.portal.event.EventManager; 27 import org.apache.cocoon.portal.event.Receiver; 28 import org.apache.cocoon.portal.event.impl.ChangeCopletsJXPathEvent; 29 import org.apache.cocoon.portal.event.impl.CopletJXPathEvent; 30 import org.apache.cocoon.portal.profile.ProfileManager; 31 32 38 public final class DefaulCopletDataEventSubscriber 39 implements Receiver { 40 41 44 public DefaulCopletDataEventSubscriber() { 45 } 47 48 51 public void inform(CopletDataEvent e, PortalService service) { 52 CopletData data = (CopletData)e.getTarget(); 53 List instances = null; 54 55 ProfileManager profileManager = service.getComponentManager().getProfileManager(); 56 instances = profileManager.getCopletInstanceData(data); 57 58 if ( instances != null && e instanceof ChangeCopletsJXPathEvent ) { 59 EventManager eventManager = service.getComponentManager().getEventManager(); 60 final String path = ((ChangeCopletsJXPathEvent)e).getPath(); 61 final Object value = ((ChangeCopletsJXPathEvent)e).getValue(); 62 63 Iterator i = instances.iterator(); 64 while ( i.hasNext() ) { 65 CopletInstanceData current = (CopletInstanceData) i.next(); 66 Event event = new CopletJXPathEvent(current, path, value); 67 eventManager.send(event); 68 } 69 } 70 } 71 72 } 73 | Popular Tags |