private void addKieBaseModels(
      ConfigurableListableBeanFactory beanFactory, KieModuleModelImpl kieModuleModel) {
    for (String beanDef : beanFactory.getBeanDefinitionNames()) {
      BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanDef);
      if (beanDefinition.getBeanClassName().equalsIgnoreCase(KBaseFactoryBean.class.getName())) {
        KieBaseModelImpl kBase = new KieBaseModelImpl();
        kBase.setKModule(kieModuleModel);

        kBase.setName(getPropertyValue(beanDefinition, "kBaseName"));
        kBase.setDefault("true".equals(getPropertyValue(beanDefinition, "def")));

        String packages = getPropertyValue(beanDefinition, "packages");
        if (!packages.isEmpty()) {
          for (String pkg : packages.split(",")) {
            kBase.addPackage(pkg.trim());
          }
        }

        String includes = getPropertyValue(beanDefinition, "includes");
        if (!includes.isEmpty()) {
          for (String include : includes.split(",")) {
            kBase.addInclude(include.trim());
          }
        }

        String eventMode = getPropertyValue(beanDefinition, "eventProcessingMode");
        if (!eventMode.isEmpty()) {
          kBase.setEventProcessingMode(
              EventProcessingOption.determineEventProcessingMode(eventMode));
        }

        String equalsBehavior = getPropertyValue(beanDefinition, "equalsBehavior");
        if (!equalsBehavior.isEmpty()) {
          kBase.setEqualsBehavior(EqualityBehaviorOption.determineEqualityBehavior(equalsBehavior));
        }

        String declarativeAgenda = getPropertyValue(beanDefinition, "declarativeAgenda");
        if (!declarativeAgenda.isEmpty()) {
          kBase.setDeclarativeAgenda(
              DeclarativeAgendaOption.determineDeclarativeAgenda(declarativeAgenda));
        }

        String scope = getPropertyValue(beanDefinition, "scope");
        if (!scope.isEmpty()) {
          kBase.setScope(scope.trim());
        }

        kieModuleModel.getRawKieBaseModels().put(kBase.getName(), kBase);
        beanDefinition
            .getPropertyValues()
            .addPropertyValue(new PropertyValue("releaseId", releaseId));
        addKieSessionModels(beanFactory, kBase);
      }
    }
  }
Beispiel #2
0
  private void init(Properties properties) {
    this.immutable = false;

    this.chainedProperties = new ChainedProperties("rulebase.conf", this.classLoader, true);

    if (properties != null) {
      this.chainedProperties.addProperties(properties);
    }

    setSequentialAgenda(
        SequentialAgenda.determineSequentialAgenda(
            this.chainedProperties.getProperty(
                SequentialAgendaOption.PROPERTY_NAME, "sequential")));

    setSequential(
        Boolean.valueOf(this.chainedProperties.getProperty(SequentialOption.PROPERTY_NAME, "false"))
            .booleanValue());

    setRemoveIdentities(
        Boolean.valueOf(this.chainedProperties.getProperty("drools.removeIdentities", "false"))
            .booleanValue());

    setShareAlphaNodes(
        Boolean.valueOf(
                this.chainedProperties.getProperty(ShareAlphaNodesOption.PROPERTY_NAME, "true"))
            .booleanValue());

    setShareBetaNodes(
        Boolean.valueOf(
                this.chainedProperties.getProperty(ShareBetaNodesOption.PROPERTY_NAME, "true"))
            .booleanValue());

    setPermGenThreshold(
        Integer.parseInt(
            this.chainedProperties.getProperty(
                PermGenThresholdOption.PROPERTY_NAME, "" + PermGenThresholdOption.DEFAULT_VALUE)));

    setAlphaNodeHashingThreshold(
        Integer.parseInt(
            this.chainedProperties.getProperty(AlphaThresholdOption.PROPERTY_NAME, "3")));

    setCompositeKeyDepth(
        Integer.parseInt(
            this.chainedProperties.getProperty(CompositeKeyDepthOption.PROPERTY_NAME, "3")));

    setIndexLeftBetaMemory(
        Boolean.valueOf(
                this.chainedProperties.getProperty(IndexLeftBetaMemoryOption.PROPERTY_NAME, "true"))
            .booleanValue());
    setIndexRightBetaMemory(
        Boolean.valueOf(
                this.chainedProperties.getProperty(
                    IndexRightBetaMemoryOption.PROPERTY_NAME, "true"))
            .booleanValue());

    setIndexPrecedenceOption(
        IndexPrecedenceOption.determineIndexPrecedence(
            this.chainedProperties.getProperty(IndexPrecedenceOption.PROPERTY_NAME, "equality")));

    setAssertBehaviour(
        AssertBehaviour.determineAssertBehaviour(
            this.chainedProperties.getProperty(EqualityBehaviorOption.PROPERTY_NAME, "identity")));

    setExecutorService(
        this.chainedProperties.getProperty(
            "drools.executorService", "org.drools.core.concurrent.DefaultExecutorService"));

    setConsequenceExceptionHandler(
        this.chainedProperties.getProperty(
            ConsequenceExceptionHandlerOption.PROPERTY_NAME,
            "org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler"));

    setRuleBaseUpdateHandler(
        this.chainedProperties.getProperty("drools.ruleBaseUpdateHandler", ""));

    setConflictResolver(
        determineConflictResolver(
            this.chainedProperties.getProperty(
                "drools.conflictResolver", "org.drools.core.conflict.DepthConflictResolver")));

    setAdvancedProcessRuleIntegration(
        Boolean.valueOf(
                this.chainedProperties.getProperty(
                    "drools.advancedProcessRuleIntegration", "false"))
            .booleanValue());

    setMultithreadEvaluation(
        Boolean.valueOf(
                this.chainedProperties.getProperty(
                    MultithreadEvaluationOption.PROPERTY_NAME, "false"))
            .booleanValue());

    setMaxThreads(
        Integer.parseInt(this.chainedProperties.getProperty(MaxThreadsOption.PROPERTY_NAME, "3")));

    setEventProcessingMode(
        EventProcessingOption.determineEventProcessingMode(
            this.chainedProperties.getProperty(EventProcessingOption.PROPERTY_NAME, "cloud")));

    setMBeansEnabled(
        MBeansOption.isEnabled(
            this.chainedProperties.getProperty(MBeansOption.PROPERTY_NAME, "disabled")));

    setClassLoaderCacheEnabled(
        Boolean.valueOf(
            this.chainedProperties.getProperty(ClassLoaderCacheOption.PROPERTY_NAME, "true")));

    setPhreakEnabled(
        Boolean.valueOf(this.chainedProperties.getProperty(PhreakOption.PROPERTY_NAME, "false")));
    setDeclarativeAgendaEnabled(
        Boolean.valueOf(
            this.chainedProperties.getProperty(DeclarativeAgendaOption.PROPERTY_NAME, "false")));

    this.componentFactory = new ReteooComponentFactory();
  }
