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
log( "Acquired RuleRuntime: " + ruleRuntime );
// print the uris of the registered rulesets
List uriList = ruleRuntime.getRegistrations( );
log( "Registered RuleExecutionSets:" );
for ( Iterator it = uriList.iterator( ); it.hasNext( ); )
{
log( "Ruleset URI: " + it.next( ) );
}
log( "Runtime API - Stateless Execution" );
// create a StatelessRuleSession
StatelessRuleSession statelessRuleSession = ( StatelessRuleSession )
ruleRuntime.createRuleSession(
uri, new HashMap( ), RuleRuntime.STATELESS_SESSION_TYPE );
log( "Got Stateful Rule Session " + uri );
log( "Implementation: " + statelessRuleSession );
// add the user's User-Agent string to the session and execute it
List inputList = new LinkedList( );
inputList.add( userAgent );
log( "Adding browser User-Agent to session: " + userAgent );
List resultList = statelessRuleSession.executeRules( inputList );
log( "Called executeRules on Stateless Rule Session: "
+ statelessRuleSession );
log( "Result of calling executeRules: " + resultList );
// release the session
statelessRuleSession.release( );
log( "Released Stateless Rule Session." );
log( "Runtime API - Stateful Execution" );
// create a StatefulRuleSession
StatefulRuleSession statefulRuleSession = ( StatefulRuleSession )
ruleRuntime.createRuleSession(
uri, new HashMap( ), RuleRuntime.STATEFUL_SESSION_TYPE );
log( "Got Stateful Rule Session " + uri );
log( ": " + statefulRuleSession );
// add an Object to the statefulRuleSession
log( "Adding browser User-Agent to session: " + userAgent );