Package com.ms.service Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class Service

Constructor , Methods , Fields

public abstract class Service
{
  // Fields
  protected static boolean disableassassin;	
  public static final int START_PENDING = 2;
  public static final int STOP_PENDING = 3;
  public static final int RUNNING = 4;
  public static final int CONTINUE_PENDING = 5;
  public static final int PAUSE_PENDING = 6;
  public static final int PAUSE = 7;

  public static final int ACCEPT_STOP = 1;
  public static final int ACCEPT_PAUSE_CONTINUE = 2;
  public static final int ACCEPT_SHUTDOWN = 4;

  // Constructor
  protected Service(); 

  // Methods
  public boolean setAutoDumpErr(boolean autodump);
  public static boolean setAutoDumpOut(boolean autodump);
	
  protected boolean setServiceStatus(ServiceStatus newstatus)
	
  public ServiceStatus getServiceStatus();
	
  protected void CheckPoint();
  protected void CheckPoint(int waithint);
	
  protected void setRunning ();
  protected void setRunning(int controls);
  protected void setPausing(int waithint);
  protected void setPaused();
  protected void setContinuing(int waithint);
  protected void setStopping(int waithint);

  public int getCurrentState();
  public int getControlsAccepted();
  public boolean canStop();
  public boolean canPause();
  public boolean canShutdown();
  public int getCheckPoint();
  public int getWaitHint();
	
  protected boolean handleStop();
  protected boolean handleInterrogate();
  protected boolean handlePause();
  protected boolean handleContinue();
  protected boolean handleShutdown();
	
  protected void StopServiceEventHandler(int waithint);
	
}


Constructor


Service

protected Service();

Constructs a new service.

Note Because Service is an abstract class, you need to derive your own class from it rather than creating an instance of it.


Methods


CheckPoint

protected void CheckPoint();

Increments the current checkpoint value.

Return Value:

No return value.

Remarks:

During a pending operation, the service should call the CheckPoint method to indicate that it has made progress toward a non-pending state (that is, changing state from pending to start, stop, continue, or paused).


CheckPoint

protected void CheckPoint(int waithint);

Sets the checkpoint to the specified value.

ParameterDescription
checkpoint Value of the checkpoint.


canPause

public boolean canPause();

Indicates whether the service can be paused.

Return Value:

Returns true if the service can be paused (ACCEPT_PAUSE_CONTINUE); otherwise, returns false.


canShutdown

public boolean canShutdown();

Indicates whether the service should be notified when the system shuts down.

Return Value:

Returns true if the service can accept shutdown requests (ACCEPT_SHUTDOWN); otherwise, returns false.


canStop

public boolean canStop();

Indicates whether the service can be stopped.

Return Value:

Returns true if the service can be stopped (ACCEPT_STOP); otherwise, returns false.


getCheckPoint

public int getCheckPoint();

Determines the service's checkpoint.

Return Value:

Returns the current checkpoint value.


getControlsAccepted

public int getControlsAccepted();

Indicates the control codes that the service will accept and process.

Return Value:

Returns flags indicating which controls the service will accept.


getCurrentState

public int getCurrentState();

Determines the service's state.

Return Value:

Returns the system's current state.


getServiceStatus

public ServiceStatus getServiceStatus();

Determines the service's status.

Return Value:

Returns a copy of the service's ServiceStatus.


getWaitHint

public int getWaitHint();

Determines the wait hint.

Return Value:

Returns the service's wait hint.

Remarks:

The wait hint value specifies the amount of time (in milliseconds) the service expects to be in the current pending state. If this value is exceeded by the service, the service is terminated.


handleContinue

protected boolean handleContinue();

Handles the continue request.

Return Value:

Returns true if the service should shut down; otherwise, it returns false.


handleInterrogate

protected boolean handleInterrogate();

Handles the interrogate request.

Return Value:

Returns true if the service should shut down; otherwise, it returns false.


handlePause

protected boolean handlePause();

Handles the pause request.

Return Value:

Returns true if the service should shut down; otherwise, it returns false.


handleShutdown

protected boolean handleShutdown();

Handles the shutdown request.

Return Value:

Returns true if the service should shut down; otherwise, it returns false.


handleStop

protected boolean handleStop();

Handles the stop request.

Return Value:

Returns true if the service should shut down; otherwise, it returns false.


setAutoDumpErr

public boolean setAutoDumpErr(boolean autodump);

Changes when errors are flushed to the event log.

Return Value:

Returns the previous auto-flush state.

ParameterDescription
autodump Set to true to automatically flush to the Windows NT® event log whenever a new line is written. Set to false to enable the writing of multiline error messages. You must manage the flushing of the stream by calling System.err.flush().


setAutoDumpOut

public boolean setAutoDumpOut(boolean autodump);

Return Value:

Returns the previous auto-flush state.

ParameterDescription
autodump Set to true to automatically flush to the Windows NT® event log whenever a new line is written. Set to false to enable the writing of multiline log messages. You must manage the flushing of the stream by calling System.out.flush().


setContinuing

protected void setContinuing (int waithint);

Sets the service to CONTINUE_PENDING.

Return Value:

No return value.

ParameterDescription
waithint Value to set waithint (estimate of the time in milliseconds to reach the continued state).


setPaused

protected void setPaused();

Sets the service to the PAUSED state.

Return Value:

No return value.


setPausing

protected void setPausing(int waithint);

Sets the service to PAUSE_PENDING and the wait hint to waithint.

Return Value:

No return value.

ParameterDescription
waithint Value to set waithint (estimate of the time in milliseconds to reach the PAUSED state).


setRunning

protected void setRunning();

Sets the service to RUNNING.

Return Value:

No return value.


setRunning

protected void setRunning(int controls);

Sets the service to RUNNING, and sets the ControlsAccepted field in the ServiceStatus object to the specified controls value.

Return Value:

No return value.

ParameterDescription
controls The controls to set ControlsAccepted to.


setServiceStatus

protected boolean setServiceStatus(ServiceStatus newstatus);

Changes the value of the service's ServiceStatus.

Return Value:

Returns true if the status was updated; false if the newstatus parameter is not correct.

ParameterDescription
newstatus Value to set the service's status to. The state in newstatus is copied to the current status.


setStopping

protected void setStopping(int waithint);

Sets the service to STOP_PENDING and wait hint to waithint.

Return Value:

No return value.

ParameterDescription
waithint Value to set wait hint to (estimate of the time in milliseconds to reach the STOPPED state).


StopServiceEventHandler

protected void StopServiceEventHandler(int waithint);

Internally stops the service. Sets the service to STOP_PENDING and the wait hint to waithint. No more control commands will be dispatched.

Return Value:

No return value

ParameterDescription
waithint Value to set wait hint (estimate of the time in milliseconds for the service to shut down).


Fields

disableassassin
START_PENDING
Indicates that the service is starting.
STOP_PENDING
Indicates that the service is stopping.
RUNNING
Indicates that the service is running.
CONTINUE_PENDING
Indicates that the service is changing its state from paused to running.
PAUSE_PENDING
Indicates that the service is changing its state from running to paused.
PAUSED
Indicates that the service is paused.
ACCEPT_STOP
Indicates that the service accepts stop requests.
ACCEPT_PAUSE_CONTINUE
Indicates that the service can be paused and continued.
ACCEPT_SHUTDOWN
Indicates that the service accepts shutdown messages from the system.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.