- Timestamp:
- 2008-10-29T20:04:25+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/remote/RemoteGreenstoneServer.java
r17612 r17630 66 66 67 67 public RemoteGreenstoneServer() { 68 // Create the progress_bar first since ActionQueue uses it in its thread 69 // (the thread will start immediately). 70 progress_bar = new RemoteGreenstoneServer.ProgressBar(); 68 71 remote_greenstone_server_action_queue = new ActionQueue(); 69 progress_bar = new RemoteGreenstoneServer.ProgressBar();70 72 } 71 73 … … 230 232 } 231 233 } 232 234 233 235 234 236 // ---------------------------------------------------------------------------------------------------- … … 240 242 private String performAction(RemoteGreenstoneServerAction remote_greenstone_server_action) 241 243 { 244 // Check for whether the queue thread stopped running because 245 // the user cancelled out. If so, exit GLI. 246 if(remote_greenstone_server_action_queue.hasExited()) { 247 remote_greenstone_server_action_queue.clear(); 248 //remote_greenstone_server_action_queue = null; 249 Gatherer.exit(); 250 return ""; 251 } 252 242 253 // Add the action to the queue 243 254 remote_greenstone_server_action_queue.addAction(remote_greenstone_server_action); 255 String threadName = Thread.currentThread().getName(); 244 256 245 257 // If we're running in the GUI thread we must return immediately 246 258 // We cannot wait for the action to complete because this will block any GUI updates 247 259 if (SwingUtilities.isEventDispatchThread()) { 248 System.err.println("WARNING: In event dispatch thread, returning immediately..."); 260 System.err.println(threadName 261 + "\tACTION QUEUED: In event dispatch thread, returning immediately...\n\t" 262 + remote_greenstone_server_action); 249 263 return null; 250 264 } 251 265 252 266 // Otherwise wait until the action is processed 253 while (!remote_greenstone_server_action.processed){267 try { 254 268 synchronized (remote_greenstone_server_action) { 255 try { 269 while(!remote_greenstone_server_action.processed) { 270 //System.err.println("Waiting for action to complete...: " + remote_greenstone_server_action); 256 271 DebugStream.println("Waiting for action to complete..."); 257 remote_greenstone_server_action.wait( 500);272 remote_greenstone_server_action.wait(); // wait to be notified when the action has been processed 258 273 } 259 catch (InterruptedException exception) {} 260 } 274 } 275 } catch (Exception e) { 276 System.err.println("RemoteGreenstoneServer.performAction() - exception: " + e); 277 e.printStackTrace(); 261 278 } 262 279 … … 285 302 } 286 303 287 288 public void setAction(String action)304 /** synchronized to avoid conflicts since several threads access this */ 305 synchronized public void setAction(String action) 289 306 { 290 307 if (action != null) { … … 310 327 } 311 328 312 public RemoteGreenstoneServer.ProgressBar getProgressBar() 329 /** synchronized to avoid conflicts since several threads access this */ 330 synchronized public RemoteGreenstoneServer.ProgressBar getProgressBar() 313 331 { 314 332 return progress_bar; … … 327 345 remote_greenstone_server_authentication = new RemoteGreenstoneServerAuthenticator().getAuthentication(); 328 346 } 329 347 330 348 331 349 static private class RemoteGreenstoneServerAuthenticator … … 366 384 } 367 385 catch (Exception exception) { 386 System.err.println("Exception occurred when authenticating the user: " + exception); 368 387 DebugStream.printStackTrace(exception); 369 388 }
Note:
See TracChangeset
for help on using the changeset viewer.