com.artima.place
Class ServicePresenter

java.lang.Object
  |
  +--com.artima.place.ServicePresenter

public abstract class ServicePresenter
extends java.lang.Object

Contains a method that allows clients to request that the service host present a service to the user. The passed Link is activated by the host, so that the host can give the user feedback about the activation progress. The host can, for example, show an animation, status messages, progress bar, etc., during the activation of the Link.


Field Summary
static int DEFAULT_ACTIVATION_TIMEOUT
          The default maximum activation time is 30 seconds.
static int DEFAULT_SINGLE_REQUEST_TIMEOUT
          The default network request timeout is 20 seconds.
 
Constructor Summary
ServicePresenter()
          Construct a ServicePresenter.
 
Method Summary
static int getActivationTimeout()
          Returns the recommended activation timeout.
static ServicePresenter getDefault()
          Gets the default ServicePresenter object.
static int getSingleRequestTimeout()
          Returns the recommended single request timeout.
abstract  void presentService(Link link)
          Presents a service to a user.
static void setLatencyTimeouts(int singleRequestTimeout, int activationTimeout)
          Sets the two recommended latency timeouts: the single request timeout and the activation timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ACTIVATION_TIMEOUT

public static final int DEFAULT_ACTIVATION_TIMEOUT
The default maximum activation time is 30 seconds. This value is expressed in milliseconds. This is the value that getMaxActivationTime will return if it is not explicitly set by the client via setMaxActivationTime.

DEFAULT_SINGLE_REQUEST_TIMEOUT

public static final int DEFAULT_SINGLE_REQUEST_TIMEOUT
The default network request timeout is 20 seconds. This value is expressed in milliseconds. This is the value that getNetworkRequestTimeout will return if it is not explicitly set by the client via setNetworkRequestTimeout.
Constructor Detail

ServicePresenter

public ServicePresenter()
Construct a ServicePresenter.
Method Detail

setLatencyTimeouts

public static void setLatencyTimeouts(int singleRequestTimeout,
                                      int activationTimeout)
Sets the two recommended latency timeouts: the single request timeout and the activation timeout.

Link activations may use the single request timeout in deciding when to stop attempting to contact a particular server on the network. This value may be used, for example, if the link has several alternative servers that would yield the same service. If one is down (hasn't been reached within the single request timeout), the link could give up on that server and try the next in line. Link activations are not in any way required to use this value.

Link activations may use the activation timeout in deciding when to declare that an activation has failed due to no or slow response on the network. Link activations are not in any way required to use this value.

Parameters:
singleRequestTimeout - the recommended single request timeout, expressed in milliseconds
activationTimeout - the recommended activation timeout, expressed in milliseconds
Throws:
java.lang.IllegalArgumentException - if either of passed activationTimeout or singleRequestTimeout is less than or equal to zero, or if singleRequestTimeout is greater than activationTimeout

getActivationTimeout

public static int getActivationTimeout()
Returns the recommended activation timeout. Link activations may use this value in deciding when to declare that an activation has failed due to no or slow response on the network. Service presenters may dynamically adjust this value via the setLatencyTimeouts method to reflect user preferences and observed network latency. Link activations are not in any way required to use this value.
Returns:
the recommended activation timeout, expressed in milliseconds.

getSingleRequestTimeout

public static int getSingleRequestTimeout()
Returns the recommended single request timeout. Link activations may use this value in deciding when to stop attempting to contact a particular server on the network. This value may be used, for example, if the link has several alternative servers that would yield the same service. If one is down (hasn't been reached within the single request timeout), the link could give up on that server and try the next in line. Link activations are not in any way required to use this value.
Returns:
the recommended single request timeout, expressed in milliseconds.

presentService

public abstract void presentService(Link link)
Presents a service to a user. This method will return promptly. If the method needs to do something on the network, which it often will, that something will need to be done in a different thread. This means that a GUI event handler thread should be able to safely invoke this method directly without fear that doing so will "hang" their UI.
Parameters:
link - the Link that, when activated, will produce a service to present to the user.

getDefault

public static ServicePresenter getDefault()
Gets the default ServicePresenter object.
Returns:
the default ServicePresenter.