@Override protected Naming getNamingProxy() throws Exception { this.rmiserver = new HARMIServerImpl(this.clusterPartition, this.replicantName, Naming.class, this.theServer, this.rmiPort, this.clientSocketFactory, this.serverSocketFactory, this.rmiBindAddress); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Class<?> clazz = cl.loadClass(this.loadBalancePolicy); LoadBalancePolicy policy = (LoadBalancePolicy)clazz.newInstance(); Naming proxy = (Naming) this.rmiserver.createHAStub(policy); return proxy; } }
@Override protected void stopService() throws Exception { super.stopService(); // Unexport server this.log.debug("destroy ha rmiserver"); this.rmiserver.destroy (); }
public void startRMIServer(NullActivityFactoryImpl naf, SleeInternalEndpoint endpoint, EventLookup eventLookup, ActivityContextFactoryImpl activityContextFactory) { RemoteSleeService stub = null; try { if (logger.isDebugEnabled()) { logger.debug("Starting Slee Service HARMI Server"); } InitialContext ctx = new InitialContext(); // TODO This shouldn't be hardcoded - use a config. file to // configure the partition name, jndi name, port number and // inetaddress HAPartition myPartition = (HAPartition) ctx .lookup("/HAPartition/DefaultPartition"); rmiServer = new HARMIServerImpl(myPartition, "RemoteSleeService", RemoteSleeService.class, new RemoteSleeServiceImpl(naf, eventLookup, activityContextFactory)); stub = (RemoteSleeService) rmiServer .createHAStub(new FirstAvailable()); ctx.rebind("/SleeService", stub); if (logger.isDebugEnabled()) { logger.debug("Bound SleeService rmi stub in jndi"); } } catch (Exception e) { logger.error("Failed to start HA RMI server for Remote slee service", e); } }
public void stopRMIServer() { try { if (logger.isDebugEnabled()) { logger.debug("Stopping HA RMI Server for slee service"); } InitialContext ctx = new InitialContext(); Util.unbind(ctx, "/SleeService"); rmiServer.destroy(); } catch (NamingException e) { logger .error("Failed to stop HA RMI Server for remote slee service", e); } } }