/*
* 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 ClientCommunicatorAdmin {
if (period > 0) {
t.setDaemon(true);
t.start();
} else
}
/**
* Called by a client to inform of getting an IOException.
*/
}
/**
* Called by this class to check a client connection.
*/
/**
* Tells a client to re-start again.
*/
/**
* Tells a client to stop because failing to call checkConnection.
*/
protected abstract void doStop();
/**
* Terminates this object.
*/
public void terminate() {
synchronized(lock) {
if (state == TERMINATED) {
return;
}
state = TERMINATED;
}
}
// check state
synchronized(lock) {
if (state == TERMINATED) {
throw new IOException("The client has been closed.");
throw ioe;
} else if (state == RE_CONNECTING) {
// restart process has been called by another thread
// we need to wait
while(state == RE_CONNECTING) {
try {
} catch (InterruptedException ire) {
// be asked to give up
throw iioe;
}
}
if (state == TERMINATED) {
throw new IOException("The client has been closed.");
// restarted is failed by another thread
throw ioe;
}
} else {
}
}
// re-starting
try {
doStart();
synchronized(lock) {
if (state == TERMINATED) {
throw new IOException("The client has been closed.");
}
}
return;
} catch (Exception e) {
synchronized(lock) {
if (state == TERMINATED) {
throw new IOException("The client has been closed.");
}
}
try {
doStop();
// OK.
// We know there is a problem.
}
terminate();
throw ioe;
}
}
// --------------------------------------------------------------
// private varaibles
// --------------------------------------------------------------
public void run() {
try {
} catch (InterruptedException ire) {
// OK.
// We will check the state at the following steps
}
break;
}
try {
} catch (Exception e) {
synchronized(lock) {
break;
}
}
if (e instanceof IOException &&
!(e instanceof InterruptedIOException)) {
try {
restart((IOException)e);
"Failed to check connection: "+ e);
break;
}
} else {
"Failed to check the connection: " + e);
// XXX stop checking?
break;
}
}
}
}
}
private void stop() {
}
}
}
// --------------------------------------------------------------
// private variables
// --------------------------------------------------------------
private long period;
// state
new ClassLogger("javax.management.remote.misc",
"ClientCommunicatorAdmin");
}