import java.lang.*; import java.io.*; import java.util.*; import EDU.neu.ccs.demeter.*; class TimeOut extends Service { protected float timeout; public float get_timeout() { return timeout; } public void set_timeout(float new_timeout) { timeout = new_timeout; } protected Service service; public Service get_service() { return service; } public void set_service(Service new_service) { service = new_service; } public TimeOut() { super(); } public TimeOut(float timeout, Service service) { super(); set_timeout(timeout); set_service(service); } public static TimeOut parse(java.io.Reader in) throws ParseException { return new Parser(in)._TimeOut(); } public static TimeOut parse(java.io.InputStream in) throws ParseException { return new Parser(in)._TimeOut(); } public static TimeOut parse(String s) { try { return parse(new java.io.StringReader(s)); } catch (ParseException e) { throw new RuntimeException(e.toString()); } } void universal_trv0_bef(UniversalVisitor _v_) { super.universal_trv0_bef(_v_); _v_.before(this); } void universal_trv0_aft(UniversalVisitor _v_) { _v_.after(this); super.universal_trv0_aft(_v_); } void universal_trv0(UniversalVisitor _v_) { universal_trv0_bef(_v_); _v_.before_timeout(this, timeout); _v_.after_timeout(this, timeout); _v_.before_service(this, service); service.universal_trv0(_v_); _v_.after_service(this, service); super.universal_trv0(_v_); universal_trv0_aft(_v_); } void all_WebScript_trv_bef(UniversalVisitor __v0) { super.all_WebScript_trv_bef(__v0); __v0.before(this); } void all_WebScript_trv_aft(UniversalVisitor __v0) { __v0.after(this); super.all_WebScript_trv_aft(__v0); } void all_WebScript_trv(UniversalVisitor __v0) { all_WebScript_trv_bef(__v0); __v0.before_timeout(this, timeout); __v0.after_timeout(this, timeout); __v0.before_service(this, service); service.all_WebScript_trv(__v0); __v0.after_service(this, service); super.all_WebScript_trv(__v0); all_WebScript_trv_aft(__v0); } //Modified from here to implement Runnable interface. private int time; public void set_time(int tm){ time = tm; } public int get_time(){ return time; } public void run(){ serviceState = 0; time = 0; MyTimer my_timer = new MyTimer( this, timeout); my_timer.start(); Thread t = new Thread(service); t.start(); while(t.isAlive()){ if(time == 1){ try{ t.stop(); }catch(SecurityException e1){ } } } if(service.get_serviceState()==0) { try{ out1.write("\n\nTimeout, service is interrupted\n"); }catch(IOException e){ } } serviceState = service.get_serviceState(); } }