Merge branch '273-service-exceptions' into 'master'

Services should throw exceptions for startup errors

Fixes #273

See merge request !134
This commit is contained in:
Torsten Grote
2016-04-06 15:51:03 +00:00
12 changed files with 87 additions and 85 deletions

View File

@@ -19,7 +19,6 @@ import org.briarproject.api.sync.Offer;
import org.briarproject.api.sync.Request;
import org.briarproject.api.transport.TransportKeys;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
@@ -37,7 +36,7 @@ public interface DatabaseComponent {
/**
* Waits for any open transactions to finish and closes the database.
*/
void close() throws DbException, IOException;
void close() throws DbException;
/**
* Starts a new transaction and returns an object representing it.

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);
}
}