// prepare and run the index builder
final ImageMosaicEventHandlers eventHandler=new ImageMosaicEventHandlers();
final ImageMosaicConfigHandler catalogHandler = new ImageMosaicConfigHandler(configuration, eventHandler);
final ImageMosaicDirectoryWalker builder = new ImageMosaicDirectoryWalker(catalogHandler, eventHandler);
// this is going to help us with catching exceptions and logging them
final Queue<Throwable> exceptions = new LinkedList<Throwable>();
try {
final ImageMosaicEventHandlers.ProcessingEventListener listener = new ImageMosaicEventHandlers.ProcessingEventListener() {
@Override
public void exceptionOccurred(ExceptionEvent event) {
final Throwable t = event.getException();
exceptions.add(t);
if (LOGGER.isLoggable(Level.SEVERE))
LOGGER.log(Level.SEVERE, t.getLocalizedMessage(), t);
}
@Override
public void getNotification(ProcessingEvent event) {
if (LOGGER.isLoggable(Level.FINE))
LOGGER.fine(event.getMessage());
}
};
eventHandler.addProcessingEventListener(listener);
builder.run();
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Unable to build mosaic", e);
} finally {
catalogHandler.dispose();
}