1 24 25 package org.objectweb.dream.aggregator; 26 27 import java.util.Map ; 28 29 import org.objectweb.dream.AbstractComponent; 30 import org.objectweb.dream.Pull; 31 import org.objectweb.dream.PullException; 32 import org.objectweb.dream.message.ExtensibleMessage; 33 import org.objectweb.dream.message.Message; 34 import org.objectweb.dream.message.MessageTypeImpl; 35 import org.objectweb.dream.message.manager.MessageManager; 36 import org.objectweb.fractal.api.NoSuchInterfaceException; 37 import org.objectweb.fractal.api.control.IllegalBindingException; 38 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 39 40 48 public class PullPullAggregatorContextualImpl extends AbstractComponent 49 implements 50 Pull 51 { 52 56 protected Pull inPullItf; 57 protected MessageManager messageManagerItf; 58 59 63 66 public Message pull(Map context) throws PullException 67 { 68 int nbMessageToAggregate = ((Integer ) context 69 .get(PullPullAggregatorContextualKey.KEY)).intValue(); 70 71 ExtensibleMessage outMessage = (ExtensibleMessage) messageManagerItf 72 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 73 for (int i = 0; i < nbMessageToAggregate; i++) 74 { 75 outMessage.addSubMessage(inPullItf.pull(context)); 76 } 77 return outMessage; 78 } 79 80 84 87 public String [] listFc() 88 { 89 return new String []{MessageManager.ITF_NAME, Pull.IN_PULL_ITF_NAME}; 90 } 91 92 96 public synchronized void bindFc(String clientItfName, Object serverItf) 97 throws NoSuchInterfaceException, IllegalBindingException, 98 IllegalLifeCycleException 99 { 100 super.bindFc(clientItfName, serverItf); 101 if (clientItfName.equals(MessageManager.ITF_NAME)) 102 { 103 messageManagerItf = (MessageManager) serverItf; 104 } 105 else if (clientItfName.equals(Pull.IN_PULL_ITF_NAME)) 106 { 107 inPullItf = (Pull) serverItf; 108 } 109 110 } 111 } | Popular Tags |