/**
  * Adds configured variables to the variable service.
  *
  * @param variableService service to add to
  * @param variables configured variables
  */
 protected static void initVariables(
     VariableService variableService,
     Map<String, ConfigurationVariable> variables,
     EngineImportService engineImportService) {
   for (Map.Entry<String, ConfigurationVariable> entry : variables.entrySet()) {
     try {
       Pair<String, Boolean> arrayType =
           JavaClassHelper.isGetArrayType(entry.getValue().getType());
       variableService.createNewVariable(
           null,
           entry.getKey(),
           arrayType.getFirst(),
           entry.getValue().isConstant(),
           arrayType.getSecond(),
           false,
           entry.getValue().getInitializationValue(),
           engineImportService);
       variableService.allocateVariableState(entry.getKey(), 0, null);
     } catch (VariableExistsException e) {
       throw new ConfigurationException("Error configuring variables: " + e.getMessage(), e);
     } catch (VariableTypeException e) {
       throw new ConfigurationException("Error configuring variables: " + e.getMessage(), e);
     }
   }
 }
  public boolean removeVariable(String name, boolean force) throws ConfigurationException {
    if (!force) {
      Set<String> statements = statementVariableRef.getStatementNamesForVar(name);
      if ((statements != null) && (!statements.isEmpty())) {
        throw new ConfigurationException(
            "Variable '" + name + "' is in use by one or more statements");
      }
    }

    VariableReader reader = variableService.getReader(name);
    if (reader == null) {
      return false;
    }

    variableService.removeVariable(name);
    statementVariableRef.removeReferencesVariable(name);
    statementVariableRef.removeConfiguredVariable(name);
    return true;
  }
  /**
   * Ctor.
   *
   * @param variableName is the name of the variable
   */
  public ExprVariableNodeImpl(String variableName, VariableService variableService) {
    if (variableName == null) {
      throw new IllegalArgumentException("Variables name is null");
    }

    int indexOfDot = variableName.indexOf('.');
    if (indexOfDot != -1) {
      this.optSubPropName = variableName.substring(indexOfDot + 1, variableName.length());
      this.variableName = variableName.substring(0, indexOfDot);
    } else {
      this.variableName = variableName;
      this.optSubPropName = null;
    }

    // Allow initialization of the reader to determine whether constant or not.
    // Validation occurs as usual.
    if (variableService != null) {
      reader = variableService.getReader(variableName);
    }
  }
 public void addVariable(
     String variableName, String type, Object initializationValue, boolean constant)
     throws ConfigurationException {
   try {
     Pair<String, Boolean> arrayType = JavaClassHelper.isGetArrayType(type);
     variableService.createNewVariable(
         variableName,
         arrayType.getFirst(),
         initializationValue,
         constant,
         arrayType.getSecond(),
         null,
         engineImportService);
     statementVariableRef.addConfiguredVariable(variableName);
   } catch (VariableExistsException e) {
     throw new ConfigurationException("Error creating variable: " + e.getMessage(), e);
   } catch (VariableTypeException e) {
     throw new ConfigurationException("Error creating variable: " + e.getMessage(), e);
   }
 }
Exemplo n.º 5
0
  private void processHandle(
      EPStatementAgentInstanceHandle handle,
      List<NamedWindowConsumerView> value,
      EventBean[] newData,
      EventBean[] oldData,
      ExprEvaluatorContext exprEvaluatorContext) {
    handle.getStatementAgentInstanceLock().acquireWriteLock(statementLockFactory);
    try {
      if (handle.isHasVariables()) {
        variableService.setLocalVersion();
      }

      for (NamedWindowConsumerView consumerView : value) {
        consumerView.update(newData, oldData);
      }

      // internal join processing, if applicable
      handle.internalDispatch(exprEvaluatorContext);
    } catch (RuntimeException ex) {
      exceptionHandlingService.handleException(ex, handle);
    } finally {
      handle.getStatementAgentInstanceLock().releaseWriteLock(null);
    }
  }
Exemplo n.º 6
0
  private void processHandleMultiple(
      EPStatementAgentInstanceHandle handle,
      Map<NamedWindowConsumerView, NamedWindowDeltaData> deltaPerConsumer,
      ExprEvaluatorContext exprEvaluatorContext) {
    handle.getStatementAgentInstanceLock().acquireWriteLock(statementLockFactory);
    try {
      if (handle.isHasVariables()) {
        variableService.setLocalVersion();
      }
      for (Map.Entry<NamedWindowConsumerView, NamedWindowDeltaData> entryDelta :
          deltaPerConsumer.entrySet()) {
        EventBean[] newData = entryDelta.getValue().getNewData();
        EventBean[] oldData = entryDelta.getValue().getOldData();
        entryDelta.getKey().update(newData, oldData);
      }

      // internal join processing, if applicable
      handle.internalDispatch(exprEvaluatorContext);
    } catch (RuntimeException ex) {
      exceptionHandlingService.handleException(ex, handle);
    } finally {
      handle.getStatementAgentInstanceLock().releaseWriteLock(null);
    }
  }
 @Override
 public boolean evaluate(EventBean theEvent) {
   variableService.setLocalVersion();
   return evaluatePerStream(new EventBean[] {theEvent});
 }