1 22 package fr.dyade.aaa.jndi2.ha; 23 24 import java.net.*; 25 26 import fr.dyade.aaa.agent.*; 27 import fr.dyade.aaa.jndi2.server.*; 28 29 import org.objectweb.util.monolog.api.BasicLevel; 30 import org.objectweb.util.monolog.api.Logger; 31 32 public class HAJndiServer { 33 34 private static HATcpServer tcpServer; 35 36 public static void init(String args, boolean firstTime) throws Exception { 37 if (Trace.logger.isLoggable(BasicLevel.DEBUG)) 38 Trace.logger.log(BasicLevel.DEBUG, "HAJndiServer.init(" + 39 args + ',' + firstTime + ')'); 40 int port = Integer.parseInt(args); 41 42 ServerSocket serverSocket = new ServerSocket(port); 45 46 tcpServer = new HATcpServer( 47 serverSocket, 48 3, 49 getDefault()); 50 tcpServer.start(); 51 52 if (firstTime) { 53 RequestManager manager = new RequestManager(); 54 55 HARequestManager haManager = new HARequestManager(); 56 haManager.setRequestManager(manager); 57 58 AgentEntryPoint agentEP = new AgentEntryPoint(); 59 agentEP.setRequestManager(manager); 60 61 HAEntryPoint haEP = new HAEntryPoint(); 62 haEP.setHARequestManager(haManager); 63 64 Container container = new Container(); 65 container.addEntryPoint(agentEP); 66 container.addEntryPoint(haEP); 67 container.setLifeCycleListener(haManager); 68 container.setBagSerializer(haManager); 69 manager.setContainer(container); 70 container.deploy(); 71 } 72 } 73 74 77 public static void stopService() { 78 tcpServer.stop(); 79 } 80 81 86 public static AgentId getDefault() { 87 return getDefault(AgentServer.getServerId()); 88 } 89 90 96 public static AgentId getDefault(short serverId) { 97 return new AgentId( 98 serverId, serverId, 99 AgentId.LocalJndiServiceStamp); 100 } 101 } 102 | Popular Tags |