conf.configure( grid2 );
GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "node1" );
GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
GridNode remoteN1 = conn.connect();
KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();
String rule = "package org.grid.test\n"
+ "declare Message2\n"
+ "text : String\n"
+ "end\n"
+ "rule \"echo2\" \n"
+ "dialect \"mvel\"\n"
+ "when\n"
+ " $m : Message2()\n"
+ "then\n"
+ "$m.text = \"echo2:\" + $m.text;\n"
+ "end\n";
//System.out.println("Rule = "+rule);
kbuilder.add( new ByteArrayResource( rule.getBytes() ),
ResourceType.DRL );
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if ( errors != null && errors.size() > 0 ) {
for ( KnowledgeBuilderError error : errors ) {
System.out.println( "Error: " + error.getMessage() );
}
return;
}
KnowledgeBase kbase = remoteN1.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
remoteN1.set("ksession3", session);
remoteN1.dispose();
}