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 43 public class PullPullAggregatorWhileNotNullImpl extends AbstractComponent 44 implements 45 Pull, 46 PullPullAggregatorWhileNotNullAttributeController 47 { 48 52 boolean pullEmptyMessagePolicy; 53 54 58 protected Pull inPullItf; 59 protected MessageManager messageManagerItf; 60 61 65 68 public Message pull(Map context) throws PullException 69 { 70 Message inMessage = inPullItf.pull(context); 71 if (inMessage == null && (!pullEmptyMessagePolicy)) 72 { 73 return null; 74 } 75 ExtensibleMessage outMessage = null; 76 outMessage = (ExtensibleMessage) messageManagerItf 77 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 78 while (inMessage != null) 79 { 80 outMessage.addSubMessage(inMessage); 81 inMessage = inPullItf.pull(context); 82 } 83 return outMessage; 84 } 85 86 90 93 public boolean getPullEmptyMessagePolicy() 94 { 95 return pullEmptyMessagePolicy; 96 } 97 98 101 public void setPullEmptyMessagePolicy(boolean policy) 102 { 103 pullEmptyMessagePolicy = policy; 104 } 105 106 110 113 public String [] listFc() 114 { 115 return new String []{MessageManager.ITF_NAME, Pull.IN_PULL_ITF_NAME}; 116 } 117 118 122 public synchronized void bindFc(String clientItfName, Object serverItf) 123 throws NoSuchInterfaceException, IllegalBindingException, 124 IllegalLifeCycleException 125 { 126 super.bindFc(clientItfName, serverItf); 127 if (clientItfName.equals(MessageManager.ITF_NAME)) 128 { 129 messageManagerItf = (MessageManager) serverItf; 130 } 131 else if (clientItfName.equals(Pull.IN_PULL_ITF_NAME)) 132 { 133 inPullItf = (Pull) serverItf; 134 } 135 136 } 137 } | Popular Tags |