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 47 public class PullPullAggregatorFixedNumberImpl extends AbstractComponent 48 implements 49 Pull, 50 PullPullAggregatorFixedNumberAttributeController 51 { 52 53 private Pull inPullItf; 54 55 56 protected MessageManager messageManagerItf; 57 58 private int nbMessageToAggregate; 59 60 66 public Message pull(Map context) throws PullException 67 { 68 ExtensibleMessage outMessage = (ExtensibleMessage) messageManagerItf 69 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 70 for (int i = 0; i < nbMessageToAggregate; i++) 71 { 72 outMessage.addSubMessage(inPullItf.pull(context)); 73 } 74 return outMessage; 75 } 76 77 82 85 public int getNbMessagesToAggregate() 86 { 87 return nbMessageToAggregate; 88 } 89 90 93 public void setNbMessagesToAggregate(int nb) 94 { 95 this.nbMessageToAggregate = nb; 96 } 97 98 102 106 public synchronized void bindFc(String clientItfName, Object serverItf) 107 throws NoSuchInterfaceException, IllegalBindingException, 108 IllegalLifeCycleException 109 { 110 super.bindFc(clientItfName, serverItf); 111 if (clientItfName.equals(Pull.IN_PULL_ITF_NAME)) 112 { 113 inPullItf = (Pull) serverItf; 114 } 115 else if (clientItfName.equals(MessageManager.ITF_NAME)) 116 { 117 messageManagerItf = (MessageManager) serverItf; 118 } 119 } 120 121 124 public String [] listFc() 125 { 126 return new String []{Pull.IN_PULL_ITF_NAME, MessageManager.ITF_NAME}; 127 } 128 129 } | Popular Tags |