コード例 #1
0
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    index = in.readInt();
    valueType = (ValueType) in.readObject();
    String clsName = in.readUTF();

    try {
      fieldType =
          in instanceof DroolsObjectInput
              ? ClassUtils.getClassFromName(
                  clsName, false, ((DroolsObjectInput) in).getClassLoader())
              : ClassUtils.getClassFromName(clsName);
    } catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }
  }
コード例 #2
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();
  }
コード例 #3
0
ファイル: XpathConstraint.java プロジェクト: UniqueOne/drools
 private static XpathChunk get(
     Class<?> clazz, String field, int index, boolean iterate, boolean lazy) {
   Method accessor = ClassUtils.getAccessor(clazz, field);
   if (accessor == null) {
     return null;
   }
   return new XpathChunk(
       accessor.getName(), index, iterate, lazy, iterate && accessor.getReturnType().isArray());
 }
コード例 #4
0
 public String getExtractToClassName() {
   Class<?> clazz = null;
   // @todo : this is a bit nasty, but does the trick
   if (this.objectType instanceof ClassObjectType) {
     clazz = ((ClassObjectType) this.objectType).getClassType();
   } else {
     clazz = Fact.class;
   }
   return ClassUtils.canonicalName(clazz);
 }
コード例 #5
0
 public static List<String> getSettableProperties(InternalRuleBase ruleBase, Class<?> nodeClass) {
   if (nodeClass == null) {
     return null;
   }
   TypeDeclaration typeDeclaration = ruleBase.getTypeDeclaration(nodeClass);
   if (typeDeclaration == null) {
     return ClassUtils.getSettableProperties(nodeClass);
   }
   typeDeclaration.setTypeClass(nodeClass);
   return typeDeclaration.getSettableProperties();
 }
コード例 #6
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);
    }
  }
コード例 #7
0
  public KnowledgePackageImpl deepCloneIfAlreadyInUse(ClassLoader classLoader) {
    if (inUse.compareAndSet(false, true)) {
      return this;
    }

    if (classLoader instanceof ProjectClassLoader) {
      ClassLoader originalClassLoader =
          ((JavaDialectRuntimeData) dialectRuntimeRegistry.getDialectData("java"))
              .getRootClassLoader();
      if (originalClassLoader instanceof ProjectClassLoader) {
        ((ProjectClassLoader) classLoader).initFrom((ProjectClassLoader) originalClassLoader);
      }
    }

    return ClassUtils.deepClone(this, classLoader);
  }
コード例 #8
0
ファイル: ClassUtils.java プロジェクト: benbennett/drools
 /** Please do not use - internal org/my/Class.xxx -> org.my.Class */
 public static String convertResourceToClassName(final String pResourceName) {
   return ClassUtils.stripExtension(pResourceName).replace('/', '.');
 }
コード例 #9
0
 public String getExtractToClassName() {
   return ClassUtils.canonicalName(this.fieldType);
 }
コード例 #10
0
ファイル: AnotherKlass_.java プロジェクト: coldsarge/drools
 @Override
 protected void cachePropertyNames() {
   propertyNames = ClassUtils.getSettableProperties(AnotherKlass.class);
 }