Services should throw exceptions for startup errors.

This commit is contained in:
akwizgran
2016-04-05 15:44:50 +01:00
parent bbd14f1af4
commit b480777548
12 changed files with 87 additions and 85 deletions

View File

@@ -3,14 +3,14 @@ package org.briarproject.api.lifecycle;
public interface Service {
/**
* Starts the service and returns true if it started successfully.
* This method must not be called concurrently with {@link #stop()}.
* Starts the service.This method must not be called concurrently with
* {@link #stopService()}.
*/
public boolean start();
void startService() throws ServiceException;
/**
* Stops the service and returns true if it stopped successfully.
* This method must not be called concurrently with {@link #start()}.
* Stops the service. This method must not be called concurrently with
* {@link #startService()}.
*/
public boolean stop();
void stopService() throws ServiceException;
}

View File

@@ -0,0 +1,15 @@
package org.briarproject.api.lifecycle;
/**
* An exception that indicates an error starting or stopping a {@link Service}.
*/
public class ServiceException extends Exception {
public ServiceException() {
super();
}
public ServiceException(Throwable cause) {
super(cause);
}
}