1 24 25 package org.objectweb.dream.aggregator; 26 27 import java.util.HashMap ; 28 import java.util.Iterator ; 29 import java.util.Map ; 30 31 import org.objectweb.dream.AbstractComponent; 32 import org.objectweb.dream.Pull; 33 import org.objectweb.dream.PullException; 34 import org.objectweb.dream.message.ExtensibleMessage; 35 import org.objectweb.dream.message.Message; 36 import org.objectweb.dream.message.MessageTypeImpl; 37 import org.objectweb.dream.message.manager.MessageManager; 38 import org.objectweb.fractal.api.NoSuchInterfaceException; 39 import org.objectweb.fractal.api.control.IllegalBindingException; 40 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 41 42 50 public class PullPullAggregatorCollectionInputImpl extends AbstractComponent 51 implements 52 Pull 53 { 54 55 private Map inPullItfs = new HashMap (); 56 57 58 protected MessageManager messageManagerItf; 59 60 63 public Message pull(Map context) throws PullException 64 { 65 ExtensibleMessage outMessage = null; 66 outMessage = (ExtensibleMessage) messageManagerItf 67 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 68 Iterator iter = inPullItfs.values().iterator(); 69 while (iter.hasNext()) 70 { 71 Pull pullItf = (Pull) iter.next(); 72 Message msg = pullItf.pull(context); 73 if (msg != null) 74 { 75 outMessage.addSubMessage(msg); 76 } 77 } 78 return outMessage; 79 } 80 81 85 88 public String [] listFc() 89 { 90 String [] tab = new String [inPullItfs.size() + 1]; 91 inPullItfs.keySet().toArray(tab); 92 tab[inPullItfs.size()] = MessageManager.ITF_NAME; 93 return tab; 94 } 95 96 100 public synchronized void bindFc(String clientItfName, Object serverItf) 101 throws NoSuchInterfaceException, IllegalBindingException, 102 IllegalLifeCycleException 103 { 104 super.bindFc(clientItfName, serverItf); 105 if (clientItfName.startsWith(IN_PULL_ITF_NAME)) 106 { 107 inPullItfs.put(clientItfName, serverItf); 108 } 109 else if (clientItfName.equals(MessageManager.ITF_NAME)) 110 { 111 messageManagerItf = (MessageManager) serverItf; 112 } 113 } 114 115 118 public synchronized void unbindFc(String clientItfName) 119 throws NoSuchInterfaceException, IllegalBindingException, 120 IllegalLifeCycleException 121 { 122 super.unbindFc(clientItfName); 123 if (clientItfName.startsWith(IN_PULL_ITF_NAME)) 124 { 125 inPullItfs.remove(clientItfName); 126 } 127 } 128 } | Popular Tags |