/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
public abstract class ServerCommunicatorAdmin {
"Creates a new ServerCommunicatorAdmin object "+
"with the timeout "+timeout);
}
timestamp = 0;
// If you change this name you will need to change a unit test
// (NoServerTimeoutTest)
t.setDaemon(true);
t.start();
}
}
/**
* Tells that a new request message is received.
* A caller of this method should always call the method
* <code>rspOutgoing</code> to inform that a response is sent out
* for the received request.
* @return the value of the termination flag:
* <ul><code>true</code> if the connection is already being terminated,
* <br><code>false</code> otherwise.</ul>
*/
public boolean reqIncoming() {
}
synchronized(lock) {
if (terminated) {
"The server has decided to close " +
"this client connection.");
}
++currentJobs;
return terminated;
}
}
/**
* Tells that a response is sent out for a received request.
* @return the value of the termination flag:
* <ul><code>true</code> if the connection is already being terminated,
* <br><code>false</code> otherwise.</ul>
*/
public boolean rspOutgoing() {
}
synchronized(lock) {
if (--currentJobs == 0) {
// tells the adminor to restart waiting with timeout
}
return terminated;
}
}
/**
* Called by this class to tell an implementation to do stop.
*/
protected abstract void doStop();
/**
* Terminates this object.
* Called only by outside, so do not need to call doStop
*/
public void terminate() {
"terminate the ServerCommunicatorAdmin object.");
}
synchronized(lock) {
if (terminated) {
return;
}
terminated = true;
// tell Timeout to terminate
}
}
// --------------------------------------------------------------
// private classes
// --------------------------------------------------------------
public void run() {
boolean stopping = false;
synchronized(lock) {
while(!terminated) {
try {
// wait until there is no more job
"Waiting without timeout.");
}
}
if (terminated) return;
final long remaining =
if (remaining > 0) {
"Waiting with timeout: "+
remaining + " ms remaining");
}
}
if (currentJobs > 0) continue;
final long elapsed =
"timeout elapsed");
}
logtime("Admin: timeout elapsed! "+
// stopping
terminated = true;
stopping = true;
break;
}
} catch (InterruptedException ire) {
ire);
return;
}
}
}
if (stopping) {
}
doStop();
}
}
}
}
// --------------------------------------------------------------
// private variables
// --------------------------------------------------------------
private long timestamp;
private long timeout;
// state issue
private boolean terminated = false;
new ClassLogger("javax.management.remote.misc",
"ServerCommunicatorAdmin");
new ClassLogger("javax.management.remote.timeout",
"ServerCommunicatorAdmin");
}