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.Push; 33 import org.objectweb.dream.PushException; 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 47 public class PushPullAggregatorImpl extends AbstractComponent 48 implements 49 Push, 50 Pull 51 { 52 53 54 protected MessageManager messageManagerItf; 55 56 60 protected ExtensibleMessage nextAggregatedMessage = null; 61 62 65 public synchronized void push(Message message, Map context) 66 throws PushException 67 { 68 if (nextAggregatedMessage == null) 69 { 70 nextAggregatedMessage = (ExtensibleMessage) messageManagerItf 71 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 72 } 73 nextAggregatedMessage.addSubMessage(message); 74 } 75 76 79 public synchronized Message pull(Map context) throws PullException 80 { 81 if (nextAggregatedMessage == null) 82 { 83 return (ExtensibleMessage) messageManagerItf 84 .createMessage(MessageTypeImpl.EMPTY_MESSAGE_TYPE); 85 } 86 else 87 { 88 Message msg = nextAggregatedMessage; 89 nextAggregatedMessage = null; 90 return msg; 91 } 92 } 93 94 98 101 public String [] listFc() 102 { 103 return new String []{MessageManager.ITF_NAME}; 104 } 105 106 110 public synchronized void bindFc(String clientItfName, Object serverItf) 111 throws NoSuchInterfaceException, IllegalBindingException, 112 IllegalLifeCycleException 113 { 114 super.bindFc(clientItfName, serverItf); 115 if (clientItfName.equals(MessageManager.ITF_NAME)) 116 { 117 messageManagerItf = (MessageManager) serverItf; 118 } 119 } 120 121 } | Popular Tags |