// prepare the fake operation we're providing to the source output format
final Operation sourceOperation = buildSourceOperation(operation, info);
// lookup the operation we are going to use
final Response sourceResponse = findSourceResponse(sourceOperation, info);
if (sourceResponse == null) {
throw new WFSException(
"Could not locate a response that can generate the desired source format '"
+ info.getSourceFormat() + "' for transformation '" + info.getName() + "'");
}
// prepare the stream connections, so that we can do the transformation on the fly
PipedInputStream pis = new PipedInputStream();
final PipedOutputStream pos = new PipedOutputStream(pis);
// submit the source output format execution, tracking exceptions
Future<Void> future = executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
try {
sourceResponse.write(featureCollection, pos, sourceOperation);
} finally {
// close the stream to make sure the transformation won't keep on waiting
pos.close();
}