uk.ac.lancs.relate.gateways.services.architecture
Class ServiceRequester

java.lang.Object
  extended by uk.ac.lancs.relate.gateways.services.architecture.ServiceRequester
All Implemented Interfaces:
java.io.Serializable, ProvidersAndRequestersCommonInterface
Direct Known Subclasses:
MulticastServiceRequester, PresentationServiceRequester, RMIServiceRequester, SocketServiceRequester

public abstract class ServiceRequester
extends java.lang.Object
implements java.io.Serializable, ProvidersAndRequestersCommonInterface

This interface defines the methods common to all the service requestors.

Author:
Dominique Guinard
Personal Homepage
See Also:
Serialized Form

Constructor Summary
ServiceRequester(Service service)
          Default constructor for a ServiceRequester.
 
Method Summary
protected  int askForConfirmation(javax.swing.JFrame frame, java.lang.String message, java.lang.String title)
          This method is provided in order ask for user confirmation.
protected  java.io.File askToSelectFile(javax.swing.JFrame frame)
          This method prompts a FileChooser in order for the user to be able to select a file.
 void confirmShutdown()
          Method used to confirm the service requester was successfully shutdown.
 void confirmStartup()
          Method used to confirm the service requester was successfully started.
protected  void displayErrorMessage(java.lang.String message, java.lang.String title)
          This method is provided in order to give a feedback message to the used when invoking a service and an error occurs.
protected  void displayMessage(java.lang.String message, java.lang.String title)
          This method is provided in order to give a feedback message to the used when invoking a service.
protected  void displayNonBlockingMessage(javax.swing.JFrame frame, java.lang.String message, java.lang.String title)
          This method is provided in order to give a feedback message to the used when invoking a service.
 Service getService()
           
 boolean isStarted()
          Returns the requester's running status.
abstract  void request(java.lang.Object o)
          Method request a service from a service provider
 void setService(Service service)
           
protected  void setStarted(boolean started)
          Sets the requester's running status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ac.lancs.relate.gateways.services.architecture.ProvidersAndRequestersCommonInterface
shutdown, startup
 

Constructor Detail

ServiceRequester

public ServiceRequester(Service service)
Default constructor for a ServiceRequester. A provider is always attached to a service..

Method Detail

confirmStartup

public void confirmStartup()
Method used to confirm the service requester was successfully started. This method is to be used by concrete rquesters once their startup() procedure was successfully executed. It prevents a not fully started service to be in the running state.


confirmShutdown

public void confirmShutdown()
Method used to confirm the service requester was successfully shutdown. This method is to be used by concrete requesters once their shutdown() procedure was successfully executed. It prevents a not fully shutdown service to be in the "not running" state.


request

public abstract void request(java.lang.Object o)
Method request a service from a service provider


displayNonBlockingMessage

protected void displayNonBlockingMessage(javax.swing.JFrame frame,
                                         java.lang.String message,
                                         java.lang.String title)
This method is provided in order to give a feedback message to the used when invoking a service. The feedback is given in the form of a non-blocking dialog box.


displayMessage

protected void displayMessage(java.lang.String message,
                              java.lang.String title)
This method is provided in order to give a feedback message to the used when invoking a service. The feedback is given in the form of a blocking dialog box.


displayErrorMessage

protected void displayErrorMessage(java.lang.String message,
                                   java.lang.String title)
This method is provided in order to give a feedback message to the used when invoking a service and an error occurs. The feedback is given in the form of a blocking error dialog box.


askForConfirmation

protected int askForConfirmation(javax.swing.JFrame frame,
                                 java.lang.String message,
                                 java.lang.String title)
This method is provided in order ask for user confirmation. The dialog is modal (i.e. blocking the process thread until the user provides an answer).


askToSelectFile

protected java.io.File askToSelectFile(javax.swing.JFrame frame)
                                throws ServiceCancelledException
This method prompts a FileChooser in order for the user to be able to select a file.

Parameters:
frame - the frame on which to display the FileChooser.
Returns:
the selected file (null if nothing was selected)
Throws:
ServiceException - an exception is raised if the user cancels the file selection
ServiceCancelledException

isStarted

public boolean isStarted()
Returns the requester's running status.


setStarted

protected void setStarted(boolean started)
Sets the requester's running status.


getService

public Service getService()

setService

public void setService(Service service)