コード例 #1
0
ファイル: ReteAgenda.java プロジェクト: chearius/drools
  /**
   * Construct.
   *
   * @param kBase The <code>InternalKnowledgeBase</code> of this agenda.
   * @param initMain Flag to initialize the MAIN agenda group
   */
  public ReteAgenda(InternalKnowledgeBase kBase, boolean initMain) {

    this.agendaGroups = new HashMap<String, InternalAgendaGroup>();
    this.activationGroups = new HashMap<String, InternalActivationGroup>();
    this.focusStack = new LinkedList<AgendaGroup>();
    this.scheduledActivations = new org.drools.core.util.LinkedList<ScheduledAgendaItem>();
    this.agendaGroupFactory = kBase.getConfiguration().getAgendaGroupFactory();

    if (initMain) {
      // MAIN should always be the first AgendaGroup and can never be
      // removed
      this.main = agendaGroupFactory.createAgendaGroup(AgendaGroup.MAIN, kBase);

      this.agendaGroups.put(AgendaGroup.MAIN, this.main);

      this.focusStack.add(this.main);
    }
    eager = new LinkedList<RuleAgendaItem>();

    Object object =
        ClassUtils.instantiateObject(
            kBase.getConfiguration().getConsequenceExceptionHandler(),
            kBase.getConfiguration().getClassLoader());
    if (object instanceof ConsequenceExceptionHandler) {
      this.legacyConsequenceExceptionHandler = (ConsequenceExceptionHandler) object;
    } else {
      this.consequenceExceptionHandler =
          (org.kie.api.runtime.rule.ConsequenceExceptionHandler) object;
    }

    this.declarativeAgenda = kBase.getConfiguration().isDeclarativeAgenda();
  }
コード例 #2
0
  public static RuleBaseUpdateListener createListener(String className, StatefulSession session) {
    try {
      RuleBaseUpdateListener listener =
          (RuleBaseUpdateListener) ClassUtils.instantiateObject(className);
      listener.setSession(session);

      return listener;
    } catch (Throwable e) {
      throw new RuntimeException(
          "Unable to instantiate RuleBaseUpdateListener '" + className + "'", e);
    }
  }