Interface Repository

Interface CtsServices::ExtendedService

An interface that can be implemented by a service component instead of implementing the simpler GenericService. This interface adds some methods that allow the user to query the state of the service.

Example Java implementation of a service component implementing this interface:

    public class MyService
    {
        private static boolean _starting = false;
        private static boolean _running = false;
        private static boolean _stopping = false;
        private static boolean _stop = false;
        private static boolean _runHasBeenCalled = false;
        public void start()
        {
            _starting = true;
            // Perform initialization
            _starting = false;
        }
        public void stop()
        {
            _stopping = true;
            _running = false;
            _stop = true;
            // Perform cleanup
            _stopping = false;
        }
        public void run()
        {
            _runHasBeenCalled = true; 
            _running = true;
            while (! _stop)
            {
                try
                {
                    // do whatever this service does on each iteration
                    Thread.sleep(10000);
                }
                catch (InterruptedException ie)
                {
                    _stop = true;
                }
            }
            _running = false;
        }
        public int getServiceState()
        {
            if (_starting)
            {
                return SERVICE_STATE_STARTING.value;
            }
            else if (! _runHasBeenCalled)
            {
                return SERVICE_STATE_STARTED.value;
            }
            else if (_stopping)
            {
                return SERVICE_STATE_STOPPING.value;
            }
            else if (_stop)
            {
                return SERVICE_STATE_STOPPED.value;
            }
            else if (_running)
            {
                return SERVICE_STATE_RUNNING.value;
            }
            else
            {
                return SERVICE_STATE_FINISHED.value;
            }
        }
    }
 

Inherits From

Operation Index

Operations


Generated by Sybase EAServer 5.0