@Create
  public void create() {
    if (entityManager == null) {
      entityManager =
          Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class);
    }

    tokenUsernameProperty =
        new AnnotatedBeanProperty<TokenUsername>(tokenClass, TokenUsername.class);
    tokenValueProperty = new AnnotatedBeanProperty<TokenValue>(tokenClass, TokenValue.class);

    if (!tokenUsernameProperty.isSet()) {
      throw new IllegalStateException(
          "Invalid tokenClass "
              + tokenClass.getName()
              + " - required annotation @TokenUsername not found on any Field or Method.");
    }

    if (!tokenValueProperty.isSet()) {
      throw new IllegalStateException(
          "Invalid tokenClass "
              + tokenClass.getName()
              + " - required annotation @TokenValue not found on any Field or Method.");
    }
  }
Exemple #2
0
  protected WorkingMemory getWorkingMemory(
      String workingMemoryName,
      List<String> expressions,
      List<String> retractions,
      ExecutionContext executionContext)
      throws ELException {
    WorkingMemory workingMemory = (WorkingMemory) Component.getInstance(workingMemoryName, true);

    if (expressions != null && expressions.size() > 0) {
      for (String objectName : expressions) {
        Object object = Expressions.instance().createValueExpression(objectName).getValue();
        // Object object = new SeamVariableResolver().resolveVariable(objectName);
        // assert the object into the rules engine
        if (object instanceof Iterable) {
          for (Object element : (Iterable) object) {
            assertObject(workingMemory, element);
          }
        } else {
          assertObject(workingMemory, object);
        }
      }
    }

    if (retractions != null && retractions.size() > 0) {
      for (String objectName : retractions) {
        Object object = Expressions.instance().createValueExpression(objectName).getValue();
        // Object object = new SeamVariableResolver().resolveVariable(objectName);
        // retract the object from the rules engine
        if (object instanceof Iterable) {
          for (Object element : (Iterable) object) {
            retractObject(workingMemory, element);
          }
        } else {
          retractObject(workingMemory, object);
        }
      }
    }

    // workingMemory.setGlobal( "contextInstance", executionContext.getContextInstance() );
    workingMemory.insert(Actor.instance());

    return workingMemory;
  }
 @Override
 protected String getViewId(Exception e) {
   return Expressions.instance()
       .createValueExpression(e.getClass().getAnnotation(Redirect.class).viewId(), String.class)
       .getValue();
 }