Beispiel #3
0
  public void setProperty(String name, String value) {
    name = name.trim();
    if (StringUtils.isEmpty(name)) {
      return;
    }

    if (name.equals(SequentialAgendaOption.PROPERTY_NAME)) {
      setSequentialAgenda(
          SequentialAgenda.determineSequentialAgenda(
              StringUtils.isEmpty(value) ? "sequential" : value));
    } else if (name.equals(SequentialOption.PROPERTY_NAME)) {
      setSequential(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(RemoveIdentitiesOption.PROPERTY_NAME)) {
      setRemoveIdentities(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(ShareAlphaNodesOption.PROPERTY_NAME)) {
      setShareAlphaNodes(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(ShareBetaNodesOption.PROPERTY_NAME)) {
      setShareBetaNodes(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(PermGenThresholdOption.PROPERTY_NAME)) {
      setPermGenThreshold(
          StringUtils.isEmpty(value)
              ? PermGenThresholdOption.DEFAULT_VALUE
              : Integer.parseInt(value));
    } else if (name.equals(AlphaThresholdOption.PROPERTY_NAME)) {
      setAlphaNodeHashingThreshold(StringUtils.isEmpty(value) ? 3 : Integer.parseInt(value));
    } else if (name.equals(CompositeKeyDepthOption.PROPERTY_NAME)) {
      setCompositeKeyDepth(StringUtils.isEmpty(value) ? 3 : Integer.parseInt(value));
    } else if (name.equals(IndexLeftBetaMemoryOption.PROPERTY_NAME)) {
      setIndexLeftBetaMemory(StringUtils.isEmpty(value) ? true : Boolean.valueOf(value));
    } else if (name.equals(IndexRightBetaMemoryOption.PROPERTY_NAME)) {
      setIndexRightBetaMemory(StringUtils.isEmpty(value) ? true : Boolean.valueOf(value));
    } else if (name.equals(IndexPrecedenceOption.PROPERTY_NAME)) {
      setIndexPrecedenceOption(
          StringUtils.isEmpty(value)
              ? IndexPrecedenceOption.EQUALITY_PRIORITY
              : IndexPrecedenceOption.determineIndexPrecedence(value));
    } else if (name.equals(EqualityBehaviorOption.PROPERTY_NAME)) {
      setAssertBehaviour(
          AssertBehaviour.determineAssertBehaviour(
              StringUtils.isEmpty(value) ? "identity" : value));
    } else if (name.equals(ConsequenceExceptionHandlerOption.PROPERTY_NAME)) {
      setConsequenceExceptionHandler(
          StringUtils.isEmpty(value) ? DefaultConsequenceExceptionHandler.class.getName() : value);
    } else if (name.equals("drools.ruleBaseUpdateHandler")) {
      setRuleBaseUpdateHandler(StringUtils.isEmpty(value) ? "" : value);
    } else if (name.equals("drools.conflictResolver")) {
      setConflictResolver(
          determineConflictResolver(
              StringUtils.isEmpty(value) ? DepthConflictResolver.class.getName() : value));
    } else if (name.equals("drools.advancedProcessRuleIntegration")) {
      setAdvancedProcessRuleIntegration(
          StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(MultithreadEvaluationOption.PROPERTY_NAME)) {
      setMultithreadEvaluation(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    } else if (name.equals(MaxThreadsOption.PROPERTY_NAME)) {
      setMaxThreads(StringUtils.isEmpty(value) ? 3 : Integer.parseInt(value));
    } else if (name.equals(EventProcessingOption.PROPERTY_NAME)) {
      setEventProcessingMode(
          EventProcessingOption.determineEventProcessingMode(
              StringUtils.isEmpty(value) ? "cloud" : value));
    } else if (name.equals(MBeansOption.PROPERTY_NAME)) {
      setMBeansEnabled(MBeansOption.isEnabled(value));
    } else if (name.equals(ClassLoaderCacheOption.PROPERTY_NAME)) {
      setClassLoaderCacheEnabled(StringUtils.isEmpty(value) ? true : Boolean.valueOf(value));
    } else if (name.equals(PhreakOption.PROPERTY_NAME)) {
      setPhreakEnabled(StringUtils.isEmpty(value) ? false : Boolean.valueOf(value));
    }
  }