Exemplo n.º 1
0
  public ClassObjectTypeConf(
      final EntryPointId entryPoint, final Class<?> clazz, final InternalKnowledgeBase kBase) {
    this.cls =
        (Activation.class.isAssignableFrom(clazz))
            ? ClassObjectType.Match_ObjectType.getClassType()
            : clazz;
    this.kBase = kBase;
    this.entryPoint = entryPoint;

    this.typeDecl = kBase.getTypeDeclaration(clazz);
    isEvent = typeDecl != null && typeDecl.getRole() == Role.Type.EVENT;
    if (isEvent) {
      expirationOffset = typeDecl.getExpirationOffset();
    }

    isTrait = determineTraitStatus();

    this.objectType =
        kBase
            .getClassFieldAccessorCache()
            .getClassObjectType(new ClassObjectType(clazz, isEvent), false);

    this.concreteObjectTypeNode = kBase.getRete().getObjectTypeNodes(entryPoint).get(objectType);

    this.supportsPropertyListeners = checkPropertyListenerSupport(clazz);

    Traitable ttbl = cls.getAnnotation(Traitable.class);
    this.traitTmsEnabled = ttbl != null && ttbl.logical();
  }
Exemplo n.º 2
0
  public ClassObjectTypeConf(
      final EntryPointId entryPoint, final Class<?> clazz, final InternalKnowledgeBase kBase) {
    this.cls =
        (Activation.class.isAssignableFrom(clazz))
            ? ClassObjectType.Match_ObjectType.getClassType()
            : clazz;
    this.kBase = kBase;
    this.entryPoint = entryPoint;
    this.typeDecl = kBase.getTypeDeclaration(clazz);
    isEvent = typeDecl != null && typeDecl.getRole() == TypeDeclaration.Role.EVENT;
    isTrait = determineTraitStatus();

    ObjectType objectType =
        kBase.getClassFieldAccessorCache().getClassObjectType(new ClassObjectType(clazz, isEvent));

    this.concreteObjectTypeNode = kBase.getRete().getObjectTypeNodes(entryPoint).get(objectType);
    if (this.concreteObjectTypeNode == null) {
      BuildContext context = new BuildContext(kBase, kBase.getReteooBuilder().getIdGenerator());
      context.setCurrentEntryPoint(entryPoint);
      if (DroolsQuery.class == clazz) {
        context.setTupleMemoryEnabled(false);
        context.setObjectTypeNodeMemoryEnabled(false);
      } else if (context.getKnowledgeBase().getConfiguration().isSequential()) {
        // We are in sequential mode, so no nodes should have memory
        //                context.setTupleMemoryEnabled( false );
        //                context.setObjectTypeNodeMemoryEnabled( false );
        context.setTupleMemoryEnabled(true);
        context.setObjectTypeNodeMemoryEnabled(true);
      } else {
        context.setTupleMemoryEnabled(true);
        context.setObjectTypeNodeMemoryEnabled(true);
      }
      // there must exist an ObjectTypeNode for this concrete class
      this.concreteObjectTypeNode = PatternBuilder.attachObjectTypeNode(context, objectType);
    }

    this.supportsPropertyListeners = checkPropertyListenerSupport(clazz);

    Traitable ttbl = cls.getAnnotation(Traitable.class);
    this.traitTmsEnabled = ttbl != null && ttbl.logical();
  }