if ( !(cmd instanceof BatchExecutionCommandImpl) ) {
cmd = new BatchExecutionCommandImpl( Arrays.asList( new GenericCommand< ? >[]{(GenericCommand) cmd} ) );
}
CommandExecutor exec;
ExecutionNodePipelineContextImpl droolsContext = exchange.getProperty( "drools-context",
ExecutionNodePipelineContextImpl.class );
if ( droolsContext != null ) {
exec = droolsContext.getCommandExecutor();
} else {
exec = de.getExecutor();
if ( exec == null ) {
String lookup = exchange.getIn().getHeader( DroolsComponent.DROOLS_LOOKUP,
String.class );
if ( StringUtils.isEmpty( lookup ) && (cmd instanceof BatchExecutionCommandImpl) ) {
lookup = ((BatchExecutionCommandImpl) cmd).getLookup();
}
if ( de.getExecutionNode() != null && !StringUtils.isEmpty( lookup ) ) {
exec = de.getExecutionNode().get( DirectoryLookupFactoryService.class ).lookup( lookup );
if ( exec == null ) {
throw new RuntimeException( "ExecutionNode is unable to find ksession=" + lookup +" for uri" + de.getEndpointUri() );
}
} else {
throw new RuntimeException( "No ExecutionNode, unable to find ksession=" + lookup +" for uri" + de.getEndpointUri());
}
}
}
if ( exec == null ) {
throw new RuntimeException( "No defined ksession for uri" + de.getEndpointUri() );
}
ExecutionResults results = exec.execute( (BatchExecutionCommandImpl) cmd );;
// if ( de.dataFormat != null ) {
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// de.dataFormat.marshal( exchange,
// results,