1 24 25 package org.objectweb.dream.protocol.utobcast; 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.dream.protocol.utobcast.message.UTOBcastChunk; 34 import org.objectweb.fractal.api.NoSuchInterfaceException; 35 import org.objectweb.fractal.api.control.IllegalBindingException; 36 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 37 import org.objectweb.util.monolog.api.BasicLevel; 38 39 45 public class IncomingMessageRouterImpl extends AbstractComponent 46 implements 47 Push 48 { 49 50 54 55 protected Push[] outPushItfs = new Push[6]; 56 57 61 64 public IncomingMessageRouterImpl() 65 { 66 } 67 68 72 76 public void push(Message message, Map context) throws PushException 77 { 78 UTOBcastChunk chunk = (UTOBcastChunk) message 80 .getChunk(UTOBcastChunk.DEFAULT_NAME); 81 if (chunk == null) 82 { 83 logger.log(BasicLevel.ERROR, 84 "The message does not contain an UTOBcast chunk:" + message); 85 throw new PushException("The message does not contain an UTOBcast chunk:" 86 + message); 87 } 88 outPushItfs[chunk.getUTOBcastMessageType()].push(message, null); 89 } 90 91 95 99 public void bindFc(String clientItfName, Object serverItf) 100 throws NoSuchInterfaceException, IllegalBindingException, 101 IllegalLifeCycleException 102 { 103 super.bindFc(clientItfName, serverItf); 104 if (clientItfName.endsWith("DAT")) 105 { 106 outPushItfs[UTOBcastChunk.DAT] = (Push) serverItf; 107 } 108 else if (clientItfName.endsWith("ACK")) 109 { 110 outPushItfs[UTOBcastChunk.ACK] = (Push) serverItf; 111 } 112 else if (clientItfName.endsWith("REP")) 113 { 114 outPushItfs[UTOBcastChunk.REP] = (Push) serverItf; 115 } 116 else if (clientItfName.endsWith("UTO")) 117 { 118 outPushItfs[UTOBcastChunk.UTO] = (Push) serverItf; 119 } 120 else if (clientItfName.endsWith("UPD")) 121 { 122 outPushItfs[UTOBcastChunk.UPD] = (Push) serverItf; 123 } 124 else if (clientItfName.endsWith("BAK")) 125 { 126 outPushItfs[UTOBcastChunk.BAK] = (Push) serverItf; 127 } 128 } 129 130 134 public void unbindFc(String clientItfName) throws NoSuchInterfaceException, 135 IllegalBindingException, IllegalLifeCycleException 136 { 137 super.unbindFc(clientItfName); 138 if (clientItfName.endsWith("DAT")) 139 { 140 outPushItfs[UTOBcastChunk.DAT] = null; 141 } 142 else if (clientItfName.endsWith("ACK")) 143 { 144 outPushItfs[UTOBcastChunk.ACK] = null; 145 } 146 else if (clientItfName.endsWith("REP")) 147 { 148 outPushItfs[UTOBcastChunk.REP] = null; 149 } 150 else if (clientItfName.endsWith("UTO")) 151 { 152 outPushItfs[UTOBcastChunk.UTO] = null; 153 } 154 else if (clientItfName.endsWith("UPD")) 155 { 156 outPushItfs[UTOBcastChunk.UPD] = null; 157 } 158 else if (clientItfName.endsWith("BAK")) 159 { 160 outPushItfs[UTOBcastChunk.BAK] = null; 161 } 162 } 163 164 167 public String [] listFc() 168 { 169 String [] tab = new String [outPushItfs.length]; 170 tab[0] = Push.OUT_PUSH_ITF_NAME + "-DAT"; 171 tab[1] = Push.OUT_PUSH_ITF_NAME + "-ACK"; 172 tab[2] = Push.OUT_PUSH_ITF_NAME + "-REP"; 173 tab[3] = Push.OUT_PUSH_ITF_NAME + "-UTO"; 174 tab[4] = Push.OUT_PUSH_ITF_NAME + "-UPD"; 175 tab[5] = Push.OUT_PUSH_ITF_NAME + "-BAK"; 176 return tab; 177 } 178 179 } | Popular Tags |