*/
@SuppressWarnings("unchecked")
@Override
public void doSend(final ReactorImpl _source,
final AsyncResponseProcessor<RESPONSE_TYPE> _responseProcessor) {
final ReactorMtImpl source = (ReactorMtImpl) _source;
if (PlantMtImpl.DEBUG
&& (source.getThreadReference().get() != Thread.currentThread())) {
throw new IllegalStateException("send from wrong thread");
}
use();
responseProcessor = _responseProcessor;
if (responseProcessor == null) {
responseProcessor = (AsyncResponseProcessor<RESPONSE_TYPE>) OneWayResponseProcessor.SINGLETON;
}
requestSource = source;
if (!source.isRunning()) {
throw new IllegalStateException(
"A valid source sourceReactor can not be idle");
}
oldMessage = source.getCurrentRequest();
if ((oldMessage != null) && oldMessage.getIsolationReactor() != null) {
isolationReactor = oldMessage.getIsolationReactor();
} else
isolationReactor = source.isCommonReactor() ? null : (IsolationReactor) source.asReactor();
if (!(targetReactor instanceof CommonReactor)) {
if (isolationReactor != null && isolationReactor != targetReactor && (_responseProcessor != null)) {
throw new UnsupportedOperationException(
"Isolated requests can not be nested, even indirectly:\n" + toString());
}
isolationReactor = (IsolationReactor) targetReactor;
}
sourceExceptionHandler = (ExceptionHandler<RESPONSE_TYPE>) source
.getExceptionHandler();
final boolean local = targetReactor == source.asReactor();
if (local || !source.buffer(this, targetReactorImpl)) {
targetReactorImpl.unbufferedAddMessage(this, local);
}
}