1 24 25 package org.objectweb.dream.protocol.atomicity; 26 27 import java.util.Map ; 28 29 import org.objectweb.dream.AbstractComponent; 30 import org.objectweb.dream.Push; 31 import org.objectweb.dream.PushException; 32 import org.objectweb.dream.message.Message; 33 import org.objectweb.fractal.api.NoSuchInterfaceException; 34 import org.objectweb.fractal.api.control.IllegalBindingException; 35 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 36 37 42 public class AtomicRouterImpl extends AbstractComponent 43 implements 44 Push, 45 SetReactorThread 46 { 47 48 52 public static final String OUT_REACT_PUSH_ITF_NAME = "outReactPush"; 53 54 58 public static final String OUT_NOT_REACT_PUSH_ITF_NAME = "outNotReactPush"; 59 60 private Push outReactPushItf; 61 private Push outNotReactPushItf; 62 private Thread reactorThread; 63 64 67 public void push(Message message, Map context) throws PushException 68 { 69 if (Thread.currentThread() == reactorThread) 70 { 71 outReactPushItf.push(message, context); 72 } 73 else 74 { 75 outNotReactPushItf.push(message, context); 76 } 77 } 78 79 82 public void setReactorThread(Thread reactorThread) 83 { 84 this.reactorThread = reactorThread; 85 } 86 87 91 94 public String [] listFc() 95 { 96 return new String []{OUT_REACT_PUSH_ITF_NAME, OUT_NOT_REACT_PUSH_ITF_NAME}; 97 } 98 99 103 public synchronized void bindFc(String clientItfName, Object serverItf) 104 throws NoSuchInterfaceException, IllegalBindingException, 105 IllegalLifeCycleException 106 { 107 super.bindFc(clientItfName, serverItf); 108 if (clientItfName.equals(OUT_REACT_PUSH_ITF_NAME)) 109 { 110 outReactPushItf = (Push) serverItf; 111 } 112 else if (clientItfName.equals(OUT_NOT_REACT_PUSH_ITF_NAME)) 113 { 114 outNotReactPushItf = (Push) serverItf; 115 } 116 } 117 118 } | Popular Tags |