Package org.drools.agent

Examples of org.drools.agent.KnowledgeAgent


    }
   

    public Void execute(Context context) {

        KnowledgeAgent agent = (KnowledgeAgent) context.getContextManager().getContext("__TEMP__").get( kbaseKagentId+"_kAgent" );
        if( this.res != null ) {
            System.out.println("Applying Resource: "+this.res);
            agent.applyChangeSet( this.res );
        }
        if( this.cs != null ) {
            System.out.println( "Applying Change-set: "+this.cs);
            agent.applyChangeSet( this.cs );
        }
        return null;
    }
View Full Code Here


        KnowledgeSessionConfiguration kconf = null;
        if ( ksessionConfId != null ) {
            kconf = (KnowledgeSessionConfiguration) context.getContextManager().getContext( "__TEMP__" ).get( ksessionConfId );
        }
       
        KnowledgeAgent agent = (KnowledgeAgent) context.getContextManager().getContext( "__TEMP__" ).get( kbaseKagentId + "_kAgent" );
       
        if( agent != null ) {
            StatefulKnowledgeSession knowledgeSession = agent.getKnowledgeBase().newStatefulKnowledgeSession( kconf, environment );
            GridNode gnode = (GridNode) context.get( "grid_node" );
            knowledgeSession.setGlobal( "grid", gnode.getGrid() );
            return knowledgeSession;
        }
        return null;
View Full Code Here

    public KnowledgeAgent execute( Context context ) {
        KnowledgeBase kbase = ( (KnowledgeCommandContext) context ).getKnowledgeBase();
        KnowledgeAgentConfiguration kaConfig = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
        kaConfig.setProperty( NewInstanceOption.PROPERTY_NAME, "false" );
        kaConfig.setProperty( UseKnowledgeBaseClassloaderOption.PROPERTY_NAME, "true" );
        KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( this.kAgentId, kbase, kaConfig );
        SystemEventListener systemEventListener = new SystemEventListener() {

            public void info(String string) {
                System.out.println("INFO: "+string);
            }

            public void info(String string, Object o) {
                System.out.println("INFO: "+string +", "+o);
            }

            public void warning(String string) {
                System.out.println("WARN: "+string );
            }

            public void warning(String string, Object o) {
                System.out.println("WARN: "+string +", "+o);
            }

            public void exception(String string, Throwable thrwbl) {
                System.out.println("EXCEPTION: "+string +", "+thrwbl);
            }

            public void exception(Throwable thrwbl) {
                System.out.println("EXCEPTION: "+thrwbl);
            }

            public void debug(String string) {
                System.out.println("DEBUG: "+string );
            }

            public void debug(String string, Object o) {
                System.out.println("DEBUG: "+string +", "+o);
            }
        };
       
        kagent.setSystemEventListener( systemEventListener );

        GridNode gn = (GridNode) context.get("grid_node");
        gn.set( this.kAgentId + "_kAgent", kagent );

        return kagent;
View Full Code Here

    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

    KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
    aconf.setProperty("drools.agent.newInstance", "false");
    KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("RuleAgent", kbase, aconf);    
    kagent.applyChangeSet(ResourceFactory.newClassPathResource(RULES_CHANGESET, getClass()));
    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    ksession = kbase.newStatefulKnowledgeSession();
       
    // activate notifications
    ResourceFactory.getResourceChangeNotifierService().start();
View Full Code Here

        /* Incremental KnowledgeBase build */
        kaConf.setProperty("drools.agent.newInstance", "false");
        kaConf.setProperty("drools.agent.useKBaseClassLoaderForCompiling", "true");
        KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase(kBaseConfiguration);
        KnowledgeAgent kAgent = KnowledgeAgentFactory.newKnowledgeAgent("Gnostic", kBase, kaConf);

        ResourceFactory.getResourceChangeNotifierService().start();
        ResourceChangeScannerConfiguration sConf =
        ResourceFactory.getResourceChangeScannerService().
                                                         newResourceChangeScannerConfiguration();
View Full Code Here

TOP

Related Classes of org.drools.agent.KnowledgeAgent

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.