AddPropertyReference() public method

Adds a reference to the specified object name under the property specified.
public AddPropertyReference ( string name, string objectName ) : ObjectDefinitionBuilder
name string The name.
objectName string Name of the object.
return ObjectDefinitionBuilder
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {

            builder.AddPropertyReference(TxNamespaceUtils.TRANSACTION_MANAGER_PROPERTY,
                GetAttributeValue(element, TxNamespaceUtils.TRANSACTION_MANAGER_ATTRIBUTE));
            XmlNodeList txAttributes = element.SelectNodes("*[local-name()='attributes' and namespace-uri()='" + element.NamespaceURI + "']");
            if (txAttributes.Count > 1 )
            {
                parserContext.ReaderContext.ReportException(element, "tx advice", "Element <attributes> is allowed at most once inside element <advice>");
            }
            else if (txAttributes.Count == 1)
            {
                //using xml defined source
                XmlElement attributeSourceElement = txAttributes[0] as XmlElement;
                AbstractObjectDefinition attributeSourceDefinition =
                    ParseAttributeSource(attributeSourceElement, parserContext);
                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE, attributeSourceDefinition);
            }
            else
            {
                //Assume attibutes source
                ObjectDefinitionBuilder txAttributeSourceBuilder = 
                    parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof (AttributesTransactionAttributeSource));

                builder.AddPropertyValue(TxNamespaceUtils.TRANSACTION_ATTRIBUTE_SOURCE,
                                         txAttributeSourceBuilder.ObjectDefinition);

            }
        }
        protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            base.DoParse(element, builder);

            //TODO investigate setting of scope on client cache
            //builder.AddPropertyValue("Scope", "some value");

            //TODO check if .NET client has any 'data policy' settings.

            ParsingUtils.SetPropertyValue(element, builder, "name", "name");
            ParsingUtils.SetPropertyValue(element, builder, "pool-name", "poolName");

            String cacheRef = element.GetAttribute("cache-ref");
            // add cache reference (fallback to default if nothing is specified)
            builder.AddPropertyReference("cache", (StringUtils.HasText(cacheRef) ? cacheRef : "gemfire-cache"));

            // client region attributes
            String regionAttributesRef = element.GetAttribute("attributes-ref");
            if (StringUtils.HasText(regionAttributesRef))
            {
                ObjectDefinitionBuilder attrBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(RegionAttributesFactoryObject));
                builder.AddPropertyReference("attributes", regionAttributesRef);
            }

            ManagedList interests = new ManagedList();
            XmlNodeList subElements = element.ChildNodes;
            for (int i = 0; i < subElements.Count; i++)
            {
                XmlNode subElement = subElements.Item(i);
                if (subElement.NodeType == XmlNodeType.Element)
                {
                    string name = subElement.LocalName;
                    if ("cache-listener".Equals(name))
                    {
                        builder.AddPropertyValue("cacheListeners", ParseCacheListener(parserContext, (XmlElement)subElement, builder));
                    }
                    else if ("regex-interest".Equals(name))
                    {
                        interests.Add(ParseRegexInterest(parserContext, (XmlElement)subElement));
                    }
                    else if ("key-interest".Equals(name))
                    {
                        interests.Add(ParseKeyInterest(parserContext, (XmlElement)subElement));
                    }
                    else if ("all-keys-interest".Equals(name))
                    {
                        interests.Add(ParseAllKeysInterest(parserContext, (XmlElement) subElement));
                    }

                }
            }

            if (subElements.Count > 0)
            {
                builder.AddPropertyValue("interests", interests);
            }
        }
        protected void DoParseInternal(XmlElement element, ObjectDefinitionBuilder builder)
        {
            builder.SetSingleton(false);
            string leftMenu = element.GetAttribute("menu");
            if(!string.IsNullOrEmpty(leftMenu)) builder.AddPropertyReference("Menu", leftMenu);
            string rightScreen = element.GetAttribute("screen");
            if(!string.IsNullOrEmpty(rightScreen)) builder.AddPropertyReference("MainScreen", rightScreen);
            foreach (XmlNode node in element.ChildNodes)
            {
                if (node is XmlComment) continue;

                switch (node.LocalName.ToLower())
                {
                    case "steps":
                        XmlNodeList steps = node.ChildNodes;
                        if (steps.Count > 0) // if flow is configured with a list of steps
                        {
                            IDictionary stepsDic = new System.Collections.Hashtable();
                            int count = 0;
                            foreach (XmlNode step in steps)
                            {
                                if(step is XmlComment) continue;
                                if (!step.LocalName.ToLower().Equals("step"))
                                {
                                    throw new Exception("Do not support node with name " + node.Name + " in config file.");
                                }
                                string key = "Step" + (++count).ToString();
                                stepsDic[key] = step.InnerText;
                            }

                            builder.AddPropertyValue("FlowSteps", stepsDic);
                        }
                        break;
                    case "session":
                        string sessionRefBeanName = node.InnerText;
                        if(!string.IsNullOrEmpty(sessionRefBeanName))
                        {
                            builder.AddDependsOn(sessionRefBeanName);
                            builder.AddPropertyReference("Session", sessionRefBeanName);
                        }

                        break;
                    case "menu":
                        string menuClassName = node.InnerText;
                        builder.AddPropertyValue("MenuClass", Type.GetType(menuClassName));
                        break;
                    case "screen":
                        string screenClassName = node.InnerText;
                        builder.AddPropertyValue("MainScreenClass", Type.GetType(screenClassName));
                        break;
                    default:
                        throw new Exception("Do not support node with name " + node.Name + " in config file.");
                        break;
                }
            }
        }
 /*override*/
 protected void PostProcess(ObjectDefinitionBuilder builder, XmlElement element)
 {
     string requestChannelRef = element.GetAttribute("request-channel");
     if(!StringUtils.HasText(requestChannelRef))
         throw new ArgumentException("a 'request-channel' reference is required");
     builder.AddPropertyReference("requestChannel", requestChannelRef);
     string replyChannel = element.GetAttribute("reply-channel");
     if(StringUtils.HasText(replyChannel)) {
         builder.AddPropertyReference("replyChannel", replyChannel);
     }
     DoPostProcess(builder, element);
 }
 protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
 {
     base.DoParse(element, builder);
     ParsingUtils.SetPropertyValue(element, builder, "name", "name");
     String attr = element.GetAttribute("cache-ref");
     // add cache reference (fallback to default if nothing is specified)
     builder.AddPropertyReference("cache", (StringUtils.HasText(attr) ? attr : "gemfire-cache"));
 }
 protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
 {
     string parentFlow = element.GetAttribute("parent");
     if (!string.IsNullOrEmpty(parentFlow))
     {
         builder.AddPropertyReference("ParentFlow", parentFlow);
     }
     DoParseInternal(element,builder);
 }
 protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder)
 {
     String taskExecutorRef = element.GetAttribute("task-executor");
     if(StringUtils.HasText(taskExecutorRef)) {
         builder.AddPropertyReference("taskExecutor", taskExecutorRef);
     }
     else {
         IExecutor taskExecutor = IntegrationContextUtils.CreateThreadPoolTaskExecutor(1, 10, 0, "event-multicaster-");
         builder.AddPropertyValue("taskExecutor", taskExecutor);
     }
     // TODO CopyOnWriteArraySet
     builder.AddPropertyValue("collectionClass", typeof (Set)); //CopyOnWriteArraySet));
 }
 /// <summary>
 /// Parse a "poller" element to provide a reference for the target
 /// ObjectDefinitionBuilder. If the poller element does not contain a "ref"
 /// attribute, this will create and register a PollerMetadata instance and
 /// then add it as a property reference of the target builder.
 /// </summary>
 /// <param name="pollerElement">the "poller" element to parse</param>
 /// <param name="targetBuilder">the builder that expects the "trigger" property</param>
 /// <param name="parserContext">the parserContext for the target builder</param>
 public static void ConfigurePollerMetadata(XmlElement pollerElement, ObjectDefinitionBuilder targetBuilder, ParserContext parserContext)
 {
     string pollerMetadataRef;
     if(pollerElement.HasAttribute("ref")) {
         if(pollerElement.Attributes.Count != 1) {
             parserContext.ReaderContext.ReportException(pollerElement, "poller", "A 'poller' element that provides a 'ref' must have no other attributes.");
         }
         if(pollerElement.ChildNodes.Count != 0) {
             parserContext.ReaderContext.ReportException(pollerElement, "poller", "A 'poller' element that provides a 'ref' must have no child elements.");
         }
         pollerMetadataRef = pollerElement.GetAttribute("ref");
     }
     else {
         IObjectDefinition pollerDef = parserContext.ParserHelper.ParseCustomElement(pollerElement, targetBuilder.ObjectDefinition);
         pollerMetadataRef = parserContext.ReaderContext.RegisterWithGeneratedName(pollerDef);
     }
     targetBuilder.AddPropertyReference("pollerMetadata", pollerMetadataRef);
 }
 /// <summary>
 /// Populates the specified object definition property with the reference
 /// to an object. The object reference is identified by the value from the
 /// attribute whose name is provided if that attribute is defined in
 /// the given element.
 /// </summary>
 /// <param name="builder">the builder</param>
 /// <param name="element">the XML element where the attribute should be defined</param>
 /// <param name="attributeName">the name of the attribute whose value will be used as a object reference to populate the property</param>
 /// <param name="propertyName">the name of the property to be populated</param>
 public static void SetReferenceIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName, string propertyName)
 {
     string attributeValue = element.GetAttribute(attributeName);
     if(StringUtils.HasText(attributeValue)) {
         builder.AddPropertyReference(propertyName, attributeValue);
     }
 }
 public static void SetPropertyReference(XmlElement element, ObjectDefinitionBuilder builder, string attrName,
     string propertyName)
 {
     string attr = element.GetAttribute(attrName);
     if (StringUtils.HasText(attr))
     {
         builder.AddPropertyReference(propertyName, attr);
     }
 }
 private static void ConfigureTrigger(XmlElement pollerElement, ObjectDefinitionBuilder targetBuilder, ParserContext parserContext)
 {
     string triggerBeanName;
     XmlElement intervalElement = DomUtils.GetChildElementByTagName(pollerElement, "interval-trigger");
     if(intervalElement != null) {
         triggerBeanName = ParseIntervalTrigger(intervalElement, parserContext);
     }
     else {
         XmlElement cronElement = DomUtils.GetChildElementByTagName(pollerElement, "cron-trigger");
         if(cronElement == null) {
             parserContext.ReaderContext.ReportException(pollerElement, pollerElement.Name, "A <poller> element must include either an <interval-trigger/> or <cron-trigger/> child element.");
         }
         triggerBeanName = ParseCronTrigger(cronElement, parserContext);
     }
     targetBuilder.AddPropertyReference("trigger", triggerBeanName);
 }
 /**
  * Parse a "transactional" element and configure the "transactionManager" and "transactionDefinition"
  * properties for the target builder.
  */
 private static void ConfigureTransactionAttributes(XmlElement txElement, ObjectDefinitionBuilder targetBuilder)
 {
     targetBuilder.AddPropertyReference("transactionManager", txElement.GetAttribute("transaction-manager"));
     DefaultTransactionDefinition txDefinition = new DefaultTransactionDefinition();
     txDefinition.PropagationBehavior = (TransactionPropagation)Enum.Parse(typeof(TransactionPropagation), txElement.GetAttribute("propagation"));
     txDefinition.TransactionIsolationLevel = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), txElement.GetAttribute("isolation"));
     txDefinition.TransactionTimeout = Convert.ToInt32(txElement.GetAttribute("timeout"));
     txDefinition.ReadOnly = txElement.GetAttribute("read-only").Equals("true", StringComparison.OrdinalIgnoreCase);
     targetBuilder.AddPropertyValue("transactionDefinition", txDefinition);
 }
        /// <summary>The parse destination.</summary>
        /// <param name="binding">The binding.</param>
        /// <param name="parserContext">The parser context.</param>
        /// <param name="builder">The builder.</param>
        protected void ParseDestination(XmlElement binding, ParserContext parserContext, ObjectDefinitionBuilder builder)
        {
            var queueAttribute = binding.GetAttribute(BINDING_QUEUE_ATTR);
            var exchangeAttribute = binding.GetAttribute(BINDING_EXCHANGE_ATTR);
            var hasQueueAttribute = !string.IsNullOrWhiteSpace(queueAttribute);
            var hasExchangeAttribute = !string.IsNullOrWhiteSpace(exchangeAttribute);
            if (!(hasQueueAttribute ^ hasExchangeAttribute))
            {
                parserContext.ReaderContext.ReportFatalException(binding, "Binding must have exactly one of 'queue' or 'exchange'");
            }

            if (hasQueueAttribute)
            {
                builder.AddPropertyReference("DestinationQueue", queueAttribute);
            }

            if (hasExchangeAttribute)
            {
                builder.AddPropertyReference("DestinationExchange", exchangeAttribute);
            }
        }
 protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder)
 {
     // this will never be null since the schema explicitly requires that a value be supplied
     string user = element.GetAttribute("user");
     builder.AddPropertyReference("User", user);
 }
        /// <summary>Sets the reference if attribute defined.</summary>
        /// <param name="builder">The builder.</param>
        /// <param name="element">The element.</param>
        /// <param name="attributeName">Name of the attribute.</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns><c>true</c> if [is attribute defined] [the specified element]; otherwise, <c>false</c>.</returns>
        public static bool SetReferenceIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName, string propertyName)
        {
            var attributeValue = element.GetAttribute(attributeName);
            if (!string.IsNullOrWhiteSpace(attributeValue))
            {
                builder.AddPropertyReference(propertyName, attributeValue);
                return true;
            }

            return false;
        }