package com.marinilli.b2.c7.deploylet;
import java.rmi.*;

/**
 * Chapter 7 - Deployable interface
 *
 * This interface models the lifecycle of a deployable application,
 * abstracting from its client/server actual implementation.
 *
 * @author Mauro Marinilli
 * @version 1.0
 */
public interface Deploylet extends Remote {

  // lifecycle methods

  /**
   * triggers the publication phase
   */
  public void publish() throws RemoteException;

  /**
   * implements the resolution phase
   */
  public void resolve() throws RemoteException;

  /**
   * implements the application update phase
   */
  public void applicationUpdate() throws RemoteException;

  /**
   * implements the application un-installation phase
   */
  public void applicationUninstallation() throws RemoteException;

  /**
   * implements the application installation phase
   */
  public void applicationInstallation() throws RemoteException;

  /**
   * implements the application configuration phase
   */
  public void applicationConfiguration() throws RemoteException;

  /**
   * implements the resources installation phase
   */
  public void resoucesInstallation() throws RemoteException;

  /**
   * implements the JRE prepaparation phase
   */
  public void JREPreparation() throws RemoteException;


  /**
   * triggered on the client (applet) by the start() method
   */
  public void startApplication() throws RemoteException;

  /**
   * triggered on the client (applet) by the stop() method
   */
  public void stopApplication() throws RemoteException;

  /**
   * implements the application initialization
   */
  public void initApplication() throws RemoteException;

  //
  // runtime services methods

  /**
   * requests a service to its counterpart
   */
  public ServiceResult requestService(DeploymentService ds) throws RemoteException;

  //
  // support methods

  /**
   * get the server side of this deploylet (a servlet instance)
   */
  public Deploylet getServer() throws RemoteException;

  /**
   * get the client side of this deploylet (an applet instance)
   */
  public Deploylet getClient() throws RemoteException;

  /**
   * set the client side of this deploylet
   */
  public void setClient(Deploylet d) throws RemoteException;

  /**
   * set the server side of this deploylet
   */
  public void setServer(Deploylet d) throws RemoteException;

  /**
   * get the deploylet name (RMI address)
   */
  public String getName() throws RemoteException;

}