40 this.timeout = timeout; 41 42 timestamp = 0; 43 if (timeout < Long.MAX_VALUE) { 44 Runnable timeoutTask = new Timeout(); 45 final Thread t = new ManagedLocalsThread(timeoutTask); 46 t.setName("JMX server connection timeout " + t.getId()); 47 // If you change this name you will need to change a unit test 48 // (NoServerTimeoutTest) 49 t.setDaemon(true); 50 t.start(); 51 } 52 } 53 54 /** 55 * Tells that a new request message is received. 56 * A caller of this method should always call the method 57 * <code>rspOutgoing</code> to inform that a response is sent out 58 * for the received request. 59 * @return the value of the termination flag: 60 * <ul><code>true</code> if the connection is already being terminated, 61 * <br><code>false</code> otherwise.</ul> 62 */ 63 public boolean reqIncoming() { 64 if (logger.traceOn()) { 65 logger.trace("reqIncoming", "Receive a new request."); 66 } 67 68 synchronized(lock) { 69 if (terminated) { 70 logger.warning("reqIncoming", 71 "The server has decided to close " + 72 "this client connection."); 73 } 74 ++currentJobs; 75 76 return terminated; 77 } 78 } 79 80 /** 81 * Tells that a response is sent out for a received request. 82 * @return the value of the termination flag: 83 * <ul><code>true</code> if the connection is already being terminated, 84 * <br><code>false</code> otherwise.</ul> 85 */ 86 public boolean rspOutgoing() { 87 if (logger.traceOn()) { 88 logger.trace("reqIncoming", "Finish a request."); 89 } 90 91 synchronized(lock) { 92 if (--currentJobs == 0) { 93 timestamp = System.currentTimeMillis(); 94 logtime("Admin: Timestamp=",timestamp); 95 // tells the adminor to restart waiting with timeout 96 lock.notify(); 97 } 98 return terminated; 99 } 100 } 101 102 /** 103 * Called by this class to tell an implementation to do stop. 104 */ | 40 this.timeout = timeout; 41 42 timestamp = 0; 43 if (timeout < Long.MAX_VALUE) { 44 Runnable timeoutTask = new Timeout(); 45 final Thread t = new ManagedLocalsThread(timeoutTask); 46 t.setName("JMX server connection timeout " + t.getId()); 47 // If you change this name you will need to change a unit test 48 // (NoServerTimeoutTest) 49 t.setDaemon(true); 50 t.start(); 51 } 52 } 53 54 /** 55 * Tells that a new request message is received. 56 * A caller of this method should always call the method 57 * <code>rspOutgoing</code> to inform that a response is sent out 58 * for the received request. 59 * @return the value of the termination flag: 60 * true if the connection is already being terminated, 61 * false otherwise. 62 */ 63 public boolean reqIncoming() { 64 if (logger.traceOn()) { 65 logger.trace("reqIncoming", "Receive a new request."); 66 } 67 68 synchronized(lock) { 69 if (terminated) { 70 logger.warning("reqIncoming", 71 "The server has decided to close " + 72 "this client connection."); 73 } 74 ++currentJobs; 75 76 return terminated; 77 } 78 } 79 80 /** 81 * Tells that a response is sent out for a received request. 82 * @return the value of the termination flag: 83 * true if the connection is already being terminated, 84 * false otherwise. 85 */ 86 public boolean rspOutgoing() { 87 if (logger.traceOn()) { 88 logger.trace("reqIncoming", "Finish a request."); 89 } 90 91 synchronized(lock) { 92 if (--currentJobs == 0) { 93 timestamp = System.currentTimeMillis(); 94 logtime("Admin: Timestamp=",timestamp); 95 // tells the adminor to restart waiting with timeout 96 lock.notify(); 97 } 98 return terminated; 99 } 100 } 101 102 /** 103 * Called by this class to tell an implementation to do stop. 104 */ |