Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
  /**
   * 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();
  }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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();
 }
  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);
    }
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 8
0
 /** Please do not use - internal org/my/Class.xxx -> org.my.Class */
 public static String convertResourceToClassName(final String pResourceName) {
   return ClassUtils.stripExtension(pResourceName).replace('/', '.');
 }
Ejemplo n.º 9
0
 public String getExtractToClassName() {
   return ClassUtils.canonicalName(this.fieldType);
 }
Ejemplo n.º 10
0
 @Override
 protected void cachePropertyNames() {
   propertyNames = ClassUtils.getSettableProperties(AnotherKlass.class);
 }