com.sun.jini.thread
Class ReadyState

java.lang.Object
  extended by com.sun.jini.thread.ReadyState

public class ReadyState
extends Object

Utility class used to prevent access to a service before it has completed its initialization or after it starts to shutdown. Each public entry point to the service should call check or shutdown, and initialization should call ready when the service is ready to use.

Since:
2.1
Author:
Sun Microsystems, Inc.

Nested Class Summary
private static class ReadyState.RemoteExceptionWrapper
          Wrapper used to prevent a RemoteException from being wrapped in a ServerException by the RMI implementation.
 
Field Summary
private static int INITIALIZE
           
private static int READY
           
private static int SHUTDOWN
           
private  int state
           
 
Constructor Summary
ReadyState()
           
 
Method Summary
 void check()
          Checks if the service is ready to use, waiting if it is initializing, and throwing NoSuchObjectException if it is shutting down.
 void ready()
          Marks the service ready for use.
 void shutdown()
          Marks the service as shutting down, waiting if it is initializing, and throwing NoSuchObjectException if it is already shutting down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIALIZE

private static final int INITIALIZE
See Also:
Constant Field Values

READY

private static final int READY
See Also:
Constant Field Values

SHUTDOWN

private static final int SHUTDOWN
See Also:
Constant Field Values

state

private int state
Constructor Detail

ReadyState

public ReadyState()
Method Detail

check

public void check()
Checks if the service is ready to use, waiting if it is initializing, and throwing NoSuchObjectException if it is shutting down. Note that the NoSuchObjectException will be wrapped in a RemoteExceptionWrapper.


ready

public void ready()
Marks the service ready for use. This method should only be called from the code that performs the service initialization, and it should only be called once.


shutdown

public void shutdown()
Marks the service as shutting down, waiting if it is initializing, and throwing NoSuchObjectException if it is already shutting down. Note that the NoSuchObjectException will be wrapped in a RemoteExceptionWrapper.



Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.