001 package railo.cli; 002 003 import java.rmi.registry.Registry; 004 import java.rmi.server.UnicastRemoteObject; 005 006 public class Closer extends Thread { 007 008 private String name; 009 private Registry reg; 010 private long idleTime; 011 private CLIInvokerImpl invoker; 012 013 public Closer(Registry reg, CLIInvokerImpl invoker, String name, long idleTime) { 014 this.reg=reg; 015 this.name=name; 016 this.idleTime=idleTime; 017 this.invoker=invoker; 018 } 019 020 public void run() { 021 // idle 022 do{ 023 sleepEL(idleTime); 024 } 025 while(invoker.lastAccess()+idleTime>System.currentTimeMillis()); 026 027 028 try { 029 reg.unbind(name); 030 UnicastRemoteObject.unexportObject(invoker,true); 031 } catch (Throwable t) { 032 t.printStackTrace(); 033 } 034 035 } 036 037 private void sleepEL(long millis) { 038 try { 039 sleep(millis); 040 } catch (Throwable t) {t.printStackTrace();} 041 } 042 043 }