public StmtClassForgeableAIFactoryProviderCreateContext( string className, CodegenNamespaceScope namespaceScope, string contextName, ContextControllerFactoryForge[] forges, EventType eventTypeContextProperties, StatementAgentInstanceFactoryCreateContextForge forge) : base(className, namespaceScope) { this.contextName = contextName; this.forges = forges; this.eventTypeContextProperties = eventTypeContextProperties; this.forge = forge; }
public StmtForgeMethodResult Make( string @namespace, string classPostfix, StatementCompileTimeServices services) { var statementSpec = @base.StatementSpec; if (statementSpec.Raw.OptionalContextName != null) { throw new ExprValidationException( "A create-context statement cannot itself be associated to a context, please declare a nested context instead"); } IList<FilterSpecCompiled> filterSpecCompileds = new List<FilterSpecCompiled>(); IList<ScheduleHandleCallbackProvider> scheduleHandleCallbackProviders = new List<ScheduleHandleCallbackProvider>(); IList<FilterSpecParamExprNodeForge> filterBooleanExpressions = new List<FilterSpecParamExprNodeForge>(); var context = statementSpec.Raw.CreateContextDesc; if (services.ContextCompileTimeResolver.GetContextInfo(context.ContextName) != null) { throw new ExprValidationException("Context by name '" + context.ContextName + "' already exists"); } // compile filter specs, if any var validationEnv = new CreateContextValidationEnv( context.ContextName, @base.StatementRawInfo, services, filterSpecCompileds, scheduleHandleCallbackProviders, filterBooleanExpressions); var additionalForgeables = ValidateContextDetail( context.ContextDetail, 0, validationEnv); // get controller factory forges var controllerFactoryForges = GetForges( context.ContextName, context.ContextDetail); // build context properties type information var contextProps = MakeContextProperties( controllerFactoryForges, @base.StatementRawInfo, services); // allocate type for context properties var contextEventTypeName = services.EventTypeNameGeneratorStatement.GetContextPropertyTypeName(context.ContextName); var metadata = new EventTypeMetadata( contextEventTypeName, @base.ModuleName, EventTypeTypeClass.CONTEXTPROPDERIVED, EventTypeApplicationType.MAP, NameAccessModifier.TRANSIENT, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); var contextPropertiesType = BaseNestableEventUtil.MakeMapTypeCompileTime( metadata, contextProps, null, null, null, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); services.EventTypeCompileTimeRegistry.NewType(contextPropertiesType); // register context var visibilityContext = services.ModuleVisibilityRules.GetAccessModifierContext(@base, context.ContextName); var validationInfo = new ContextControllerPortableInfo[controllerFactoryForges.Length]; for (var i = 0; i < validationInfo.Length; i++) { validationInfo[i] = controllerFactoryForges[i].ValidationInfo; } var detail = new ContextMetaData( context.ContextName, @base.ModuleName, visibilityContext, contextPropertiesType, validationInfo); services.ContextCompileTimeRegistry.NewContext(detail); // define output event type var statementEventTypeName = services.EventTypeNameGeneratorStatement.GetContextStatementTypeName(context.ContextName); var statementTypeMetadata = new EventTypeMetadata( statementEventTypeName, @base.ModuleName, EventTypeTypeClass.STATEMENTOUT, EventTypeApplicationType.MAP, NameAccessModifier.TRANSIENT, EventTypeBusModifier.NONBUS, false, EventTypeIdPair.Unassigned()); EventType statementEventType = BaseNestableEventUtil.MakeMapTypeCompileTime( statementTypeMetadata, EmptyDictionary<string, object>.Instance, null, null, null, null, services.BeanEventTypeFactoryPrivate, services.EventTypeCompileTimeResolver); services.EventTypeCompileTimeRegistry.NewType(statementEventType); var statementFieldsClassName = CodeGenerationIDGenerator .GenerateClassNameSimple(typeof(StatementFields), classPostfix); var namespaceScope = new CodegenNamespaceScope( @namespace, statementFieldsClassName, services.IsInstrumented); var forgeables = new List<StmtClassForgeable>(); foreach (var additional in additionalForgeables) { forgeables.Add(additional.Make(namespaceScope, classPostfix)); } var statementProviderClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementProvider), classPostfix); var statementAIFactoryProviderClassName = CodeGenerationIDGenerator.GenerateClassNameSimple(typeof(StatementAIFactoryProvider), classPostfix); var forge = new StatementAgentInstanceFactoryCreateContextForge(context.ContextName, statementEventType); forgeables.Add( new StmtClassForgeableAIFactoryProviderCreateContext( statementAIFactoryProviderClassName, namespaceScope, context.ContextName, controllerFactoryForges, contextPropertiesType, forge)); var selectSubscriberDescriptor = new SelectSubscriberDescriptor(); var informationals = StatementInformationalsUtil.GetInformationals( @base, filterSpecCompileds, scheduleHandleCallbackProviders, EmptyList<NamedWindowConsumerStreamSpec>.Instance, false, selectSubscriberDescriptor, namespaceScope, services); informationals.Properties.Put(StatementProperty.CREATEOBJECTNAME, context.ContextName); forgeables.Add( new StmtClassForgeableStmtProvider( statementAIFactoryProviderClassName, statementProviderClassName, informationals, namespaceScope)); forgeables.Add( new StmtClassForgeableStmtFields( statementFieldsClassName, namespaceScope, 0)); return new StmtForgeMethodResult( forgeables, filterSpecCompileds, scheduleHandleCallbackProviders, EmptyList<NamedWindowConsumerStreamSpec>.Instance, FilterSpecCompiled.MakeExprNodeList(filterSpecCompileds, filterBooleanExpressions)); }