public Set<String> getVariableNameUsedBy(String variableName) {
   Set<String> statements = statementVariableRef.getStatementNamesForVar(variableName);
   if ((statements == null) || (statements.isEmpty())) {
     return Collections.emptySet();
   }
   return Collections.unmodifiableSet(statements);
 }
 public Set<String> getEventTypeNameUsedBy(String name) {
   Set<String> statements = statementEventTypeRef.getStatementNamesForType(name);
   if ((statements == null) || (statements.isEmpty())) {
     return Collections.emptySet();
   }
   return Collections.unmodifiableSet(statements);
 }
 public void addPlugInView(String namespace, String name, String viewFactoryClass) {
   ConfigurationPlugInView configurationPlugInView = new ConfigurationPlugInView();
   configurationPlugInView.setNamespace(namespace);
   configurationPlugInView.setName(name);
   configurationPlugInView.setFactoryClassName(viewFactoryClass);
   plugInViews.addViews(
       Collections.singletonList(configurationPlugInView),
       Collections.<ConfigurationPlugInVirtualDataWindow>emptyList());
 }
  // Determine which properties provided by the Map must be downcast from EventBean to Object
  private static Set<String> getEventBeanToObjectProps(
      Map<String, Object> selPropertyTypes, EventType resultEventType) {

    if (!(resultEventType instanceof BaseNestableEventType)) {
      return Collections.emptySet();
    }
    BaseNestableEventType mapEventType = (BaseNestableEventType) resultEventType;
    Set<String> props = null;
    for (Map.Entry<String, Object> entry : selPropertyTypes.entrySet()) {
      if (entry.getValue() instanceof BeanEventType
          && mapEventType.getTypes().get(entry.getKey()) instanceof Class) {
        if (props == null) {
          props = new HashSet<String>();
        }
        props.add(entry.getKey());
      }
    }
    if (props == null) {
      return Collections.emptySet();
    }
    return props;
  }
  public void testObjectArrayInheritanceRuntime() {
    Configuration configuration = SupportConfigFactory.getConfiguration();

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    ConfigurationOperations configOps = epService.getEPAdministrator().getConfiguration();
    configOps.addEventType("RootEvent", new String[] {"base"}, new Object[] {String.class});
    configOps.addEventType(
        "Sub1Event",
        new String[] {"sub1"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent")));
    configOps.addEventType(
        "Sub2Event",
        new String[] {"sub2"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("RootEvent")));
    configOps.addEventType(
        "SubAEvent",
        new String[] {"suba"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("Sub1Event")));
    configOps.addEventType(
        "SubBEvent",
        new String[] {"subb"},
        new Object[] {String.class},
        new ConfigurationEventTypeObjectArray(Collections.singleton("SubAEvent")));

    runObjectArrInheritanceAssertion(epService);

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
  public void testConfiguredViaPropsAndXML() {
    Configuration configuration = SupportConfigFactory.getConfiguration();
    configuration
        .getEngineDefaults()
        .getEventMeta()
        .setDefaultEventRepresentation(Configuration.EventRepresentation.OBJECTARRAY);
    configuration.addEventType(
        "MyOAType",
        "bean,theString,map".split(","),
        new Object[] {SupportBean.class.getName(), "string", "java.util.Map"});

    EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
    epService.initialize();
    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.startTest(epService, this.getClass(), getName());
    }

    EventType eventType =
        epService.getEPAdministrator().getConfiguration().getEventType("MyOAType");
    assertEquals(Object[].class, eventType.getUnderlyingType());
    assertEquals(String.class, eventType.getPropertyType("theString"));
    assertEquals(Map.class, eventType.getPropertyType("map"));
    assertEquals(SupportBean.class, eventType.getPropertyType("bean"));

    EPStatement stmt =
        epService
            .getEPAdministrator()
            .createEPL("select bean, theString, map('key'), bean.theString from MyOAType");
    SupportUpdateListener listener = new SupportUpdateListener();
    stmt.addListener(listener);
    assertEquals(Object[].class, stmt.getEventType().getUnderlyingType());

    SupportBean bean = new SupportBean("E1", 1);
    epService
        .getEPRuntime()
        .sendEvent(
            new Object[] {bean, "abc", Collections.singletonMap("key", "value")}, "MyOAType");
    EPAssertionUtil.assertProps(
        listener.assertOneGetNew(),
        "bean,theString,map('key'),bean.theString".split(","),
        new Object[] {bean, "abc", "value", "E1"});

    if (InstrumentationHelper.ENABLED) {
      InstrumentationHelper.endTest();
    }
  }
  protected static ExceptionHandlingService initExceptionHandling(
      String engineURI,
      ConfigurationEngineDefaults.ExceptionHandling exceptionHandling,
      ConfigurationEngineDefaults.ConditionHandling conditionHandling)
      throws ConfigurationException {
    List<ExceptionHandler> exceptionHandlers;
    if (exceptionHandling.getHandlerFactories() == null
        || exceptionHandling.getHandlerFactories().isEmpty()) {
      exceptionHandlers = Collections.emptyList();
    } else {
      exceptionHandlers = new ArrayList<ExceptionHandler>();
      ExceptionHandlerFactoryContext context = new ExceptionHandlerFactoryContext(engineURI);
      for (String className : exceptionHandling.getHandlerFactories()) {
        try {
          ExceptionHandlerFactory factory =
              (ExceptionHandlerFactory)
                  JavaClassHelper.instantiate(ExceptionHandlerFactory.class, className);
          ExceptionHandler handler = factory.getHandler(context);
          if (handler == null) {
            log.warn(
                "Exception handler factory '"
                    + className
                    + "' returned a null handler, skipping factory");
            continue;
          }
          exceptionHandlers.add(handler);
        } catch (RuntimeException ex) {
          throw new ConfigurationException(
              "Exception initializing exception handler from exception handler factory '"
                  + className
                  + "': "
                  + ex.getMessage(),
              ex);
        }
      }
    }

    List<ConditionHandler> conditionHandlers;
    if (conditionHandling.getHandlerFactories() == null
        || conditionHandling.getHandlerFactories().isEmpty()) {
      conditionHandlers = Collections.emptyList();
    } else {
      conditionHandlers = new ArrayList<ConditionHandler>();
      ConditionHandlerFactoryContext context = new ConditionHandlerFactoryContext(engineURI);
      for (String className : conditionHandling.getHandlerFactories()) {
        try {
          ConditionHandlerFactory factory =
              (ConditionHandlerFactory)
                  JavaClassHelper.instantiate(ConditionHandlerFactory.class, className);
          ConditionHandler handler = factory.getHandler(context);
          if (handler == null) {
            log.warn(
                "Condition handler factory '"
                    + className
                    + "' returned a null handler, skipping factory");
            continue;
          }
          conditionHandlers.add(handler);
        } catch (RuntimeException ex) {
          throw new ConfigurationException(
              "Exception initializing exception handler from exception handler factory '"
                  + className
                  + "': "
                  + ex.getMessage(),
              ex);
        }
      }
    }
    return new ExceptionHandlingService(engineURI, exceptionHandlers, conditionHandlers);
  }