1 23 package fr.dyade.aaa.jndi2.server; 24 25 import fr.dyade.aaa.agent.*; 26 import fr.dyade.aaa.jndi2.msg.*; 27 28 import org.objectweb.util.monolog.api.BasicLevel; 29 import org.objectweb.util.monolog.api.Logger; 30 31 public class AgentEntryPoint implements EntryPoint { 32 33 private RequestManager manager; 34 35 public void setRequestManager(RequestManager manager) { 36 this.manager = manager; 37 } 38 39 public boolean accept(AgentId from, Notification not) throws Exception { 40 if (not instanceof JndiScriptRequestNot) { 41 doReact(from, (JndiScriptRequestNot)not); 42 } else return false; 43 return true; 44 } 45 46 52 private void doReact(AgentId from, JndiScriptRequestNot not) throws Exception { 53 if (Trace.logger.isLoggable(BasicLevel.DEBUG)) 54 Trace.logger.log(BasicLevel.DEBUG, 55 "AgentEntryPoint[" + manager.getId() + 56 "].doReact(" + from + 57 ",(JndiScriptRequestNot)" + not + ')'); 58 JndiRequest[] requests = not.getRequests(); 59 JndiReply[] replies = new JndiReply[requests.length]; 60 for (int i = 0; i < requests.length; i++) { 61 AgentRequestContext reqCtx = new AgentRequestContext( 62 requests[i], from, not.reply()); 63 replies[i] = manager.invoke(reqCtx); 64 } 65 if (not.reply()) { 66 manager.sendTo(from, new JndiScriptReplyNot(replies)); 75 } 76 } 77 } 78 | Popular Tags |