[sword-cvs] sword/bindings/corba/java/src/org/crosswire/sword/orb SwordOrb.java,1.2,1.3

sword@www.crosswire.org sword@www.crosswire.org
Mon, 5 May 2003 12:07:40 -0700


Update of /usr/local/cvsroot/sword/bindings/corba/java/src/org/crosswire/sword/orb
In directory www:/tmp/cvs-serv18375/bindings/corba/java/src/org/crosswire/sword/orb

Modified Files:
	SwordOrb.java 
Log Message:


Index: SwordOrb.java
===================================================================
RCS file: /usr/local/cvsroot/sword/bindings/corba/java/src/org/crosswire/sword/orb/SwordOrb.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SwordOrb.java	4 May 2003 08:40:13 -0000	1.2
--- SwordOrb.java	5 May 2003 19:07:38 -0000	1.3
***************
*** 30,39 ****
  
  //	this doesn't seem to work.  Never seems to get called for me
! 	protected void finalize() throws Throwable {
! System.out.println("finalizing");
  		try {
  			getSWMgrInstance().terminate();
  		}
  		catch (Exception e) {}	// we know this doesn't return property cuz we killed the orb! :)
  	}
  
--- 30,43 ----
  
  //	this doesn't seem to work.  Never seems to get called for me
! 	public void finalize () throws Throwable {
! 		// shut down external process
! System.err.println("finalizing");
  		try {
  			getSWMgrInstance().terminate();
  		}
  		catch (Exception e) {}	// we know this doesn't return property cuz we killed the orb! :)
+ 
+ 		// release thread
+ 		waitor.setFinished();
  	}
  
***************
*** 48,53 ****
  	private void startOrb() {
  		try {
  			java.lang.Process p = Runtime.getRuntime().exec("./swordorbserver");
- 
  			InputStream is = p.getInputStream();
  			InputStreamReader isr = new InputStreamReader(is);
--- 52,59 ----
  	private void startOrb() {
  		try {
+ 			waitor = new Waitor ();
+ 			new Thread (waitor).run ();
+ 			// start external process
  			java.lang.Process p = Runtime.getRuntime().exec("./swordorbserver");
  			InputStream is = p.getInputStream();
  			InputStreamReader isr = new InputStreamReader(is);
***************
*** 88,92 ****
  
  
! 	public static void main(String args[]) {
  		SWMgr mgr = new SwordOrb().getSWMgrInstance();
  
--- 94,101 ----
  
  
! 	public static void main(String args[]) throws Exception {
! 		new SwordOrb ();
! 		Thread.sleep(100);
! 		/*
  		SWMgr mgr = new SwordOrb().getSWMgrInstance();
  
***************
*** 98,104 ****
  			System.out.println(modInfoList[i].name + ": " + modInfoList[i].type + ": " + modInfoList[i].lang);
  		}
  	}
  
  }
  
! 
--- 107,129 ----
  			System.out.println(modInfoList[i].name + ": " + modInfoList[i].type + ": " + modInfoList[i].lang);
  		}
+ 		*/
  	}
  
+ public class Waitor implements Runnable {
+   protected boolean finished = false;
+   public Waitor () {
+   }
+   public void setFinished () {
+     finished = true;
+   }
+   public void run () {
+     while (!finished) {
+ 	    try { Thread.sleep (100); } catch (Exception e) { e.printStackTrace(); }
+ 	 // possibly even:
+ 	 // System.gc();
+     }
+   }
  }
+   protected Waitor waitor;
  
! }
\ No newline at end of file