1 24 25 package org.objectweb.tribe.adapters; 26 27 import java.io.Serializable ; 28 import java.util.ArrayList ; 29 30 import org.objectweb.tribe.common.Member; 31 import org.objectweb.tribe.common.log.Trace; 32 33 39 public class MulticastRequestAdapterThread extends Thread 40 { 41 42 private MulticastRequestListener multicastRequestListener; 43 private PullPushAdapter pullPushAdapter; 44 private MulticastRequestAdapterMessage requestReply; 45 private Object singleTheadedCallback; 46 private Member me; 47 private static Trace logger = Trace 48 .getLogger("org.objectweb.tribe.blocks.multicastdispatcher"); 49 50 59 public MulticastRequestAdapterThread(MulticastRequestListener listener, 60 MulticastRequestAdapterMessage requestReply, 61 Object singleTheadedCallback, PullPushAdapter pullPushAdapter, 62 Member senderMembership) 63 { 64 super("MulticastRequestAdapterThread"); 65 this.multicastRequestListener = listener; 66 this.requestReply = requestReply; 67 this.singleTheadedCallback = singleTheadedCallback; 68 this.me = senderMembership; 69 this.pullPushAdapter = pullPushAdapter; 70 } 71 72 75 public void run() 76 { 77 Member replyTo = requestReply.getSender(); 78 79 Serializable reply = multicastRequestListener.handleMessageMultiThreaded( 80 requestReply.getMessage(), replyTo, singleTheadedCallback); 81 if (!requestReply.isRequestOnly()) 82 { 83 MulticastRequestAdapterMessage answer = new MulticastRequestAdapterMessage( 88 reply, me, requestReply.getUid(), 89 MulticastRequestAdapterMessage.REPLY); 90 ArrayList replyList = new ArrayList (1); 91 replyList.add(replyTo); 92 try 93 { 94 if (logger.isDebugEnabled()) 95 logger.debug("Replying to " + replyTo + " for message " 96 + requestReply.getUid()); 97 pullPushAdapter.send(answer, replyList); 98 } 99 catch (Exception e) 100 { 101 logger 102 .info("Error while replying to " + replyTo + " for message " 103 + requestReply.getUid() + " (" + requestReply.getMessage() 104 + ")", e); 105 } 106 } 107 } 108 109 } | Popular Tags |