A simple version of the interface is:
public interface IAPI {
void initialize(int processId) throws APIException;
APIResult process(IData data) throws APIException;
void finalize();
}
Finalize method creates a summary report on data that is processed (very important information for me) but is not crucial for a client.
The API is consumed like:
IAPI api = new API();
api.initialize(18);
loop {
IData data = …..getData!
APIResult res = api.process(data);
// do something with result.
}
// Finalize - We want to enforce the finalize call
api.finalize();
I need a solution to ensure that the finalize method is called when they are done processing their data. The solution has to be flexible enough to let user define how they want to handle exceptions, process as many data as they want. Thanks in advance for any alternatives.