summaryrefslogtreecommitdiff
path: root/java/JACE/ServiceConfigurator/Service.java
blob: fac0b0fc54baa9f8b22898f3013e2642a5b861d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package JACE.ServiceConfigurator;

/**
 * Interface common to all services loaded with the
 * Service Configurator.
 * <P>
 * In order to create a completely new type of service, all that
 * is necessary is to implement this interface, and ServiceConfig
 * will be able to load it.  A concrete example is ServiceObject,
 * the base class for the network services.
 * <P>
 * Implementing classes must also:
 * <UL>
 * <LI> Provide a default constructor
 * <LI> Begin in their own thread (probably in init (String[]))
 * </UL>
 * <P>
 * Implementing classes should also:
 * <UL>
 * <LI> Shut down completely when close () has been called.  That
 * means ending thread activity.  
 * </UL>
 *
 *@see JACE.ServiceConfigurator.ServiceObject
 *@see JACE.ServiceConfigurator.ServiceConfig
 *@author Everett Anderson
 */
public interface Service
{
  /**
   * Temporarily disable this service.  This will only be called for a 
   * service which returns false from its suspended() method.
   * <P>
   *@return -1 on failure, 0 on success
   */
  int suspend ();

  /**
   * Re-enable this service.  This will only be called for a service
   * which returns true from its suspended() method.
   * <P>
   *@return -1 on failure, 0 on success
   */
  int resume ();

  /**
   * Initialize this service.  The arguments will be given as if they
   * were from the command line, separated into Strings using spaces
   * as the delimiters.
   * <P>
   *@param args set of command line arguments
   *@return -1 on failure, 0 on success
   */
  int init (String [] args);

  /**
   * Close this service and free any internal resources.
   * <P>
   *@return -1 on failure, 0 on success
   */
  int fini ();

  /**
   * Provide a status message for this service.
   * <P>
   *@return status message
   */
  String info ();

  /**
   * Return the name of this service.  The name is typically set
   * in ServiceConfig to a name supplied in a configuration file.
   * <P>
   *@return name of this service
   */
  String name ();

  /**
   * Set the name of this service.  This is typically caled in
   * ServiceConfig, setting the name to one supplied in a configuration
   * file.
   * <P>
   *@param name new name for this service
   */
  void name (String name);

  /**
   * Returns whether or not this service is suspended.  The result 
   * determines whether or not this service's resume() and suspend()
   * methods will be called by ServiceConfig.  (For instance, while
   * a service returns true, its suspend() method will not be called.)
   * <P>
   *@return true if suspended, else false
   */
  boolean suspended ();
}