public override void Configure(Configuration configuration) { var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.PropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("Bean", typeof(SupportBean).AssemblyQualifiedName, legacyDef); }
public override void Run(EPServiceProvider epService) { var configBean = new ConfigurationEventTypeLegacy(); configBean.StartTimestampPropertyName = null; configBean.EndTimestampPropertyName = "caldate"; TryInvalidConfig(epService, typeof(SupportDateTime), configBean, "Declared end timestamp property requires that a start timestamp property is also declared"); configBean.StartTimestampPropertyName = "xyz"; configBean.EndTimestampPropertyName = null; TryInvalidConfig(epService, typeof(SupportBean), configBean, "Declared start timestamp property name 'xyz' was not found"); configBean.StartTimestampPropertyName = "LongPrimitive"; configBean.EndTimestampPropertyName = "xyz"; TryInvalidConfig(epService, typeof(SupportBean), configBean, "Declared end timestamp property name 'xyz' was not found"); configBean.EndTimestampPropertyName = null; configBean.StartTimestampPropertyName = "TheString"; TryInvalidConfig(epService, typeof(SupportBean), configBean, "Declared start timestamp property 'TheString' is expected to return a DateTime, DateTimeEx or long-typed value but returns 'System.String'"); configBean.StartTimestampPropertyName = "LongPrimitive"; configBean.EndTimestampPropertyName = "TheString"; TryInvalidConfig(epService, typeof(SupportBean), configBean, "Declared end timestamp property 'TheString' is expected to return a DateTime, DateTimeEx or long-typed value but returns 'System.String'"); configBean.StartTimestampPropertyName = "Longdate"; configBean.EndTimestampPropertyName = "Caldate"; TryInvalidConfig(epService, typeof(SupportDateTime), configBean, "Declared end timestamp property 'Caldate' is expected to have the same property type as the start-timestamp property 'Longdate'"); }
public void Initialize() { if (_isInitialized) { return; } //NOTE This call internally depend on libraries //will throw an error if NEsper libs not found EPServiceProviderManager.PurgeDefaultProvider(); var cfg = new Configuration(); var evConfig = new ConfigurationEventTypeLegacy(); evConfig.PropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; cfg.AddEventType <ActivityEvent>(typeof(ActivityEvent).Name, evConfig); cfg.EngineDefaults.Threading.IsInternalTimerEnabled = true; cfg.EngineDefaults.Threading.IsInsertIntoDispatchPreserveOrder = false; cfg.EngineDefaults.Threading.IsListenerDispatchPreserveOrder = false; cfg.EngineDefaults.Logging.IsEnableExecutionDebug = false; cfg.EngineDefaults.Logging.IsEnableADO = false; cfg.EngineDefaults.Logging.IsEnableQueryPlan = false; cfg.EngineDefaults.Logging.IsEnableTimerDebug = false; cfg.EngineDefaults.ViewResources.IsShareViews = false; cfg.AddImport <StringUtil>(); _engine = EPServiceProviderManager.GetDefaultProvider(cfg); _engine.StatementStateChange += OnStatementChanged; _activityEventSender = _engine.EPRuntime.GetEventSender(typeof(ActivityEvent).Name); _isInitialized = true; }
/// <summary> /// Constructor takes a class as an argument. /// </summary> /// <param name="metadata">event type metadata</param> /// <param name="eventTypeId">The event type id.</param> /// <param name="clazz">is the class of an object</param> /// <param name="eventAdapterService">factory for event beans and event types</param> /// <param name="optionalLegacyDef">optional configuration supplying legacy event type information</param> public BeanEventType(EventTypeMetadata metadata, int eventTypeId, Type clazz, EventAdapterService eventAdapterService, ConfigurationEventTypeLegacy optionalLegacyDef) { Metadata = metadata; UnderlyingType = clazz; _eventAdapterService = eventAdapterService; OptionalLegacyDef = optionalLegacyDef; EventTypeId = eventTypeId; if (optionalLegacyDef != null) { FactoryMethodName = optionalLegacyDef.FactoryMethod; _copyMethodName = optionalLegacyDef.CopyMethod; PropertyResolutionStyle = optionalLegacyDef.PropertyResolutionStyle; } else { PropertyResolutionStyle = eventAdapterService.BeanEventTypeFactory.DefaultPropertyResolutionStyle; } _propertyGetterCache = new Dictionary <String, EventPropertyGetter>(); Initialize(false); EventTypeUtility.TimestampPropertyDesc desc = EventTypeUtility.ValidatedDetermineTimestampProps( this, optionalLegacyDef == null ? null : optionalLegacyDef.StartTimestampPropertyName, optionalLegacyDef == null ? null : optionalLegacyDef.EndTimestampPropertyName, SuperTypes); StartTimestampPropertyName = desc.Start; EndTimestampPropertyName = desc.End; }
/// <summary> /// Creates a new EventType object for a object of the specified class if this is the first time the class has been seen. Else uses a cached EventType instance, i.e. client classes do not need to cache. /// </summary> /// <param name="name">is the name</param> /// <param name="clazz">is the class of the object.</param> /// <param name="isPreconfiguredStatic">if from static engine config</param> /// <param name="isPreconfigured">if configured before use</param> /// <param name="isConfigured">if the class is a configuration value, false if discovered</param> /// <returns>EventType implementation for bean class</returns> public BeanEventType CreateBeanType(String name, Type clazz, bool isPreconfiguredStatic, bool isPreconfigured, bool isConfigured) { if (clazz == null) { throw new ArgumentException("Null value passed as class"); } BeanEventType eventType; // not created yet, thread-safe create using (_typesPerObjectLock.Acquire()) { eventType = _typesPerObject.Get(clazz); if (eventType != null) { _eventTypeIdGenerator.AssignedType(name, eventType); return(eventType); } // Check if we have a legacy type definition for this class ConfigurationEventTypeLegacy legacyDef = _typeToLegacyConfigs.Get(clazz.FullName); if ((legacyDef == null) && (_defaultAccessorStyle != AccessorStyleEnum.NATIVE)) { legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = _defaultAccessorStyle; } int typeId = _eventTypeIdGenerator.GetTypeId(name); EventTypeMetadata metadata = EventTypeMetadata.CreateBeanType(name, clazz, isPreconfiguredStatic, isPreconfigured, isConfigured, TypeClass.APPLICATION); eventType = new BeanEventType(metadata, typeId, clazz, _eventAdapterService, legacyDef); _typesPerObject.Put(clazz, eventType); } return(eventType); }
private void RunAssertionIterable(EPServiceProvider epService) { var configField = new ConfigurationEventTypeLegacy(); configField.AccessorStyle = AccessorStyleEnum.PUBLIC; epService.EPAdministrator.Configuration.AddEventType(typeof(MyEventWithField).Name, typeof(MyEventWithField).AssemblyQualifiedName, configField); var eventField = new MyEventWithField(); eventField.OtherEventsIterable = Collections.List(new OtherEvent("id1")); eventField.OtherEventsMap = Collections.SingletonMap("key", new OtherEvent("id2")); eventField.OtherEventsList = Collections.List(new OtherEvent("id3")); var configCglib = new ConfigurationEventTypeLegacy(); epService.EPAdministrator.Configuration.AddEventType(typeof(MyEventWithMethodWCGLIB).Name, typeof(MyEventWithMethodWCGLIB).AssemblyQualifiedName, configCglib); var eventMethodCglib = new MyEventWithMethodWCGLIB(Collections.List(new OtherEvent("id1")), Collections.SingletonMap("key", new OtherEvent("id2")), Collections.List(new OtherEvent("id3"))); var configNoCglib = new ConfigurationEventTypeLegacy(); configNoCglib.CodeGeneration = CodeGenerationEnum.DISABLED; epService.EPAdministrator.Configuration.AddEventType(typeof(MyEventWithMethodNoCGLIB).Name, typeof(MyEventWithMethodNoCGLIB).AssemblyQualifiedName, configNoCglib); var eventMethodNocglib = new MyEventWithMethodNoCGLIB(Collections.List(new OtherEvent("id1")), Collections.SingletonMap("key", new OtherEvent("id2")), Collections.List(new OtherEvent("id3"))); TryAssertionIterable(epService, typeof(MyEventWithField), eventField); TryAssertionIterable(epService, typeof(MyEventWithMethodWCGLIB), eventMethodCglib); TryAssertionIterable(epService, typeof(MyEventWithMethodNoCGLIB), eventMethodNocglib); }
public void TestInput() { IDictionary <String, Object> meta = new Dictionary <String, Object>(); meta.Put("timeTaken", typeof(DateTime)); _epService.EPAdministrator.Configuration.AddEventType("RFIDEvent", meta); _epService.EPAdministrator.CreateEPL("select timeTaken.Format() as timeTakenStr from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Get('month') as timeTakenMonth from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.GetMonthOfYear() as timeTakenMonth from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Minus(2 minutes) as timeTakenMinus2Min from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Minus(2*60*1000) as timeTakenMinus2Min from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Plus(2 minutes) as timeTakenMinus2Min from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Plus(2*60*1000) as timeTakenMinus2Min from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.RoundCeiling('min') as timeTakenRounded from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.RoundFloor('min') as timeTakenRounded from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.Set('month', 3) as timeTakenMonth from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.WithDate(2002, 4, 30) as timeTakenDated from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.WithMax('sec') as timeTakenMaxSec from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.ToCalendar() as timeTakenCal from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.ToDate() as timeTakenDate from RFIDEvent"); _epService.EPAdministrator.CreateEPL("select timeTaken.ToMillisec() as timeTakenLong from RFIDEvent"); // test pattern use ConfigurationEventTypeLegacy leg = new ConfigurationEventTypeLegacy(); leg.StartTimestampPropertyName = "LongdateStart"; _epService.EPAdministrator.Configuration.AddEventType("A", typeof(SupportTimeStartEndA).FullName, leg); _epService.EPAdministrator.Configuration.AddEventType("B", typeof(SupportTimeStartEndB).FullName, leg); TryRun("a.LongdateStart.After(b)", "2002-05-30 09:00:00.000", "2002-05-30 08:59:59.999", true); TryRun("a.After(b.LongdateStart)", "2002-05-30 09:00:00.000", "2002-05-30 08:59:59.999", true); TryRun("a.After(b)", "2002-05-30 09:00:00.000", "2002-05-30 08:59:59.999", true); TryRun("a.After(b)", "2002-05-30 08:59:59.999", "2002-05-30 09:00:00.000", false); }
private void TryFinalClass(CodeGenerationEnum codeGeneration) { var config = SupportConfigFactory.GetConfiguration(); var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.NATIVE; legacyDef.CodeGeneration = codeGeneration; config.AddEventType("MyFinalEvent", typeof(SupportBeanFinal).FullName, legacyDef); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } var statementText = "select IntPrimitive " + "from " + typeof(SupportBeanFinal).FullName + "#length(5)"; var statement = _epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; var theEvent = new SupportBeanFinal(10); _epService.EPRuntime.SendEvent(theEvent); Assert.AreEqual(10, listener.LastNewData[0].Get("IntPrimitive")); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } _epService.Dispose(); }
public void AddEventType( string eventTypeName, Type eventClass, ConfigurationEventTypeLegacy legacyEventTypeDesc) { AddEventType(eventTypeName, eventClass.AssemblyQualifiedName, legacyEventTypeDesc); }
public void TestCopyMethod() { var copyFields = "MyString".Split(','); Assert.That(_eventTypeSimple.GetCopyMethod(copyFields), Is.InstanceOf <BeanEventBeanSerializableCopyMethod>()); var nonSerializable = new BeanEventType(null, 0, typeof(NonSerializableNonCopyable), SupportEventAdapterService.Service, null); Assert.That(nonSerializable.GetCopyMethod(copyFields), Is.Null); var config = new ConfigurationEventTypeLegacy(); config.CopyMethod = "MyCopyMethod"; nonSerializable = new BeanEventType(null, 0, typeof(NonSerializableNonCopyable), SupportEventAdapterService.Service, config); try { nonSerializable.GetCopyMethod(copyFields); // also logs error Assert.Fail(); } catch (EPException) { // expected } var myCopyable = new BeanEventType(null, 0, typeof(MyCopyable), SupportEventAdapterService.Service, config); Assert.That(myCopyable.GetCopyMethod(copyFields), Is.InstanceOf <BeanEventBeanConfiguredCopyMethod>()); // also logs error var myCopyableAndSer = new BeanEventType(null, 0, typeof(MyCopyableAndSerializable), SupportEventAdapterService.Service, config); Assert.That(myCopyableAndSer.GetCopyMethod(copyFields), Is.InstanceOf <BeanEventBeanConfiguredCopyMethod>()); // also logs error }
/// <summary> /// Ctor. /// </summary> /// <param name="legacyConfig">is a legacy type specification containinginformation about explicitly configured fields and methods </param> public PropertyListBuilderExplicit(ConfigurationEventTypeLegacy legacyConfig) { if (legacyConfig == null) { throw new ArgumentException("Required configuration not passed"); } _legacyConfig = legacyConfig; }
public override void Configure(Configuration configuration) { var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.NATIVE; legacyDef.CodeGeneration = codegen ? CodeGenerationEnum.ENABLED : CodeGenerationEnum.DISABLED; configuration.AddEventType("MyFinalEvent", typeof(SupportBeanFinal).AssemblyQualifiedName, legacyDef); }
private void TryInvalidConfig(EPServiceProvider epService, Type clazz, ConfigurationEventTypeLegacy config, string message) { try { epService.EPAdministrator.Configuration.AddEventType(clazz.Name, clazz, config); Assert.Fail(); } catch (ConfigurationException ex) { Assert.AreEqual(message, ex.Message); } }
public void SetUp() { var configuration = SupportConfigFactory.GetConfiguration(); var legacy = new ConfigurationEventTypeLegacy(); legacy.FactoryMethod = "GetInstance"; configuration.AddEventType("SupportBeanString", typeof(SupportBeanString).FullName, legacy); configuration.AddImport(typeof(TestInsertIntoPopulateUnderlying).Namespace); legacy = new ConfigurationEventTypeLegacy(); legacy.FactoryMethod = typeof(SupportSensorEventFactory).FullName + ".GetInstance"; configuration.AddEventType("SupportSensorEvent", typeof(SupportSensorEvent).FullName, legacy); _epService = EPServiceProviderManager.GetDefaultProvider(configuration); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } _listener = new SupportUpdateListener(); _subscriber = new SupportSubscriber(); _epService.EPAdministrator.Configuration.AddImport(typeof(SupportStaticMethodLib)); _epService.EPAdministrator.Configuration.AddEventType <SupportBean>(); _epService.EPAdministrator.Configuration.AddEventType("SupportTemperatureBean", typeof(SupportTemperatureBean)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanComplexProps", typeof(SupportBeanComplexProps)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanInterfaceProps", typeof(SupportBeanInterfaceProps)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanErrorTestingOne", typeof(SupportBeanErrorTestingOne)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanErrorTestingTwo", typeof(SupportBeanErrorTestingTwo)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanReadOnly", typeof(SupportBeanReadOnly)); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanArrayCollMap", typeof(SupportBeanArrayCollMap)); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_N>(); _epService.EPAdministrator.Configuration.AddEventType <SupportBean_S0>(); _epService.EPAdministrator.Configuration.AddEventType("SupportBeanObject", typeof(SupportBeanObject)); _epService.EPAdministrator.Configuration.AddImport(typeof(SupportEnum)); IDictionary <String, Object> mymapDef = new Dictionary <string, object>(); mymapDef.Put("AnInt", typeof(int)); mymapDef.Put("IntBoxed", typeof(int)); mymapDef.Put("FloatBoxed", typeof(float)); mymapDef.Put("IntArr", typeof(int[])); mymapDef.Put("MapProp", typeof(IDictionary <string, string>)); mymapDef.Put("IsAImpl", typeof(ISupportAImpl)); mymapDef.Put("IsBImpl", typeof(ISupportBImpl)); mymapDef.Put("IsGImpl", typeof(ISupportAImplSuperGImpl)); mymapDef.Put("IsABImpl", typeof(ISupportBaseABImpl)); mymapDef.Put("Nested", typeof(SupportBeanComplexProps.SupportBeanSpecialGetterNested)); _epService.EPAdministrator.Configuration.AddEventType("MyMap", mymapDef); var xml = new ConfigurationEventTypeXMLDOM(); xml.RootElementName = "abc"; _epService.EPAdministrator.Configuration.AddEventType("xmltype", xml); }
public void SetUp() { ConfigurationEventTypeLegacy config = new ConfigurationEventTypeLegacy(); // add 2 explicit properties, also supported config.AddFieldProperty("x", "fieldNested"); config.AddMethodProperty("y", "ReadLegacyBeanVal"); _builder = new PropertyListBuilderNative(config); }
public void TestCaseInsensitiveTypeConfig() { Configuration configuration = SupportConfigFactory.GetConfiguration(); ConfigurationEventTypeLegacy legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.PropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("Bean", typeof(SupportBean).FullName, legacyDef); TryCaseInsensitive(configuration, "select theSTRING, INTPRIMITIVE from Bean where THESTRING='A'", "theSTRING", "INTPRIMITIVE"); TryCaseInsensitive(configuration, "select THEsTrInG, INTprimitIVE from Bean where theSTRing='A'", "THEsTrInG", "INTprimitIVE"); }
public override void Configure(Configuration configuration) { var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.NATIVE; legacyDef.CodeGeneration = _codegen ? CodeGenerationEnum.ENABLED : CodeGenerationEnum.DISABLED; legacyDef.AddFieldProperty("explicitFInt", "fieldIntPrimitive"); legacyDef.AddMethodProperty("explicitMGetInt", "get_IntPrimitive"); legacyDef.AddMethodProperty("explicitMReadInt", "ReadIntPrimitive"); configuration.AddEventType("MyLegacyEvent", typeof(SupportLegacyBeanInt).AssemblyQualifiedName, legacyDef); }
private void TryInvalidField(String fieldName, Type clazz) { var config = new ConfigurationEventTypeLegacy(); config.AddFieldProperty("name", fieldName); _builder = new PropertyListBuilderExplicit(config); try { _builder.AssessProperties(clazz); } catch (ConfigurationException ex) { // expected Log.Debug(ex.Message, ex); } }
public void AddEventType(String eventTypeName, String eventType, ConfigurationEventTypeLegacy legacyEventTypeDesc) { CheckTableExists(eventTypeName); try { IDictionary <String, ConfigurationEventTypeLegacy> map = new Dictionary <String, ConfigurationEventTypeLegacy>(); map.Put(eventType, legacyEventTypeDesc); _eventAdapterService.TypeLegacyConfigs = map; _eventAdapterService.AddBeanType(eventTypeName, eventType, false, false, false, true); } catch (EventAdapterException ex) { throw new ConfigurationException("Failed to add legacy event type definition for type '" + eventTypeName + "': " + ex.Message, ex); } }
/// <summary> /// Populates explicitly-defined properties into the result list. /// </summary> /// <param name="result">is the resulting list of event property descriptors</param> /// <param name="type">is the class to introspect</param> /// <param name="legacyConfig">supplies specification of explicit methods and fields to expose</param> public static void GetExplicitProperties(IList <InternalEventPropDescriptor> result, Type type, ConfigurationEventTypeLegacy legacyConfig) { foreach (ConfigurationEventTypeLegacy.LegacyFieldPropDesc desc in legacyConfig.FieldProperties) { result.Add(MakeDesc(type, desc)); } foreach (ConfigurationEventTypeLegacy.LegacyMethodPropDesc desc in legacyConfig.MethodProperties) { result.Add(MakeDesc(type, desc)); } }
public void TestBeaconWithBeans() { var legacy = new ConfigurationEventTypeLegacy(); legacy.CodeGeneration = CodeGenerationEnum.DISABLED; _epService.EPAdministrator.Configuration.AddEventType("MyLegacyEvent", typeof(MyLegacyEvent).FullName, legacy); var resultLegacy = (MyLegacyEvent)RunAssertionBeans("MyLegacyEvent"); Assert.AreEqual("abc", resultLegacy.Myfield); #if NOT_SUPPORTED_IN_DOTNET _epService.EPAdministrator.Configuration.AddEventType("MyEventNoDefaultCtor", typeof(MyEventNoDefaultCtor)); var resultNoDefCtor = (MyEventNoDefaultCtor)RunAssertionBeans("MyEventNoDefaultCtor"); Assert.AreEqual("abc", resultNoDefCtor.Myfield); #endif }
private void RunAssertionBeaconWithBeans(EPServiceProvider epService) { var legacy = new ConfigurationEventTypeLegacy(); legacy.CodeGeneration = CodeGenerationEnum.DISABLED; epService.EPAdministrator.Configuration.AddEventType( "MyLegacyEvent", typeof(MyLegacyEvent).AssemblyQualifiedName, legacy); var resultLegacy = (MyLegacyEvent)RunAssertionBeans(epService, "MyLegacyEvent"); Assert.AreEqual("abc", resultLegacy.Myfield); #if NOT_SUPPORTED_IN_DOTNET epService.EPAdministrator.Configuration.AddEventType("MyEventNoDefaultCtor", typeof(MyEventNoDefaultCtor)); var resultNoDefCtor = (MyEventNoDefaultCtor)RunAssertionBeans(epService, "MyEventNoDefaultCtor"); Assert.AreEqual("abc", resultNoDefCtor.Myfield); #endif }
public void SetUp() { var config = new ConfigurationEventTypeLegacy(); config.AddFieldProperty("f_legVal", "fieldLegacyVal"); config.AddFieldProperty("f_strArr", "fieldStringArray"); config.AddFieldProperty("f_strMap", "fieldMapped"); config.AddFieldProperty("f_legNested", "fieldNested"); config.AddMethodProperty("m_legVal", "ReadLegacyBeanVal"); config.AddMethodProperty("m_strArr", "ReadStringArray"); config.AddMethodProperty("m_strInd", "ReadStringIndexed"); config.AddMethodProperty("m_strMapKeyed", "ReadMapByKey"); config.AddMethodProperty("m_strMap", "ReadMap"); config.AddMethodProperty("m_legNested", "ReadLegacyNested"); _builder = new PropertyListBuilderExplicit(config); }
public void TryNativeBeanAccessor(CodeGenerationEnum codeGeneration) { var config = SupportConfigFactory.GetConfiguration(); var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.NATIVE; legacyDef.CodeGeneration = codeGeneration; legacyDef.AddFieldProperty("explicitFInt", "fieldIntPrimitive"); legacyDef.AddMethodProperty("explicitMGetInt", "GetIntPrimitive"); legacyDef.AddMethodProperty("explicitMReadInt", "ReadIntPrimitive"); config.AddEventType("MyLegacyEvent", typeof(SupportLegacyBeanInt).FullName, legacyDef); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); if (InstrumentationHelper.ENABLED) { InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName); } var statementText = "select IntPrimitive, explicitFInt, explicitMGetInt, explicitMReadInt " + " from MyLegacyEvent#length(5)"; var statement = _epService.EPAdministrator.CreateEPL(statementText); var listener = new SupportUpdateListener(); statement.Events += listener.Update; var eventType = statement.EventType; var theEvent = new SupportLegacyBeanInt(10); _epService.EPRuntime.SendEvent(theEvent); foreach (var name in new String[] { "IntPrimitive", "explicitFInt", "explicitMGetInt", "explicitMReadInt" }) { Assert.AreEqual(typeof(int), eventType.GetPropertyType(name)); Assert.AreEqual(10, listener.LastNewData[0].Get(name)); } if (InstrumentationHelper.ENABLED) { InstrumentationHelper.EndTest(); } _epService.Dispose(); }
private void RunAssertionInput(EPServiceProvider epService) { string[] fields = "val0,val1".Split(','); string epl = "select " + "utildate.Get('month') as val0," + "longdate.Get('month') as val1 " + " from SupportDateTime"; EPStatement stmt = epService.EPAdministrator.CreateEPL(epl); var listener = new SupportUpdateListener(); stmt.Events += listener.Update; LambdaAssertionUtil.AssertTypes(stmt.EventType, fields, new Type[] { typeof(int?), typeof(int?) }); string startTime = "2002-05-30T09:00:00.000"; epService.EPRuntime.SendEvent(SupportDateTime.Make(startTime)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), fields, new object[] { 5, 5 }); // try event as input var configBean = new ConfigurationEventTypeLegacy(); configBean.StartTimestampPropertyName = "longdateStart"; configBean.EndTimestampPropertyName = "longdateEnd"; epService.EPAdministrator.Configuration.AddEventType("SupportTimeStartEndA", typeof(SupportTimeStartEndA), configBean); stmt.Dispose(); epl = "select abc.Get('month') as val0 from SupportTimeStartEndA as abc"; stmt = epService.EPAdministrator.CreateEPL(epl); stmt.Events += listener.Update; epService.EPRuntime.SendEvent(SupportTimeStartEndA.Make("A0", startTime, 0)); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "val0".Split(','), new object[] { 5 }); // test "get" method on object is preferred epService.EPAdministrator.Configuration.AddEventType(typeof(MyEvent)); epService.EPAdministrator.CreateEPL("select e.Get() as c0, e.Get('abc') as c1 from MyEvent as e").Events += listener.Update; epService.EPRuntime.SendEvent(new MyEvent()); EPAssertionUtil.AssertProps(listener.AssertOneGetNewAndReset(), "c0,c1".Split(','), new object[] { 1, 2 }); stmt.Dispose(); }
/// <summary> /// Creates an implementation for a builer considering the accessor style and code /// generation flags for a given class. /// </summary> /// <param name="optionalLegacyClassConfigs">configures how event property listy is build</param> /// <returns> /// builder/introspector implementation /// </returns> public static PropertyListBuilder CreateBuilder(ConfigurationEventTypeLegacy optionalLegacyClassConfigs) { if (optionalLegacyClassConfigs == null) { return(new PropertyListBuilderNative(null)); } if (optionalLegacyClassConfigs.AccessorStyle == AccessorStyleEnum.NATIVE) { return(new PropertyListBuilderNative(optionalLegacyClassConfigs)); } if (optionalLegacyClassConfigs.AccessorStyle == AccessorStyleEnum.EXPLICIT) { return(new PropertyListBuilderExplicit(optionalLegacyClassConfigs)); } if (optionalLegacyClassConfigs.AccessorStyle == AccessorStyleEnum.PUBLIC) { return(new PropertyListBuilderPublic(optionalLegacyClassConfigs)); } throw new ArgumentException("Cannot match accessor style to property list builder"); }
public void TestAddTypeFullName() { var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.PUBLIC; legacyDef.CodeGeneration = CodeGenerationEnum.DISABLED; var config = SupportConfigFactory.GetConfiguration(); _epService = EPServiceProviderManager.GetDefaultProvider(config); _epService.Initialize(); _epService.EPAdministrator.Configuration.AddEventType("MyLegacyEvent", typeof(SupportLegacyBean).FullName, legacyDef); Assert.IsTrue(_epService.EPAdministrator.Configuration.IsEventTypeExists("MyLegacyEvent")); Assert.That(_epService.EPAdministrator.Configuration.GetEventType("MyLegacyEvent"), Is.Not.Null); Assert.That(_epService.EPAdministrator.Configuration.GetEventTypeNameUsedBy("MyLegacyEvent"), Is.Empty); using (_epService.EPAdministrator.CreateEPL("select * from MyLegacyEvent")) { } }
public void AddEventType(string eventTypeName, string eventClass, ConfigurationEventTypeLegacy legacyEventTypeDesc) { // To ensure proper usage, we have to convert the type to its assembly qualified name. try { eventClass = TypeHelper.ResolveType(eventClass, true).AssemblyQualifiedName; } catch (TypeLoadException ex) { throw new ConfigurationException("Failed to add legacy event type definition for type '" + eventTypeName + "': " + ex.Message, ex); } CheckTableExists(eventTypeName); try { var map = new Dictionary <string, ConfigurationEventTypeLegacy>(); map.Put(eventClass, legacyEventTypeDesc); _eventAdapterService.TypeLegacyConfigs = map; _eventAdapterService.AddBeanType(eventTypeName, eventClass, false, false, false, true); } catch (EventAdapterException ex) { throw new ConfigurationException("Failed to add legacy event type definition for type '" + eventTypeName + "': " + ex.Message, ex); } }
public override void Configure(Configuration configuration) { var codeGeneration = codegen ? CodeGenerationEnum.ENABLED : CodeGenerationEnum.DISABLED; var legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.EXPLICIT; legacyDef.CodeGeneration = codeGeneration; legacyDef.AddFieldProperty("explicitFNested", "fieldNested"); legacyDef.AddMethodProperty("explicitMNested", "ReadLegacyNested"); configuration.AddEventType("MyLegacyEvent", typeof(SupportLegacyBean).AssemblyQualifiedName, legacyDef); legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.EXPLICIT; legacyDef.CodeGeneration = codeGeneration; legacyDef.AddFieldProperty("fieldNestedClassValue", "fieldNestedValue"); legacyDef.AddMethodProperty("ReadNestedClassValue", "ReadNestedValue"); configuration.AddEventType("MyLegacyNestedEvent", typeof(SupportLegacyBean.LegacyNested).AssemblyQualifiedName, legacyDef); legacyDef = new ConfigurationEventTypeLegacy(); legacyDef.AccessorStyle = AccessorStyleEnum.EXPLICIT; legacyDef.CodeGeneration = codeGeneration; configuration.AddEventType("MySupportBean", typeof(SupportBean).AssemblyQualifiedName, legacyDef); }
/// <summary> /// Constructor takes a class as an argument. /// </summary> /// <param name="container">The container.</param> /// <param name="metadata">event type metadata</param> /// <param name="eventTypeId">type id</param> /// <param name="clazz">is the class of a java bean or other POJO</param> /// <param name="eventAdapterService">factory for event beans and event types</param> /// <param name="optionalLegacyDef">optional configuration supplying legacy event type information</param> public BeanEventType( IContainer container, EventTypeMetadata metadata, int eventTypeId, Type clazz, EventAdapterService eventAdapterService, ConfigurationEventTypeLegacy optionalLegacyDef) { _container = container; _metadata = metadata; _clazz = clazz; _eventAdapterService = eventAdapterService; _optionalLegacyDef = optionalLegacyDef; _eventTypeId = eventTypeId; if (optionalLegacyDef != null) { _factoryMethodName = optionalLegacyDef.FactoryMethod; _copyMethodName = optionalLegacyDef.CopyMethod; _propertyResolutionStyle = optionalLegacyDef.PropertyResolutionStyle; } else { _propertyResolutionStyle = eventAdapterService.BeanEventTypeFactory.DefaultPropertyResolutionStyle; } _propertyGetterCache = new Dictionary<string, EventPropertyGetterSPI>(); Initialize(false, eventAdapterService.EngineImportService); var desc = EventTypeUtility.ValidatedDetermineTimestampProps( this, optionalLegacyDef == null ? null : optionalLegacyDef.StartTimestampPropertyName, optionalLegacyDef == null ? null : optionalLegacyDef.EndTimestampPropertyName, _superTypes); _startTimestampPropertyName = desc.Start; _endTimestampPropertyName = desc.End; }