public void RegisterXMLNewType( EventTypeMetadata metadata, ConfigurationCommonEventTypeXMLDOM config) { SchemaModel schemaModel = null; if ((config.SchemaResource != null) || (config.SchemaText != null)) { try { schemaModel = XSDSchemaMapper.LoadAndMap( config.SchemaResource, config.SchemaText, _container.ResourceManager()); } catch (Exception ex) { throw new EPException(ex.Message, ex); } } EventType eventType = _eventTypeFactory.CreateXMLType( metadata, config, schemaModel, null, metadata.Name, _beanEventTypeFactory, _xmlFragmentEventTypeFactory, _eventTypeNameResolver); HandleRegister(eventType); if (eventType is SchemaXMLEventType) { _xmlFragmentEventTypeFactory.AddRootType((SchemaXMLEventType) eventType); } }
public void Configure(Configuration configuration) { SupportExceptionHandlerFactory.FactoryContexts.Clear(); SupportExceptionHandlerFactory.Handlers.Clear(); configuration.Runtime.ExceptionHandling.HandlerFactories.Clear(); configuration.Runtime.ExceptionHandling.AddClass(typeof(SupportExceptionHandlerFactory)); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Runtime.Threading.IsThreadPoolInbound = true; configuration.Runtime.Threading.ThreadPoolInboundNumThreads = 4; configuration.Compiler.Expression.UdfCache = false; configuration.Common.AddEventType("MyMap", new Dictionary<string, object>()); configuration.Common.AddEventType("SupportBean", typeof(SupportBean)); configuration.Common.AddImportType(typeof(SupportStaticMethodLib)); configuration.Common.AddEventType("MyOA", new string[0], new object[0]); var xmlDOMEventTypeDesc = new ConfigurationCommonEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; configuration.Common.AddEventType("XMLType", xmlDOMEventTypeDesc); configuration.Compiler.AddPlugInSingleRowFunction( "throwException", GetType(), "ThrowException", ConfigurationCompilerPlugInSingleRowFunction.ValueCacheEnum.DISABLED, ConfigurationCompilerPlugInSingleRowFunction.FilterOptimizableEnum.DISABLED, true); }
public EventType CreateXMLType( EventTypeMetadata metadata, ConfigurationCommonEventTypeXMLDOM detail, SchemaModel schemaModel, string representsFragmentOfProperty, string representsOriginalTypeName, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory, EventTypeNameResolver eventTypeNameResolver) { if (metadata.IsPropertyAgnostic) { return new SimpleXMLEventType( metadata, detail, beanEventTypeFactory.EventBeanTypedEventFactory, eventTypeNameResolver, xmlFragmentEventTypeFactory); } return new SchemaXMLEventType( metadata, detail, schemaModel, representsFragmentOfProperty, representsOriginalTypeName, beanEventTypeFactory.EventBeanTypedEventFactory, eventTypeNameResolver, xmlFragmentEventTypeFactory); }
public void TestInvalidConfig() { ConfigurationCommonEventTypeXMLDOM desc = new ConfigurationCommonEventTypeXMLDOM(); desc.RootElementName = "ABC"; desc.StartTimestampPropertyName = "mystarttimestamp"; desc.EndTimestampPropertyName = "myendtimestamp"; desc.AddXPathProperty("mystarttimestamp", "/test/prop", XPathResultType.Number); TryInvalidConfigurationCompileAndRuntime(SupportConfigFactory.GetConfiguration(), config => config.Common.AddEventType("TypeXML", desc), "Declared start timestamp property 'mystarttimestamp' is expected to return a DateTimeEx, DateTime, DateTimeOffset or long-typed value but returns 'System.Nullable<System.Double>'"); }
private static ConfigurationCommonEventTypeXMLDOM GetConfig(IResourceManager resourceManager) { var eventTypeMeta = new ConfigurationCommonEventTypeXMLDOM(); eventTypeMeta.RootElementName = "rootelement"; var schemaStream = resourceManager.GetResourceAsStream(CLASSLOADER_SCHEMA_URI); if (schemaStream == null) { throw new IllegalStateException("Failed to load schema '" + CLASSLOADER_SCHEMA_URI + "'"); } var reader = new StreamReader(schemaStream); eventTypeMeta.SchemaText = reader.ReadToEnd(); return eventTypeMeta; }
public void SetUp() { var simpleDoc = new XmlDocument(); simpleDoc.LoadXml(xml); var config = new ConfigurationCommonEventTypeXMLDOM(); config.RootElementName = "simpleEvent"; config.AddXPathProperty("customProp", "count(/simpleEvent/nested3/nested4)", XPathResultType.Number); var eventType = new SimpleXMLEventType(null, config, null, null, null); theEvent = new XMLEventBean(simpleDoc.DocumentElement, eventType); }
private static void AddXMLDOMType( EventTypeRepositoryImpl repo, string eventTypeName, ConfigurationCommonEventTypeXMLDOM detail, SchemaModel schemaModel, BeanEventTypeFactory beanEventTypeFactory, XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory) { if (detail.RootElementName == null) { throw new EventAdapterException("Required root element name has not been supplied"); } var existingType = repo.GetTypeByName(eventTypeName); if (existingType != null) { var message = "Event type named '" + eventTypeName + "' has already been declared with differing column name or type information"; throw new ConfigurationException(message); } var propertyAgnostic = detail.SchemaResource == null && detail.SchemaText == null; var metadata = new EventTypeMetadata( eventTypeName, null, EventTypeTypeClass.STREAM, EventTypeApplicationType.XML, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, propertyAgnostic, new EventTypeIdPair(CRC32Util.ComputeCRC32(eventTypeName), -1)); var type = beanEventTypeFactory.EventTypeFactory.CreateXMLType( metadata, detail, schemaModel, null, metadata.Name, beanEventTypeFactory, xmlFragmentEventTypeFactory, repo); repo.AddType(type); if (type is SchemaXMLEventType) { xmlFragmentEventTypeFactory.AddRootType((SchemaXMLEventType) type); } }
/// <summary> /// Ctor. /// </summary> /// <param name="configurationEventTypeXMLDOM">is the XML DOM configuration such as root element and schema names</param> /// <param name="metadata">event type metadata</param> /// <param name="eventBeanTypedEventFactory">for registration and lookup of types</param> /// <param name="xmlEventTypeFactory">xml type factory</param> /// <param name="eventTypeResolver">resolver</param> public BaseXMLEventType( EventTypeMetadata metadata, ConfigurationCommonEventTypeXMLDOM configurationEventTypeXMLDOM, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeNameResolver eventTypeResolver, XMLFragmentEventTypeFactory xmlEventTypeFactory) : base(eventBeanTypedEventFactory, metadata, typeof(XmlNode), eventTypeResolver, xmlEventTypeFactory) { RootElementName = configurationEventTypeXMLDOM.RootElementName; ConfigurationEventTypeXMLDOM = configurationEventTypeXMLDOM; if (configurationEventTypeXMLDOM.XPathFunctionResolver != null) { try { _functionResolver = TypeHelper.Instantiate<IXPathFunctionResolver>( configurationEventTypeXMLDOM.XPathFunctionResolver, ClassForNameProviderDefault.INSTANCE); } catch (ClassInstantiationException ex) { throw new ConfigurationException( "Error configuring XPath function resolver for XML type '" + configurationEventTypeXMLDOM.RootElementName + "' : " + ex.Message, ex); } } if (configurationEventTypeXMLDOM.XPathVariableResolver != null) { try { _variableResolver = TypeHelper.Instantiate<IXPathVariableResolver>( configurationEventTypeXMLDOM.XPathVariableResolver, ClassForNameProviderDefault.INSTANCE); } catch (ClassInstantiationException ex) { throw new ConfigurationException( "Error configuring XPath variable resolver for XML type '" + configurationEventTypeXMLDOM.RootElementName + "' : " + ex.Message, ex); } } }
public SimpleXMLEventType( EventTypeMetadata eventTypeMetadata, ConfigurationCommonEventTypeXMLDOM configurationEventTypeXMLDOM, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeNameResolver eventTypeResolver, XMLFragmentEventTypeFactory xmlEventTypeFactory) : base( eventTypeMetadata, configurationEventTypeXMLDOM, eventBeanTypedEventFactory, eventTypeResolver, xmlEventTypeFactory) { isResolvePropertiesAbsolute = configurationEventTypeXMLDOM.IsXPathResolvePropertiesAbsolute; propertyGetterCache = new Dictionary<string, EventPropertyGetterSPI>(); // Set of namespace context for XPath expressions var xPathNamespaceContext = new XPathNamespaceContext(); foreach (var entry in configurationEventTypeXMLDOM.NamespacePrefixes) { xPathNamespaceContext.AddNamespace(entry.Key, entry.Value); } if (configurationEventTypeXMLDOM.DefaultNamespace != null) { var defaultNamespace = configurationEventTypeXMLDOM.DefaultNamespace; xPathNamespaceContext.SetDefaultNamespace(defaultNamespace); // determine a default namespace prefix to use to construct XPath expressions from pure property names defaultNamespacePrefix = null; foreach (var entry in configurationEventTypeXMLDOM.NamespacePrefixes) { if (entry.Value.Equals(defaultNamespace)) { defaultNamespacePrefix = entry.Key; break; } } } NamespaceContext = xPathNamespaceContext; Initialize( configurationEventTypeXMLDOM.XPathProperties.Values, Collections.GetEmptyList<ExplicitPropertyDescriptor>()); }
private static ConfigurationCommonEventTypeXMLDOM GetConfigTestType( string additionalXPathProperty, bool isUseXPathPropertyExpression, string schemaUriSimpleSchema) { var eventTypeMeta = new ConfigurationCommonEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; eventTypeMeta.SchemaResource = schemaUriSimpleSchema; eventTypeMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); eventTypeMeta.AddXPathProperty( "customProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); eventTypeMeta.IsXPathPropertyExpr = isUseXPathPropertyExpression; if (additionalXPathProperty != null) { eventTypeMeta.AddXPathProperty( additionalXPathProperty, "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); } return eventTypeMeta; }
public void SetUp() { var schemaUrl = container.ResourceManager().ResolveResourceURL("regression/simpleSchema.xsd"); var configNoNS = new ConfigurationCommonEventTypeXMLDOM(); configNoNS.IsXPathPropertyExpr = true; configNoNS.SchemaResource = schemaUrl.ToString(); configNoNS.RootElementName = "simpleEvent"; configNoNS.AddXPathProperty("customProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathResultType.Number); configNoNS.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); var model = XSDSchemaMapper.LoadAndMap( schemaUrl.ToString(), null, container.ResourceManager()); var eventTypeNoNS = new SchemaXMLEventType( null, configNoNS, model, null, null, null, null, null); using (var stream = container.ResourceManager().GetResourceAsStream("regression/simpleWithSchema.xml")) { var noNSDoc = new XmlDocument(); noNSDoc.Load(stream); eventSchemaOne = new XMLEventBean(noNSDoc.DocumentElement, eventTypeNoNS); } }
private static void Configure(Configuration configuration) { foreach (Type clazz in new[] { typeof(SupportBean), typeof(SupportObjectArrayOneDim), typeof(SupportBeanSimple), typeof(SupportBean_A), typeof(SupportRFIDEvent), typeof(SupportBean_S0), typeof(SupportBean_S1), typeof(SupportMarketDataBean), typeof(SupportTemperatureBean), typeof(SupportBeanComplexProps), typeof(SupportBeanInterfaceProps), typeof(SupportBeanErrorTestingOne), typeof(SupportBeanErrorTestingTwo), typeof(SupportBeanReadOnly), typeof(SupportBeanArrayCollMap), typeof(SupportBean_N), typeof(SupportBeanObject), typeof(SupportBeanCtorOne), typeof(SupportBeanCtorTwo), typeof(SupportBean_ST0), typeof(SupportBean_ST1), typeof(SupportEventWithCtorSameType), typeof(SupportBeanCtorThree), typeof(SupportBeanCtorOne), typeof(SupportBean_ST0), typeof(SupportBean_ST1), typeof(SupportEventWithMapFieldSetter), typeof(SupportBeanNumeric), typeof(SupportBeanArrayEvent), typeof(SupportBean_A), typeof(SupportBean_B), typeof(SupportEventContainsSupportBean) }) { configuration.Common.AddEventType(clazz); } Schema avroExistingTypeSchema = SchemaBuilder.Record( "name", TypeBuilder.RequiredLong("MyLong"), TypeBuilder.Field( "MyLongArray", TypeBuilder.Array(TypeBuilder.LongType())), TypeBuilder.Field("MyByteArray", TypeBuilder.BytesType()), TypeBuilder.Field( "MyMap", TypeBuilder.Map( TypeBuilder.StringType( TypeBuilder.Property( AvroConstant.PROP_STRING_KEY, AvroConstant.PROP_STRING_VALUE))))); configuration.Common.AddEventTypeAvro("AvroExistingType", new ConfigurationCommonEventTypeAvro(avroExistingTypeSchema)); IDictionary<string, object> mapTypeInfo = new Dictionary<string, object>(); mapTypeInfo.Put("one", typeof(string)); mapTypeInfo.Put("two", typeof(string)); configuration.Common.AddEventType("MapOne", mapTypeInfo); configuration.Common.AddEventType("MapTwo", mapTypeInfo); string[] props = {"one", "two"}; object[] types = {typeof(string), typeof(string)}; configuration.Common.AddEventType("OAOne", props, types); configuration.Common.AddEventType("OATwo", props, types); Schema avroOneAndTwoSchema = SchemaBuilder.Record( "name", TypeBuilder.RequiredString("one"), TypeBuilder.RequiredString("two")); configuration.Common.AddEventTypeAvro("AvroOne", new ConfigurationCommonEventTypeAvro(avroOneAndTwoSchema)); configuration.Common.AddEventTypeAvro("AvroTwo", new ConfigurationCommonEventTypeAvro(avroOneAndTwoSchema)); ConfigurationCommonEventTypeBean legacySupportBeanString = new ConfigurationCommonEventTypeBean(); legacySupportBeanString.FactoryMethod = "GetInstance"; configuration.Common.AddEventType("SupportBeanString", typeof(SupportBeanString), legacySupportBeanString); ConfigurationCommonEventTypeBean legacySupportSensorEvent = new ConfigurationCommonEventTypeBean(); legacySupportSensorEvent.FactoryMethod = typeof(SupportSensorEventFactory).FullName + ".GetInstance"; configuration.Common.AddEventType("SupportSensorEvent", typeof(SupportSensorEvent), legacySupportSensorEvent); configuration.Common.AddImportType(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, object>)); 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)); configuration.Common.AddEventType("MyMap", mymapDef); IDictionary<string, object> defMap = new Dictionary<string, object>(); defMap.Put("intVal", typeof(int)); defMap.Put("stringVal", typeof(string)); defMap.Put("doubleVal", typeof(double?)); defMap.Put("nullVal", null); configuration.Common.AddEventType("MyMapType", defMap); string[] propsMyOAType = new string[] {"intVal", "stringVal", "doubleVal", "nullVal"}; object[] typesMyOAType = new object[] {typeof(int), typeof(string), typeof(double?), null}; configuration.Common.AddEventType("MyOAType", propsMyOAType, typesMyOAType); Schema schema = SchemaBuilder.Record( "MyAvroType", TypeBuilder.RequiredInt("intVal"), TypeBuilder.RequiredString("stringVal"), TypeBuilder.RequiredDouble("doubleVal"), TypeBuilder.Field("nullVal", TypeBuilder.NullType())); configuration.Common.AddEventTypeAvro("MyAvroType", new ConfigurationCommonEventTypeAvro(schema)); ConfigurationCommonEventTypeXMLDOM xml = new ConfigurationCommonEventTypeXMLDOM(); xml.RootElementName = "abc"; configuration.Common.AddEventType("xmltype", xml); IDictionary<string, object> mapDef = new Dictionary<string, object>(); mapDef.Put("IntPrimitive", typeof(int)); mapDef.Put("LongBoxed", typeof(long?)); mapDef.Put("TheString", typeof(string)); mapDef.Put("BoolPrimitive", typeof(bool?)); configuration.Common.AddEventType("MySupportMap", mapDef); IDictionary<string, object> type = MakeMap( new object[][] { new object[] {"Id", typeof(string)} }); configuration.Common.AddEventType("AEventMap", type); configuration.Common.AddEventType("BEventMap", type); IDictionary<string, object> metadata = MakeMap( new object[][] {new object[] {"Id", typeof(string)}}); configuration.Common.AddEventType("AEventTE", metadata); configuration.Common.AddEventType("BEventTE", metadata); configuration.Common.AddImportType(typeof(SupportStaticMethodLib)); configuration.Common.AddImportNamespace(typeof(EPLInsertIntoPopulateUnderlying)); IDictionary<string, object> complexMapMetadata = MakeMap( new object[][] { new object[] { "Nested", MakeMap( new object[][] { new object[] {"NestedValue", typeof(string)} }) } }); configuration.Common.AddEventType("ComplexMap", complexMapMetadata); configuration.Compiler.ByteCode.AllowSubscriber = true; configuration.Compiler.AddPlugInSingleRowFunction("generateMap", typeof(EPLInsertIntoTransposeStream), "LocalGenerateMap"); configuration.Compiler.AddPlugInSingleRowFunction("generateOA", typeof(EPLInsertIntoTransposeStream), "LocalGenerateOA"); configuration.Compiler.AddPlugInSingleRowFunction("generateAvro", typeof(EPLInsertIntoTransposeStream), "LocalGenerateAvro"); configuration.Compiler.AddPlugInSingleRowFunction("generateJson", typeof(EPLInsertIntoTransposeStream), "LocalGenerateJson"); configuration.Compiler.AddPlugInSingleRowFunction("custom", typeof(SupportStaticMethodLib), "MakeSupportBean"); configuration.Compiler.AddPlugInSingleRowFunction("customOne", typeof(SupportStaticMethodLib), "MakeSupportBean"); configuration.Compiler.AddPlugInSingleRowFunction("customTwo", typeof(SupportStaticMethodLib), "MakeSupportBeanNumeric"); }
public void TestConfigurationDefaults() { var config = new Configuration(container); var common = config.Common; Assert.AreEqual(PropertyResolutionStyle.CASE_SENSITIVE, common.EventMeta.ClassPropertyResolutionStyle); Assert.AreEqual(AccessorStyle.NATIVE, common.EventMeta.DefaultAccessorStyle); Assert.AreEqual(EventUnderlyingType.MAP, common.EventMeta.DefaultEventRepresentation); Assert.IsTrue(common.EventMeta.AvroSettings.IsEnableAvro); Assert.IsTrue(common.EventMeta.AvroSettings.IsEnableNativeString); Assert.IsTrue(common.EventMeta.AvroSettings.IsEnableSchemaDefaultNonNull); Assert.IsNull(common.EventMeta.AvroSettings.ObjectValueTypeWidenerFactoryClass); Assert.IsNull(common.EventMeta.AvroSettings.TypeRepresentationMapperClass); Assert.IsFalse(common.Logging.IsEnableQueryPlan); Assert.IsFalse(common.Logging.IsEnableADO); Assert.AreEqual(TimeUnit.MILLISECONDS, common.TimeSource.TimeUnit); Assert.AreEqual(ThreadingProfile.NORMAL, common.Execution.ThreadingProfile); var compiler = config.Compiler; Assert.IsFalse(compiler.ViewResources.IsIterableUnbound); Assert.IsTrue(compiler.ViewResources.IsOutputLimitOpt); Assert.IsFalse(compiler.Logging.IsEnableCode); Assert.AreEqual(16, compiler.Execution.FilterServiceMaxFilterWidth); Assert.IsTrue(compiler.Execution.IsEnabledDeclaredExprValueCache); var byteCode = compiler.ByteCode; Assert.IsFalse(byteCode.IsIncludeComments); Assert.IsFalse(byteCode.IsIncludeDebugSymbols); Assert.IsTrue(byteCode.IsAttachEPL); Assert.IsFalse(byteCode.IsAttachModuleEPL); Assert.IsFalse(byteCode.IsInstrumented); Assert.IsFalse(byteCode.IsAllowSubscriber); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierContext); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierEventType); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierExpression); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierNamedWindow); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierScript); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierTable); Assert.AreEqual(NameAccessModifier.PRIVATE, byteCode.AccessModifierVariable); Assert.AreEqual(EventTypeBusModifier.NONBUS, byteCode.BusModifierEventType); Assert.AreEqual(StreamSelector.ISTREAM_ONLY, compiler.StreamSelection.DefaultStreamSelector); Assert.IsFalse(compiler.Language.IsSortUsingCollator); Assert.IsFalse(compiler.Expression.IsIntegerDivision); Assert.IsFalse(compiler.Expression.IsDivisionByZeroReturnsNull); Assert.IsTrue(compiler.Expression.IsUdfCache); Assert.IsTrue(compiler.Expression.IsExtendedAggregation); Assert.IsFalse(compiler.Expression.IsDuckTyping); Assert.IsNull(compiler.Expression.MathContext); Assert.AreEqual("js", compiler.Scripts.DefaultDialect); var runtime = config.Runtime; Assert.IsTrue(runtime.Threading.IsInsertIntoDispatchPreserveOrder); Assert.AreEqual(100, runtime.Threading.InsertIntoDispatchTimeout); Assert.IsTrue(runtime.Threading.IsListenerDispatchPreserveOrder); Assert.AreEqual(1000, runtime.Threading.ListenerDispatchTimeout); Assert.IsTrue(runtime.Threading.IsInternalTimerEnabled); Assert.AreEqual(100, runtime.Threading.InternalTimerMsecResolution); Assert.AreEqual(Locking.SPIN, runtime.Threading.InsertIntoDispatchLocking); Assert.AreEqual(Locking.SPIN, runtime.Threading.ListenerDispatchLocking); Assert.IsFalse(runtime.Threading.IsThreadPoolInbound); Assert.IsFalse(runtime.Threading.IsThreadPoolOutbound); Assert.IsFalse(runtime.Threading.IsThreadPoolRouteExec); Assert.IsFalse(runtime.Threading.IsThreadPoolTimerExec); Assert.AreEqual(2, runtime.Threading.ThreadPoolInboundNumThreads); Assert.AreEqual(2, runtime.Threading.ThreadPoolOutboundNumThreads); Assert.AreEqual(2, runtime.Threading.ThreadPoolRouteExecNumThreads); Assert.AreEqual(2, runtime.Threading.ThreadPoolTimerExecNumThreads); Assert.IsNull(runtime.Threading.ThreadPoolInboundCapacity); Assert.IsNull(runtime.Threading.ThreadPoolOutboundCapacity); Assert.IsNull(runtime.Threading.ThreadPoolRouteExecCapacity); Assert.IsNull(runtime.Threading.ThreadPoolTimerExecCapacity); Assert.IsFalse(runtime.Threading.IsRuntimeFairlock); Assert.IsFalse(runtime.MetricsReporting.IsRuntimeMetrics); Assert.IsTrue(runtime.Threading.IsNamedWindowConsumerDispatchPreserveOrder); Assert.AreEqual(Int32.MaxValue, runtime.Threading.NamedWindowConsumerDispatchTimeout); Assert.AreEqual(Locking.SPIN, runtime.Threading.NamedWindowConsumerDispatchLocking); Assert.IsFalse(runtime.Logging.IsEnableExecutionDebug); Assert.IsTrue(runtime.Logging.IsEnableTimerDebug); Assert.IsNull(runtime.Logging.AuditPattern); Assert.AreEqual(15000, runtime.Variables.MsecVersionRelease); Assert.IsNull(runtime.Patterns.MaxSubexpressions); Assert.IsTrue(runtime.Patterns.IsMaxSubexpressionPreventStart); Assert.IsNull(runtime.MatchRecognize.MaxStates); Assert.IsTrue(runtime.MatchRecognize.IsMaxStatesPreventStart); Assert.AreEqual(TimeSourceType.MILLI, runtime.TimeSource.TimeSourceType); Assert.IsFalse(runtime.Execution.IsPrioritized); Assert.IsFalse(runtime.Execution.IsDisableLocking); Assert.AreEqual(FilterServiceProfile.READMOSTLY, runtime.Execution.FilterServiceProfile); Assert.AreEqual(1, runtime.Execution.DeclaredExprValueCacheSize); Assert.IsTrue(runtime.Expression.IsSelfSubselectPreeval); Assert.AreEqual(TimeZoneInfo.Utc, runtime.Expression.TimeZone); Assert.IsNull(runtime.ExceptionHandling.HandlerFactories); Assert.AreEqual(UndeployRethrowPolicy.WARN, runtime.ExceptionHandling.UndeployRethrowPolicy); Assert.IsNull(runtime.ConditionHandling.HandlerFactories); var domType = new ConfigurationCommonEventTypeXMLDOM(); Assert.IsFalse(domType.IsXPathPropertyExpr); Assert.IsTrue(domType.IsXPathResolvePropertiesAbsolute); Assert.IsTrue(domType.IsEventSenderValidatesRoot); Assert.IsTrue(domType.IsAutoFragment); }
private static void Configure(Configuration configuration) { foreach (var clazz in new[] { typeof(SupportBean), typeof(SupportBeanComplexProps), typeof(SupportBeanWithEnum), typeof(SupportMarketDataBean), typeof(SupportMarkerInterface), typeof(SupportBean_A), typeof(SupportBean_B), typeof(SupportBean_C), typeof(SupportBean_D), typeof(SupportBean_S0) }) { configuration.Common.AddEventType(clazz); } configuration.Common.AddEventType( ClientRuntimeListener.MAP_TYPENAME, Collections.SingletonDataMap("Ident", "string")); configuration.Common.AddEventType( ClientRuntimeListener.OA_TYPENAME, new[] {"Ident"}, new[] {typeof(string)}); configuration.Common.AddEventType( ClientRuntimeListener.BEAN_TYPENAME, typeof(ClientRuntimeListener.RoutedBeanEvent)); configuration.Common.AddImportNamespace(typeof(MyAnnotationNestedAttribute)); var eventTypeMeta = new ConfigurationCommonEventTypeXMLDOM(); eventTypeMeta.RootElementName = "Myevent"; var schema = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xs:schema targetNamespace=\"http://www.espertech.com/schema/esper\" elementFormDefault=\"qualified\" xmlns:esper=\"http://www.espertech.com/schema/esper\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + "\t<xs:element name=\"Myevent\">\n" + "\t\t<xs:complexType>\n" + "\t\t\t<xs:attribute name=\"Ident\" type=\"xs:string\" use=\"required\"/>\n" + "\t\t</xs:complexType>\n" + "\t</xs:element>\n" + "</xs:schema>\n"; eventTypeMeta.SchemaText = schema; configuration.Common.AddEventType(ClientRuntimeListener.XML_TYPENAME, eventTypeMeta); Schema avroSchema = SchemaBuilder.Record( EventInfraPropertyUnderlyingSimple.AVRO_TYPENAME, TypeBuilder.Field( "Ident", TypeBuilder.StringType( TypeBuilder.Property(PROP_STRING_KEY, PROP_STRING_VALUE)))); configuration.Common.AddEventTypeAvro( ClientRuntimeListener.AVRO_TYPENAME, new ConfigurationCommonEventTypeAvro(avroSchema)); configuration.Common.AddImportType(typeof(MyAnnotationValueEnumAttribute)); configuration.Common.AddImportNamespace(typeof(MyAnnotationNestableValuesAttribute)); configuration.Common.AddAnnotationImportType(typeof(SupportEnum)); configuration.Compiler.AddPlugInAggregationFunctionForge( "myinvalidagg", typeof(SupportInvalidAggregationFunctionForge)); // add service (not serializable, transient configuration) var transients = new Dictionary<string, object>(); transients.Put( ClientRuntimeItself.TEST_SERVICE_NAME, new ClientRuntimeItself.MyLocalService(ClientRuntimeItself.TEST_SECRET_VALUE)); configuration.Common.TransientConfiguration = transients; configuration.Compiler.ByteCode.AllowSubscriber = true; configuration.Runtime.Execution.IsPrioritized = true; }
public static ConfigurationCommonEventTypeXMLDOM Configure( StatementBaseInfo @base, StatementCompileTimeServices services) { var config = new ConfigurationCommonEventTypeXMLDOM(); var annotations = @base.StatementRawInfo.Annotations; var schemaAnnotations = AnnotationUtil.FindAnnotations(annotations, typeof(XMLSchemaAttribute)); if (schemaAnnotations == null || schemaAnnotations.IsEmpty()) { throw new ExprValidationException("Required annotation @" + nameof(XMLSchemaAttribute) + " could not be found"); } if (schemaAnnotations.Count > 1) { throw new ExprValidationException("Found multiple @" + nameof(XMLSchemaAttribute) + " annotations but expected a single annotation"); } var schema = (XMLSchemaAttribute)schemaAnnotations[0]; if (string.IsNullOrEmpty(schema.RootElementName)) { throw new ExprValidationException( "Required annotation field 'RootElementName' for annotation @" + nameof(XMLSchemaAttribute) + " could not be found"); } config.RootElementName = schema.RootElementName.Trim(); config.SchemaResource = NullIfEmpty(schema.SchemaResource); config.SchemaText = NullIfEmpty(schema.SchemaText); config.IsXPathPropertyExpr = schema.XPathPropertyExpr; config.DefaultNamespace = schema.DefaultNamespace; config.IsEventSenderValidatesRoot = schema.EventSenderValidatesRoot; config.IsAutoFragment = schema.AutoFragment; config.XPathFunctionResolver = NullIfEmpty(schema.XPathFunctionResolver); config.XPathVariableResolver = NullIfEmpty(schema.XPathVariableResolver); config.IsXPathResolvePropertiesAbsolute = schema.XPathResolvePropertiesAbsolute; config.RootElementNamespace = NullIfEmpty(schema.RootElementNamespace); var prefixes = AnnotationUtil.FindAnnotations(annotations, typeof(XMLSchemaNamespacePrefixAttribute)); foreach (var prefixAnnotation in prefixes) { var prefix = (XMLSchemaNamespacePrefixAttribute)prefixAnnotation; config.AddNamespacePrefix(prefix.Prefix, prefix.Namespace); } var fields = AnnotationUtil.FindAnnotations(annotations, typeof(XMLSchemaFieldAttribute)); foreach (var fieldAnnotation in fields) { var field = (XMLSchemaFieldAttribute)fieldAnnotation; var rtype = GetResultType(field.Type); if (string.IsNullOrWhiteSpace(field.EventTypeName)) { var castToType = NullIfEmpty(field.CastToType); config.AddXPathProperty(field.Name, field.XPath, rtype, castToType); } else { config.AddXPathPropertyFragment(field.Name, field.XPath, rtype, field.EventTypeName); } } return(config); }
private static void Configure(Configuration configuration) { foreach (var clazz in new Type[] { typeof(SupportBean), typeof(OrderBean), typeof(BookDesc), typeof(SentenceEvent), typeof(SupportStringBeanWithArray), typeof(SupportBeanArrayCollMap), typeof(SupportObjectArrayEvent), typeof(SupportCollectionEvent), typeof(SupportResponseEvent), typeof(SupportAvroArrayEvent), typeof(SupportJsonArrayEvent) }) { configuration.Common.AddEventType(clazz); } var innerMapDef = Collections.SingletonDataMap("p", typeof(string)); configuration.Common.AddEventType("MyInnerMap", innerMapDef); var outerMapDef = Collections.SingletonDataMap("i", "MyInnerMap[]"); configuration.Common.AddEventType("MyOuterMap", outerMapDef); var funcs = new [] { "SplitSentence","SplitSentenceBean","SplitWord" }; for (var i = 0; i < funcs.Length; i++) { foreach (var rep in EventRepresentationChoiceExtensions.Values()) { string[] methods; if (rep.IsObjectArrayEvent()) { methods = new string[] { "SplitSentenceMethodReturnObjectArray", "SplitSentenceBeanMethodReturnObjectArray", "SplitWordMethodReturnObjectArray" }; } else if (rep.IsMapEvent()) { methods = new string[] { "SplitSentenceMethodReturnMap", "SplitSentenceBeanMethodReturnMap", "SplitWordMethodReturnMap" }; } else if (rep.IsAvroEvent()) { methods = new string[] { "SplitSentenceMethodReturnAvro", "SplitSentenceBeanMethodReturnAvro", "SplitWordMethodReturnAvro" }; } else if (rep.IsJsonEvent() || rep.IsJsonProvidedClassEvent()) { methods = new string[] { "SplitSentenceMethodReturnJson", "SplitSentenceBeanMethodReturnJson", "SplitWordMethodReturnJson" }; } else { throw new IllegalStateException("Unrecognized enum " + rep); } configuration.Compiler.AddPlugInSingleRowFunction( funcs[i] + "_" + rep.GetName(), typeof(EPLContainedEventSplitExpr), methods[i]); } } var config = new ConfigurationCommonEventTypeXMLDOM(); var resourceManager = configuration.ResourceManager; config.SchemaResource = resourceManager.ResolveResourceURL("regression/mediaOrderSchema.xsd").ToString(); config.RootElementName = "MediaOrder"; configuration.Common.AddEventType("MediaOrder", config); configuration.Common.AddEventType("Cancel", config); configuration.Compiler.ByteCode.AllowSubscriber = true; configuration.Compiler.AddPlugInSingleRowFunction( "invalidSentence", typeof(EPLContainedEventSplitExpr), "InvalidSentenceMethod"); configuration.Compiler.AddPlugInSingleRowFunction( "mySplitUDFReturnEventBeanArray", typeof(EPLContainedEventSplitExpr), "MySplitUDFReturnEventBeanArray"); }
public EventType GetCreateXMLDOMType( string rootTypeName, string derivedEventTypeName, string moduleName, SchemaElementComplex complex, string representsFragmentOfProperty) { if (rootTypes == null) { rootTypes = new Dictionary<string, SchemaXMLEventType>(); } if (derivedTypes == null) { derivedTypes = new Dictionary<string, SchemaXMLEventType>(); } var type = rootTypes.Get(rootTypeName); if (type == null) { throw new IllegalStateException("Failed to find XML root event type '" + rootTypeName + "'"); } var config = type.ConfigurationEventTypeXMLDOM; // add a new type var xmlDom = new ConfigurationCommonEventTypeXMLDOM(); xmlDom.RootElementName = "//" + complex.Name; // such the reload of the type can resolve it xmlDom.RootElementNamespace = complex.Namespace; xmlDom.IsAutoFragment = config.IsAutoFragment; xmlDom.IsEventSenderValidatesRoot = config.IsEventSenderValidatesRoot; xmlDom.IsXPathPropertyExpr = config.IsXPathPropertyExpr; xmlDom.IsXPathResolvePropertiesAbsolute = config.IsXPathResolvePropertiesAbsolute; xmlDom.SchemaResource = config.SchemaResource; xmlDom.SchemaText = config.SchemaText; xmlDom.XPathFunctionResolver = config.XPathFunctionResolver; xmlDom.XPathVariableResolver = config.XPathVariableResolver; xmlDom.DefaultNamespace = config.DefaultNamespace; xmlDom.AddNamespacePrefixes(config.NamespacePrefixes); var metadata = new EventTypeMetadata( derivedEventTypeName, moduleName, EventTypeTypeClass.STREAM, EventTypeApplicationType.XML, NameAccessModifier.PRECONFIGURED, EventTypeBusModifier.BUS, false, new EventTypeIdPair(CRC32Util.ComputeCRC32(derivedEventTypeName), -1)); var eventType = (SchemaXMLEventType) eventTypeFactory.EventTypeFactory.CreateXMLType( metadata, xmlDom, type.SchemaModel, representsFragmentOfProperty, rootTypeName, eventTypeFactory, this, eventTypeNameResolver); derivedTypes.Put(derivedEventTypeName, eventType); optionalCompileTimeRegistry?.NewType(eventType); return eventType; }
private static void Configure(Configuration configuration) { configuration.Compiler.ViewResources.IsIterableUnbound = true; configuration.Common.AddVariable("var", typeof(int), 0); foreach (var clazz in new[] {typeof(SupportBean)}) { configuration.Common.AddEventType(clazz); } var resourceManager = configuration.Container.ResourceManager(); string schemaUriSimpleSchema = resourceManager .ResolveResourceURL("regression/simpleSchema.xsd") .ToString(); string schemaUriTypeTestSchema = resourceManager .ResolveResourceURL("regression/typeTestSchema.xsd") .ToString(); string schemaUriSimpleSchemaWithAll = resourceManager .ResolveResourceURL("regression/simpleSchemaWithAll.xsd") .ToString(); string schemaUriSensorEvent = resourceManager .ResolveResourceURL("regression/sensorSchema.xsd") .ToString(); var schemaStream = resourceManager .GetResourceAsStream("regression/simpleSchemaWithRestriction.xsd"); var schemaReader = new StreamReader(schemaStream); Assert.IsNotNull(schemaStream); var schemaTextSimpleSchemaWithRestriction = FileUtil.LinesToText( FileUtil.ReadFile(schemaReader)); var aEventConfig = new ConfigurationCommonEventTypeXMLDOM(); aEventConfig.RootElementName = "myroot"; configuration.Common.AddEventType("AEvent", aEventConfig); var aEventWithXPath = new ConfigurationCommonEventTypeXMLDOM(); aEventWithXPath.RootElementName = "a"; aEventWithXPath.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.Common.AddEventType("AEventWithXPath", aEventWithXPath); var aEventMoreXPath = new ConfigurationCommonEventTypeXMLDOM(); aEventMoreXPath.RootElementName = "a"; aEventMoreXPath.IsXPathPropertyExpr = true; aEventMoreXPath.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.Common.AddEventType("AEventMoreXPath", aEventMoreXPath); var desc = new ConfigurationCommonEventTypeXMLDOM(); desc.AddXPathProperty("event.type", "//event/@type", XPathResultType.String); desc.AddXPathProperty("event.uid", "//event/@uid", XPathResultType.String); desc.RootElementName = "batch-event"; configuration.Common.AddEventType("MyEvent", desc); var myEventSimpleEvent = new ConfigurationCommonEventTypeXMLDOM(); myEventSimpleEvent.RootElementName = "simpleEvent"; configuration.Common.AddEventType("MyEventSimpleEvent", myEventSimpleEvent); var mwEventWXPathExprTrue = new ConfigurationCommonEventTypeXMLDOM(); mwEventWXPathExprTrue.RootElementName = "simpleEvent"; mwEventWXPathExprTrue.IsXPathPropertyExpr = true; configuration.Common.AddEventType("MyEventWXPathExprTrue", mwEventWXPathExprTrue); var eventTypeMeta = new ConfigurationCommonEventTypeXMLDOM(); eventTypeMeta.RootElementName = "simpleEvent"; configuration.Common.AddEventType("TestXMLJustRootElementType", eventTypeMeta); var rootMeta = new ConfigurationCommonEventTypeXMLDOM(); rootMeta.RootElementName = "simpleEvent"; rootMeta.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); rootMeta.AddXPathPropertyFragment( "nested1simple", "/ss:simpleEvent/ss:nested1", XPathResultType.Any, "MyNestedEvent"); rootMeta.AddXPathPropertyFragment( "nested4array", "//ss:nested4", XPathResultType.NodeSet, "MyNestedArrayEvent"); configuration.Common.AddEventType("MyXMLEvent", rootMeta); var metaNested = new ConfigurationCommonEventTypeXMLDOM(); metaNested.RootElementName = "nested1"; configuration.Common.AddEventType("MyNestedEvent", metaNested); var metaNestedArray = new ConfigurationCommonEventTypeXMLDOM(); metaNestedArray.RootElementName = "nested4"; configuration.Common.AddEventType("MyNestedArrayEvent", metaNestedArray); var testXMLSchemaTypeWithSS = new ConfigurationCommonEventTypeXMLDOM(); testXMLSchemaTypeWithSS.RootElementName = "simpleEvent"; testXMLSchemaTypeWithSS.SchemaResource = schemaUriSimpleSchema; testXMLSchemaTypeWithSS.IsXPathPropertyExpr = true; // <== note this testXMLSchemaTypeWithSS.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); configuration.Common.AddEventType("TestXMLSchemaTypeWithSS", testXMLSchemaTypeWithSS); var myEventWTypeAndUID = new ConfigurationCommonEventTypeXMLDOM(); myEventWTypeAndUID.AddXPathProperty("event.type", "/event/@type", XPathResultType.String); myEventWTypeAndUID.AddXPathProperty("event.uid", "/event/@uid", XPathResultType.String); myEventWTypeAndUID.RootElementName = "event"; configuration.Common.AddEventType("MyEventWTypeAndUID", myEventWTypeAndUID); var stockQuote = new ConfigurationCommonEventTypeXMLDOM(); stockQuote.AddXPathProperty("symbol_a", "//m0:symbol", XPathResultType.String); stockQuote.AddXPathProperty( "symbol_b", "//*[local-name(.) = 'getQuote' and namespace-uri(.) = 'http://services.samples/xsd']", XPathResultType.String); stockQuote.AddXPathProperty("symbol_c", "/m0:getQuote/m0:request/m0:symbol", XPathResultType.String); stockQuote.RootElementName = "getQuote"; stockQuote.DefaultNamespace = "http://services.samples/xsd"; stockQuote.RootElementNamespace = "http://services.samples/xsd"; stockQuote.AddNamespacePrefix("m0", "http://services.samples/xsd"); stockQuote.IsXPathResolvePropertiesAbsolute = true; stockQuote.IsXPathPropertyExpr = true; configuration.Common.AddEventType("StockQuote", stockQuote); var stockQuoteSimpleConfig = new ConfigurationCommonEventTypeXMLDOM(); stockQuoteSimpleConfig.RootElementName = "getQuote"; stockQuoteSimpleConfig.DefaultNamespace = "http://services.samples/xsd"; stockQuoteSimpleConfig.RootElementNamespace = "http://services.samples/xsd"; stockQuoteSimpleConfig.AddNamespacePrefix("m0", "http://services.samples/xsd"); stockQuoteSimpleConfig.IsXPathResolvePropertiesAbsolute = false; stockQuoteSimpleConfig.IsXPathPropertyExpr = true; configuration.Common.AddEventType("StockQuoteSimpleConfig", stockQuoteSimpleConfig); var testXMLNoSchemaType = new ConfigurationCommonEventTypeXMLDOM(); testXMLNoSchemaType.RootElementName = "myevent"; testXMLNoSchemaType.IsXPathPropertyExpr = false; // <== DOM getter configuration.Common.AddEventType("TestXMLNoSchemaType", testXMLNoSchemaType); var testXMLNoSchemaTypeWXPathPropTrue = new ConfigurationCommonEventTypeXMLDOM(); testXMLNoSchemaTypeWXPathPropTrue.RootElementName = "myevent"; testXMLNoSchemaTypeWXPathPropTrue.IsXPathPropertyExpr = true; // <== XPath getter configuration.Common.AddEventType("TestXMLNoSchemaTypeWXPathPropTrue", testXMLNoSchemaTypeWXPathPropTrue); var xmlDOMEventTypeDesc = new ConfigurationCommonEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "myevent"; xmlDOMEventTypeDesc.AddXPathProperty("xpathElement1", "/myevent/element1", XPathResultType.String); xmlDOMEventTypeDesc.AddXPathProperty( "xpathCountE21", "count(/myevent/element2/element21)", XPathResultType.Number); xmlDOMEventTypeDesc.AddXPathProperty( "xpathAttrString", "/myevent/element3/@attrString", XPathResultType.String); xmlDOMEventTypeDesc.AddXPathProperty("xpathAttrNum", "/myevent/element3/@attrNum", XPathResultType.Number); xmlDOMEventTypeDesc.AddXPathProperty( "xpathAttrBool", "/myevent/element3/@attrBool", XPathResultType.Boolean); xmlDOMEventTypeDesc.AddXPathProperty( "stringCastLong", "/myevent/element3/@attrNum", XPathResultType.String, "long"); xmlDOMEventTypeDesc.AddXPathProperty( "stringCastDouble", "/myevent/element3/@attrNum", XPathResultType.String, "double"); xmlDOMEventTypeDesc.AddXPathProperty( "numCastInt", "/myevent/element3/@attrNum", XPathResultType.Number, "int"); xmlDOMEventTypeDesc.XPathFunctionResolver = typeof(SupportXPathFunctionResolver).FullName; xmlDOMEventTypeDesc.XPathVariableResolver = typeof(SupportXPathVariableResolver).FullName; configuration.Common.AddEventType("TestXMLNoSchemaTypeWMoreXPath", xmlDOMEventTypeDesc); xmlDOMEventTypeDesc = new ConfigurationCommonEventTypeXMLDOM(); xmlDOMEventTypeDesc.RootElementName = "my.event2"; configuration.Common.AddEventType("TestXMLWithDots", xmlDOMEventTypeDesc); var testXMLNoSchemaTypeWNum = new ConfigurationCommonEventTypeXMLDOM(); testXMLNoSchemaTypeWNum.RootElementName = "myevent"; testXMLNoSchemaTypeWNum.AddXPathProperty( "xpathAttrNum", "/myevent/@attrnum", XPathResultType.String, "long"); testXMLNoSchemaTypeWNum.AddXPathProperty( "xpathAttrNumTwo", "/myevent/@attrnumtwo", XPathResultType.String, "long"); configuration.Common.AddEventType("TestXMLNoSchemaTypeWNum", testXMLNoSchemaTypeWNum); var @event = new ConfigurationCommonEventTypeXMLDOM(); @event.RootElementName = "Event"; @event.AddXPathProperty("A", "//Field[@Name='A']/@Value", XPathResultType.NodeSet, "String[]"); configuration.Common.AddEventType("Event", @event); configuration.Common.AddEventType( "XMLSchemaConfigOne", GetConfigTestType(null, true, schemaUriSimpleSchema)); configuration.Common.AddEventType( "XMLSchemaConfigTwo", GetConfigTestType(null, false, schemaUriSimpleSchema)); var typecfg = new ConfigurationCommonEventTypeXMLDOM(); typecfg.RootElementName = "Sensor"; typecfg.SchemaResource = schemaUriSensorEvent; configuration.Common.AddEventType("SensorEvent", typecfg); var sensorcfg = new ConfigurationCommonEventTypeXMLDOM(); sensorcfg.RootElementName = "Sensor"; sensorcfg.AddXPathProperty("countTags", "count(/ss:Sensor/ss:Observation/ss:Tag)", XPathResultType.Number); sensorcfg.AddXPathProperty("countTagsInt", "count(/ss:Sensor/ss:Observation/ss:Tag)", XPathResultType.Number, "int"); sensorcfg.AddNamespacePrefix("ss", "SensorSchema"); sensorcfg.AddXPathProperty("idarray", "//ss:Tag/ss:ID", XPathResultType.NodeSet, "String[]"); sensorcfg.AddXPathPropertyFragment("tagArray", "//ss:Tag", XPathResultType.NodeSet, "TagEvent"); sensorcfg.AddXPathPropertyFragment("tagOne", "//ss:Tag[position() = 1]", XPathResultType.Any, "TagEvent"); sensorcfg.SchemaResource = schemaUriSensorEvent; configuration.Common.AddEventType("SensorEventWithXPath", sensorcfg); var tagcfg = new ConfigurationCommonEventTypeXMLDOM(); tagcfg.RootElementName = "//Tag"; tagcfg.SchemaResource = schemaUriSensorEvent; configuration.Common.AddEventType("TagEvent", tagcfg); var eventABC = new ConfigurationCommonEventTypeXMLDOM(); eventABC.RootElementName = "a"; eventABC.AddXPathProperty("element1", "/a/b/c", XPathResultType.String); configuration.Common.AddEventType("EventABC", eventABC); var bEvent = new ConfigurationCommonEventTypeXMLDOM(); bEvent.RootElementName = "a"; bEvent.AddXPathProperty("element2", "//c", XPathResultType.String); bEvent.IsEventSenderValidatesRoot = false; configuration.Common.AddEventType("BEvent", bEvent); var simpleEventWSchema = new ConfigurationCommonEventTypeXMLDOM(); simpleEventWSchema.RootElementName = "simpleEvent"; simpleEventWSchema.SchemaResource = schemaUriSimpleSchema; configuration.Common.AddEventType("SimpleEventWSchema", simpleEventWSchema); var abcType = new ConfigurationCommonEventTypeXMLDOM(); abcType.RootElementName = "simpleEvent"; abcType.SchemaResource = schemaUriSimpleSchema; configuration.Common.AddEventType("ABCType", abcType); var testNested2 = new ConfigurationCommonEventTypeXMLDOM(); testNested2.RootElementName = "//nested2"; testNested2.SchemaResource = schemaUriSimpleSchema; testNested2.IsEventSenderValidatesRoot = false; configuration.Common.AddEventType("TestNested2", testNested2); var myXMLEventXPC = new ConfigurationCommonEventTypeXMLDOM(); myXMLEventXPC.RootElementName = "simpleEvent"; myXMLEventXPC.SchemaResource = schemaUriSimpleSchema; myXMLEventXPC.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); myXMLEventXPC.AddXPathPropertyFragment( "nested1simple", "/ss:simpleEvent/ss:nested1", XPathResultType.Any, "MyNestedEventXPC"); myXMLEventXPC.AddXPathPropertyFragment( "nested4array", "//ss:nested4", XPathResultType.NodeSet, "MyNestedArrayEventXPC"); myXMLEventXPC.IsAutoFragment = false; configuration.Common.AddEventType("MyXMLEventXPC", myXMLEventXPC); var myNestedEventXPC = new ConfigurationCommonEventTypeXMLDOM(); myNestedEventXPC.RootElementName = "//nested1"; myNestedEventXPC.SchemaResource = schemaUriSimpleSchema; myNestedEventXPC.IsAutoFragment = false; configuration.Common.AddEventType("MyNestedEventXPC", myNestedEventXPC); var myNestedArrayEventXPC = new ConfigurationCommonEventTypeXMLDOM(); myNestedArrayEventXPC.RootElementName = "//nested4"; myNestedArrayEventXPC.SchemaResource = schemaUriSimpleSchema; configuration.Common.AddEventType("MyNestedArrayEventXPC", myNestedArrayEventXPC); var testTypesEvent = new ConfigurationCommonEventTypeXMLDOM(); testTypesEvent.RootElementName = "typesEvent"; testTypesEvent.SchemaResource = schemaUriTypeTestSchema; configuration.Common.AddEventType("TestTypesEvent", testTypesEvent); var myEventWithPrefix = new ConfigurationCommonEventTypeXMLDOM(); myEventWithPrefix.RootElementName = "simpleEvent"; myEventWithPrefix.SchemaResource = schemaUriSimpleSchema; myEventWithPrefix.IsXPathPropertyExpr = false; myEventWithPrefix.IsEventSenderValidatesRoot = false; myEventWithPrefix.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); myEventWithPrefix.DefaultNamespace = "samples:schemas:simpleSchema"; configuration.Common.AddEventType("MyEventWithPrefix", myEventWithPrefix); var myEventWithXPath = new ConfigurationCommonEventTypeXMLDOM(); myEventWithXPath.RootElementName = "simpleEvent"; myEventWithXPath.SchemaResource = schemaUriSimpleSchema; myEventWithXPath.IsXPathPropertyExpr = true; myEventWithXPath.IsEventSenderValidatesRoot = false; myEventWithXPath.AddNamespacePrefix("ss", "samples:schemas:simpleSchema"); myEventWithXPath.DefaultNamespace = "samples:schemas:simpleSchema"; configuration.Common.AddEventType("MyEventWithXPath", myEventWithXPath); var pageVisitEvent = new ConfigurationCommonEventTypeXMLDOM(); pageVisitEvent.RootElementName = "event-page-visit"; pageVisitEvent.SchemaResource = schemaUriSimpleSchemaWithAll; pageVisitEvent.AddNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll"); pageVisitEvent.AddXPathProperty("url", "/ss:event-page-visit/ss:url", XPathResultType.String); configuration.Common.AddEventType("PageVisitEvent", pageVisitEvent); var orderEvent = new ConfigurationCommonEventTypeXMLDOM(); orderEvent.RootElementName = "order"; orderEvent.SchemaText = schemaTextSimpleSchemaWithRestriction; configuration.Common.AddEventType("OrderEvent", orderEvent); }
public SchemaXMLEventType( EventTypeMetadata eventTypeMetadata, ConfigurationCommonEventTypeXMLDOM config, SchemaModel schemaModel, string representsFragmentOfProperty, string representsOriginalTypeName, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeNameResolver eventTypeResolver, XMLFragmentEventTypeFactory xmlEventTypeFactory) : base( eventTypeMetadata, config, eventBeanTypedEventFactory, eventTypeResolver, xmlEventTypeFactory) { propertyGetterCache = new Dictionary<string, EventPropertyGetterSPI>(); SchemaModel = schemaModel; rootElementNamespace = config.RootElementNamespace; schemaModelRoot = SchemaUtil.FindRootElement(schemaModel, rootElementNamespace, RootElementName); isPropertyExpressionXPath = config.IsXPathPropertyExpr; RepresentsFragmentOfProperty = representsFragmentOfProperty; RepresentsOriginalTypeName = representsOriginalTypeName; // Set of namespace context for XPath expressions var ctx = new XPathNamespaceContext(); if (config.DefaultNamespace != null) { ctx.SetDefaultNamespace(config.DefaultNamespace); } foreach (var entry in config.NamespacePrefixes) { ctx.AddNamespace(entry.Key, entry.Value); } NamespaceContext = ctx; // add properties for the root element IList<ExplicitPropertyDescriptor> additionalSchemaProps = new List<ExplicitPropertyDescriptor>(); // Add a property for each complex child element foreach (SchemaElementComplex complex in schemaModelRoot.ComplexElements) { var propertyName = complex.Name; var returnType = typeof(XmlNode); Type propertyComponentType = null; if (complex.OptionalSimpleType != null) { returnType = SchemaUtil.ToReturnType(complex); if (returnType == typeof(string)) { propertyComponentType = typeof(char); } } if (complex.IsArray) { returnType = typeof(XmlNode[]); // We use Node[] for arrays and NodeList for XPath-Expressions returning Nodeset propertyComponentType = typeof(XmlNode); } var isFragment = false; if (ConfigurationEventTypeXMLDOM.IsAutoFragment && !ConfigurationEventTypeXMLDOM.IsXPathPropertyExpr) { isFragment = CanFragment(complex); } var getter = DoResolvePropertyGetter(propertyName, true); var desc = new EventPropertyDescriptor( propertyName, returnType, propertyComponentType, false, false, complex.IsArray, false, isFragment); var @explicit = new ExplicitPropertyDescriptor(desc, getter, false, null); additionalSchemaProps.Add(@explicit); } // Add a property for each simple child element foreach (var simple in schemaModelRoot.SimpleElements) { var propertyName = simple.Name; var returnType = SchemaUtil.ToReturnType(simple); var componentType = GenericExtensions.GetComponentType(returnType); var isIndexed = simple.IsArray || componentType != null; var getter = DoResolvePropertyGetter(propertyName, true); var desc = new EventPropertyDescriptor( propertyName, returnType, componentType, false, false, isIndexed, false, false); var @explicit = new ExplicitPropertyDescriptor(desc, getter, false, null); additionalSchemaProps.Add(@explicit); } // Add a property for each attribute foreach (var attribute in schemaModelRoot.Attributes) { var propertyName = attribute.Name; var returnType = SchemaUtil.ToReturnType(attribute); var componentType = GenericExtensions.GetComponentType(returnType); var isIndexed = componentType != null; var getter = DoResolvePropertyGetter(propertyName, true); var desc = new EventPropertyDescriptor( propertyName, returnType, componentType, false, false, isIndexed, false, false); var @explicit = new ExplicitPropertyDescriptor(desc, getter, false, null); additionalSchemaProps.Add(@explicit); } // Finally add XPath properties as that may depend on the rootElementNamespace Initialize(config.XPathProperties.Values, additionalSchemaProps); }