Package javax.rules

Examples of javax.rules.StatefulRuleSession


        RuleExecutionSet ruleSet =
            ruleSetProvider.createRuleExecutionSet( ruleReader, null );
        ruleAdministrator.registerRuleExecutionSet(
            RULES_RESOURCE, ruleSet, null );

        StatefulRuleSession statefulRuleSession = ( StatefulRuleSession )
                    ruleRuntime.createRuleSession( RULES_RESOURCE,
                                                   null,
                                                   RuleRuntime.STATEFUL_SESSION_TYPE );
        assertNotNull(
            "cannot obtain StatefulRuleSession", statefulRuleSession );
View Full Code Here


        // 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 );
        statefulRuleSession.addObjects( inputList );
        log( "Called addObject on Stateful Rule Session: "
            + statefulRuleSession );
        statefulRuleSession.executeRules( );
        log( "Called executeRules" );
        // extract the Objects from the statefulRuleSession
        resultList = statefulRuleSession.getObjects( );
        log( "Result of calling getObjects: " + resultList );
        // release the statefulRuleSession so it is reset and repooled
        statefulRuleSession.release( );
        log( "Released Stateful Rule Session." );
    }
View Full Code Here

    DefaultRuleSource source = new DefaultRuleSource();
    setProperties(source);
    source.afterPropertiesSet();

    // get the stateless session
    StatefulRuleSession session = (StatefulRuleSession) source.createSession(BIND_URI, null, RuleRuntime.STATEFUL_SESSION_TYPE);

    // execute it
    List facts = new ArrayList();
    facts.add("Gecko");
    session.addObjects(facts);
    session.executeRules();
    facts = session.getObjects();

    assertTrue("Facts does not contain Gecko", facts.contains("Gecko"));
    assertTrue("Facts does not contain a:Gecko", facts.contains("a:Gecko"));

    session.release();
  }
View Full Code Here

     */
  private void release() throws TransactionException {
    try {
      if (TransactionSynchronizationManager.hasResource(ruleSource)) {
        logger.debug("Releasing session");
        StatefulRuleSession session = (StatefulRuleSession) TransactionSynchronizationManager.getResource(ruleSource);
        session.release();
        logger.debug("Session released");
      }
    }
    catch (InvalidRuleSessionException ex) {
      throw new Jsr94TransactionException(ex);
View Full Code Here

   * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#doGetTransaction()
   */
  protected Object doGetTransaction() throws TransactionException {
    Jsr94TransactionObject txObject = new Jsr94TransactionObject();
    if (TransactionSynchronizationManager.hasResource(ruleSource)) {
      StatefulRuleSession session = (StatefulRuleSession) TransactionSynchronizationManager.getResource(ruleSource);
      if (logger.isDebugEnabled()) {
        logger.debug("Found thread-bound session [" + session + "] for Jsr94 Transaction");
      }
      // set the existing session holder
      txObject.setSession(session);
View Full Code Here

    // get the session
    boolean synchronize = TransactionSynchronizationManager.isSynchronizationActive();
    if (!synchronize) {
      logger.debug("Not running in transaction; the session will be closed when the callback returns.");
    }
    StatefulRuleSession session = (StatefulRuleSession) TransactionSynchronizationManager.getResource(getRuleSource());
    if (session == null) {
      logger.debug("Opening StatefulRuleSession");
      session = (StatefulRuleSession) createRuleSession(uri, properties, RuleRuntime.STATEFUL_SESSION_TYPE);
      if (synchronize) TransactionSynchronizationManager.bindResource(getRuleSource(), session);
    }
View Full Code Here

                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final StatefulRuleSession statefulRuleSession = (StatefulRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
                                                                                                             null,
                                                                                                             RuleRuntime.STATEFUL_SESSION_TYPE );
        assertNotNull( "cannot obtain StatefulRuleSession",
                       statefulRuleSession );
View Full Code Here

        final List list = new ArrayList();
        properties.put( "list",
                        list );
       
        RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
        StatefulRuleSession session = (StatefulRuleSession) ruleRuntime.createRuleSession( "IntegrationExampleTest.xls",
                                                                                           properties,
                                                                                           RuleRuntime.STATEFUL_SESSION_TYPE );

        //ASSERT AND FIRE
        session.addObject( new Cheese( "stilton",
                                       42 ) );
        session.addObject( new Person( "michael",
                                       "stilton",
                                       42 ) );

        session.executeRules();
        assertEquals( 1,
                      list.size() );
    }
View Full Code Here

        final List list = new ArrayList();
        properties.put( "list",
                        list );
       
        RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
        StatefulRuleSession session = (StatefulRuleSession) ruleRuntime.createRuleSession( "IntegrationExampleTest.xls",
                                                                                           properties,
                                                                                           RuleRuntime.STATEFUL_SESSION_TYPE );

        //ASSERT AND FIRE
        session.addObject( new Cheese( "stilton",
                                       42 ) );
        session.addObject( new Person( "michael",
                                       "stilton",
                                       42 ) );

        session.executeRules();
        assertEquals( 1,
                      list.size() );
    }
View Full Code Here

                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final StatefulRuleSession statefulRuleSession = (StatefulRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
                                                                                                             null,
                                                                                                             RuleRuntime.STATEFUL_SESSION_TYPE );
        assertNotNull( "cannot obtain StatefulRuleSession",
                       statefulRuleSession );
View Full Code Here

TOP

Related Classes of javax.rules.StatefulRuleSession

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.