} finally {
searchProcessor.close();
}
} else if (request instanceof CompositeRequest) {
CompositeRequest composite = (CompositeRequest)request;
CompositeRequestChannel channel = null;
RequestProcessor searchProcessor = null;
try {
for (Request nested : composite) {
if (nested instanceof AccessQueryRequest) {
AccessQueryRequest queryRequest = (AccessQueryRequest)request;
if (searchProcessor == null) searchProcessor = searchEngine().createProcessor(context, null, true);
searchProcessor.process(queryRequest);
} else if (nested instanceof FullTextSearchRequest) {
FullTextSearchRequest searchRequest = (FullTextSearchRequest)request;
if (searchProcessor == null) searchProcessor = searchEngine().createProcessor(context, null, true);
searchProcessor.process(searchRequest);
} else {
// Delegate to the channel ...
if (channel == null) {
// Create a connection factory that always returns the delegate connection ...
RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
/**
* {@inheritDoc}
*
* @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
*/
public RepositoryConnection createConnection( String sourceName )
throws RepositorySourceException {
assert delegate().getName().equals(sourceName);
return delegateConnection();
}
};
channel = new CompositeRequestChannel(delegate().getName());
channel.start(executorService, context, connectionFactory);
}
channel.add(request);
}
}
} finally {
try {
if (searchProcessor != null) {
searchProcessor.close();
}
} finally {
if (channel != null) {
try {
channel.close();
} finally {
try {
channel.await();
} catch (CancellationException err) {
composite.cancel();
} catch (ExecutionException err) {
composite.setError(err);
} catch (InterruptedException err) {