/*
 * Copyright (c) 2009 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 *
 */

package com.jscape.util.service;

/**
 * @author Alex Usun
 */
public interface Service<T> {

    boolean isStarted();

    void start(T parameter)
            throws ServiceException;

    void stop();

    void dispose();

    class ServiceException
            extends Exception {

        private static final long serialVersionUID = 8191870657063840710L;

        public static ServiceException wrap(Throwable e) {
            return e instanceof ServiceException ? (ServiceException) e : new ServiceException(e);
        }

        public ServiceException() {
        }

        public ServiceException(String message) {
            super(message);
        }

        public ServiceException(String message, Throwable cause) {
            super(message, cause);
        }

        public ServiceException(Throwable cause) {
            super(cause.getMessage() != null ? cause.getMessage() : cause.toString(), cause);
        }
    }

}
