Package org.drools.runtime

Examples of org.drools.runtime.CommandExecutor


        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.getGridNode() != null && !StringUtils.isEmpty( lookup ) ) {
                    exec = de.getGridNode().get( lookup,
                                                     CommandExecutor.class );
                    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 );;
        exchange.getOut().setBody( results );
    }
View Full Code Here


                unwrapper = ExchangeUnwrapper.INSTANCE;
                break;
        }

        // Creates the actual worker
        CommandExecutor exec = de.getExecutor();
        if ( exec instanceof StatefulKnowledgeSession ) {
            WorkingMemoryEntryPoint wmep;
            String ep = de.getEntryPoint();
            if ( ep != null ) {
                wmep = ((StatefulKnowledgeSession) exec).getWorkingMemoryEntryPoint( ep );
View Full Code Here

            ClassLoader originalClassLoader = null;
            try {
                originalClassLoader = Thread.currentThread().getContextClassLoader();

                CommandExecutor exec = dep.executor;
                if ( exec == null ) {
                    String lookup = exchange.getIn().getHeader( DroolsComponent.DROOLS_LOOKUP,
                                                                String.class );
                    if ( StringUtils.isEmpty( lookup ) ) {
                        //Bad Hack - Need to remote it and fix it in Camel (if it's a camel problem)
View Full Code Here

            ClassLoader originalClassLoader = null;
            try {
                originalClassLoader = Thread.currentThread().getContextClassLoader();
               
                CommandExecutor exec = dep.executor;
                if ( exec == null ) {
                    String lookup = exchange.getIn().getHeader( DroolsComponent.DROOLS_LOOKUP, String.class );
                    if ( StringUtils.isEmpty( lookup )  ) {
                        lookup = dep.getLookup( exchange.getIn().getBody( String.class ) );
                    }
View Full Code Here

            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,
View Full Code Here

                throw new IllegalArgumentException("Unable to lookup XStream parser using name '" + name + "'");
            }
            ExecutionNodePipelineContextImpl executionNodeContext = (ExecutionNodePipelineContextImpl) context;
            GridNode node = executionNodeContext.getGridNode();
           
            CommandExecutor executor = node.get(name, CommandExecutor.class);
            if (executor == null) {
                throw new IllegalArgumentException("Unable to lookup CommandExecutor using name '" + name + "'");
            }
            executionNodeContext.setCommandExecutor(executor);
            ClassLoader cl = null;
View Full Code Here

        return kbase;
    }

    public static CommandExecutor createKnowledgeSession(KnowledgeBase kbase,GridNode node,String type,String name){
        CommandExecutor ksession;

        if (type.equals("stateful"))
            ksession = kbase.newStatefulKnowledgeSession();
        else
            ksession = kbase.newStatelessKnowledgeSession();
View Full Code Here

        return kbase;
    }

    public static CommandExecutor createKnowledgeSession(KnowledgeBase kbase,GridNode node,String type,String name){
        CommandExecutor ksession;

        if (type.equals("stateful")) {

            //Adding a configuration forces drools to use the current classloader (see issue SM-2316)
            ksession = kbase.newStatefulKnowledgeSession(new SessionConfiguration(), null);
View Full Code Here

                    throw new RuntimeException("Response was not correctly received");
                }
                String value = (String) ((ExecutionResults) object).getValue(commandId);
                String type = String.valueOf(value.charAt(0));
                String instanceId = value.substring(2);
                CommandExecutor executor = null;
                switch (Integer.parseInt(type)) {
                    case 0:
                        {
                            executor = new StatefulKnowledgeSessionRemoteClient(instanceId, client, messageSession);
                            break;
View Full Code Here

            if (xstream == null) {
                throw new IllegalArgumentException("Unable to lookup XStream parser using name '" + name + "'");
            }
            ExecutionNodePipelineContextImpl executionNodeContext = (ExecutionNodePipelineContextImpl) context;
            ExecutionNode node = executionNodeContext.getExecutionNode();
            CommandExecutor executor = node.get(DirectoryLookupFactoryService.class).lookup(name);
            if (executor == null) {
                throw new IllegalArgumentException("Unable to lookup CommandExecutor using name '" + name + "'");
            }
            executionNodeContext.setCommandExecutor(executor);
            ClassLoader cl = null;
View Full Code Here

TOP

Related Classes of org.drools.runtime.CommandExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.