// Get the rule service provider from the provider manager.
RuleServiceProvider serviceProvider =
RuleServiceProviderManager.getRuleServiceProvider(
ruleServiceProvider );
// get the RuleAdministrator
RuleAdministrator ruleAdministrator =
serviceProvider.getRuleAdministrator( );
// get the RuleAdministrator
log( "Got RuleAdministrator implementation: " + ruleAdministrator );
// get an input stream to the file to load
InputStream inStream = Main.class.getResourceAsStream( fileName );
log( "Acquired InputStream to input file: " + inStream );
// load a RuleExecutionSet
RuleExecutionSet ruleExecutionSet =
ruleAdministrator.getLocalRuleExecutionSetProvider( null )
.createRuleExecutionSet( inStream, null );
log( "Loaded RuleExecutionSet: " + ruleExecutionSet );
// print the metadata about the ruleset
log( "Name: " + ruleExecutionSet.getName( ) );
log( "Description: " + ruleExecutionSet.getDescription( ) );
log( "Rules:" );
// print the names of the rules in the ruleset
for ( Iterator it = ruleExecutionSet.getRules( ).iterator( );
it.hasNext( ); )
{
Rule rule = ( Rule ) it.next( );
log( rule.getName( ) );
}
// register the ruleset under a "random" URI
String uri = "uri_" + System.currentTimeMillis( );
ruleAdministrator
.registerRuleExecutionSet( uri, ruleExecutionSet, null );
log( "Bound RuleExecutionSet to URI: " + uri );
log( "Runtime API - Query Deployed RuleSets" );
RuleRuntime ruleRuntime = serviceProvider.getRuleRuntime( );
// get the RuleRuntime from JNDI