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, ObjectDefinitionBuilder builder) { base.DoParse(element, builder); ParseSimpleProperties(element, builder); XmlNodeList subElements = element.ChildNodes; ManagedList locators = new ManagedList(subElements.Count); ManagedList servers = new ManagedList(subElements.Count); for (int i = 0; i < subElements.Count; i++) { XmlNode subElement = subElements.Item(i); if (subElement != null && subElement.NodeType == XmlNodeType.Element) { if ("locator".Equals(subElement.LocalName)) { locators.Add(ParseLocator((XmlElement)subElement)); } if ("server".Equals(subElement.LocalName)) { servers.Add(ParseServer((XmlElement)subElement)); } } } if (locators.Count > 0) { builder.AddPropertyValue("Locators", locators); } if (servers.Count > 0) { builder.AddPropertyValue("Servers", servers); } }
private void ParseTypeFilters(XmlElement element, ObjectDefinitionBuilder builder) { var includeTypeFilters = new List <ITypeFilter>(); var excludeTypeFilters = new List <ITypeFilter>(); foreach (XmlNode node in element.ChildNodes) { if (node.Name.Contains(ObjectNames.IncludeFilterElement)) { var typeFilter = CreateTypeFilter(node); if (typeFilter != null) { includeTypeFilters.Add(typeFilter); } } else if (node.Name.Contains(ObjectNames.ExcludeFilterElement)) { var typeFilter = CreateTypeFilter(node); if (typeFilter != null) { excludeTypeFilters.Add(typeFilter); } } } builder.AddPropertyValue(ConventionProfileFactory.IncludeFiltersProperty, includeTypeFilters); builder.AddPropertyValue(ConventionProfileFactory.ExcludeFiltersProperty, excludeTypeFilters); }
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); } }
private string ParseMessageListenerContainer(XmlElement element, ParserContext parserContext) { if (element.HasAttribute("container")) { foreach (string containerAttribute in containerAttributes) { if (element.HasAttribute(containerAttribute)) { parserContext.ReaderContext.ReportException(element, containerAttribute, "The '" + containerAttribute + "' attribute should not be provided when specifying a 'container' reference."); } } return(element.GetAttribute("container")); } ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(typeof(SimpleMessageListenerContainer)); string destinationAttribute = this.expectReply ? "request-destination" : "destination"; string destinationNameAttribute = this.expectReply ? "request-destination-name" : "destination-name"; string destination = element.GetAttribute(destinationAttribute); string destinationName = element.GetAttribute(destinationNameAttribute); if (!(StringUtils.HasText(destination) ^ StringUtils.HasText(destinationName))) { parserContext.ReaderContext.ReportException(element, "destination or destination-name", "Exactly one of '" + destinationAttribute + "' or '" + destinationNameAttribute + "' is required."); } builder.AddPropertyReference(NmsAdapterParserUtils.CONNECTION_FACTORY_PROPERTY, NmsAdapterParserUtils.DetermineConnectionFactoryBeanName(element, parserContext)); if (StringUtils.HasText(destination)) { builder.AddPropertyReference("destination", destination); } else { builder.AddPropertyValue("destinationName", destinationName); } AcknowledgementMode acknowledgementMode = NmsAdapterParserUtils.ParseAcknowledgementMode(element, parserContext); if (acknowledgementMode.Equals(AcknowledgementMode.Transactional)) { builder.AddPropertyValue("sessionTransacted", true); } else { builder.AddPropertyValue("sessionAcknowledgeMode", acknowledgementMode); } IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "destination-resolver"); IntegrationNamespaceUtils.SetReferenceIfAttributeDefined(builder, element, "transaction-manager"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "pub-sub-domain"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "concurrent-consumers"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "max-concurrent-consumers"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "max-messages-per-task"); IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "idle-task-execution-limit"); builder.AddPropertyValue("autoStartup", false); return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition)); }
protected static /*override*/ void PostProcess(ObjectDefinitionBuilder builder, XmlElement element) { string policyName = element.GetAttribute(REJECTION_POLICY_ATTRIBUTE); builder.AddPropertyValue("rejectedExecutionHandler", CreateRejectedExecutionHandler(policyName)); builder.AddPropertyValue("corePoolSize", element.GetAttribute(CORE_SIZE_ATTRIBUTE)); string maxSize = element.GetAttribute(MAX_SIZE_ATTRIBUTE); if (StringUtils.HasText(maxSize)) { builder.AddPropertyValue("maxPoolSize", maxSize); } }
public void Configure(ObjectDefinitionBuilder builder) { foreach (var keyValue in properties) { builder.AddPropertyValue(keyValue.Key, keyValue.Value); } }
protected override void ParseTransformer(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder) { ManagedDictionary headers = new ManagedDictionary(); XmlAttributeCollection attributes = element.Attributes; for (int i = 0; i < attributes.Count; i++) { XmlNode node = attributes.Item(i); String name = node.LocalName; if (IsEligibleHeaderName(name)) { name = Conventions.AttributeNameToPropertyName(name); object value; if (ReferenceAttributesContains(name)) { value = new RuntimeObjectReference(node.Value); } else { value = node.Value; } if (_prefix != null) { name = _prefix + name; } headers.Add(name, value); } } PostProcessHeaders(element, headers, parserContext); builder.AddConstructorArg(headers); builder.AddPropertyValue("overwrite", ShouldOverwrite(element)); }
public void Configure(ObjectDefinitionBuilder builder) { foreach (var key in properties.Keys) { builder.AddPropertyValue(key, properties[key]); } }
private void ParseSelectorChain(ObjectDefinitionBuilder builder, XmlElement element, ParserContext parserContext) { IntegrationNamespaceUtils.SetValueIfAttributeDefined(builder, element, "voting-strategy"); ManagedList selectors = new ManagedList(); selectors.ElementTypeName = typeof(IMessageSelector).FullName; XmlNodeList childNodes = element.ChildNodes; for (int i = 0; i < childNodes.Count; i++) { XmlNode child = childNodes.Item(i); if (child.NodeType == XmlNodeType.Element) { string nodeName = child.LocalName; if ("selector".Equals(nodeName)) { string refatr = ((XmlElement)child).GetAttribute("ref"); selectors.Add(new RuntimeObjectReference(refatr)); } else if ("selector-chain".Equals(nodeName)) { ObjectDefinitionBuilder nestedBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(GetObjectTypeName(null)); ParseSelectorChain(nestedBuilder, (XmlElement)child, parserContext); string nestedBeanName = parserContext.ReaderContext.RegisterWithGeneratedName(nestedBuilder.ObjectDefinition); selectors.Add(new RuntimeObjectReference(nestedBeanName)); } } } builder.AddPropertyValue("selectors", selectors); }
public void Configure(ObjectDefinitionBuilder builder) { foreach (var keyValue in properties) { builder.AddPropertyValue(keyValue.Key, keyValue.Value); } }
public void Configure(ObjectDefinitionBuilder builder) { foreach (var key in properties.Keys) { builder.AddPropertyValue(key, properties[key]); } }
/// <summary>The do parse.</summary> /// <param name="element">The element.</param> /// <param name="parserContext">The parser context.</param> /// <param name="builder">The builder.</param> protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder) { var parser = new ObjectDefinitionParserHelper(parserContext); var map = parser.ParseMapElement(element, builder.RawObjectDefinition); builder.AddPropertyValue("SourceDictionary", map); }
public string Parse(XmlElement element, ParserContext parserContext) { ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.CHANNEL_INTERCEPTOR_PACKAGE + ".WireTap"); string targetRef = element.GetAttribute("channel"); if (!StringUtils.HasText(targetRef)) { parserContext.ReaderContext.ReportException(element, "wire-tap", "The 'channel' attribute is required."); } builder.AddConstructorArgReference(targetRef); string selectorRef = element.GetAttribute("selector"); if (StringUtils.HasText(selectorRef)) { builder.AddConstructorArgReference(selectorRef); } // TODO check timeout string timeout = element.GetAttribute("timeout"); if (StringUtils.HasText(timeout)) { builder.AddPropertyValue("timeout", TimeSpan.Parse(timeout)); } return(parserContext.ReaderContext.RegisterWithGeneratedName(builder.ObjectDefinition)); }
internal static bool SetCollectionPropertyIfElementDefined(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder, string propertyName, string parentPropertyName, string parentId) { var propertyElement = element.GetSingleChildElement(propertyName.ToCamelCase()); if (propertyElement != null) { var managedList = new ManagedList(); foreach (XmlNode node in propertyElement) { var parser = NamespaceParserRegistry.GetParser(node.NamespaceURI); var objectDefinition = parser.ParseElement((XmlElement)node, parserContext); if (!string.IsNullOrEmpty(parentPropertyName)) { //if the child object has a parent Property specified then set it as well for bi-directional relationships to work seamlessly. objectDefinition.PropertyValues.Add(parentPropertyName, new RuntimeObjectReference(parentId)); } managedList.Add(objectDefinition); } builder.AddPropertyValue(propertyName, managedList); return(true); } return(false); }
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)); }
private AbstractObjectDefinition CreateAdvisorObjectDefinition(XmlElement advisorElement, ParserContext parserContext) { ObjectDefinitionBuilder advisorDefinitionBuilder = parserContext.ParserHelper.CreateRootObjectDefinitionBuilder(typeof(DefaultObjectFactoryPointcutAdvisor)); advisorDefinitionBuilder.RawObjectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE; if (advisorElement.HasAttribute(ORDER_PROPERTY)) { advisorDefinitionBuilder.AddPropertyValue(ORDER_PROPERTY, advisorElement.GetAttribute(ORDER_PROPERTY)); } advisorDefinitionBuilder.AddPropertyValue(ADVICE_OBJECT_NAME, advisorElement.GetAttribute(ADVICE_REF)); return(advisorDefinitionBuilder.ObjectDefinition); }
/// <summary> /// Populates the specified object definition property with the value /// of the attribute whose name is provided if that attribute is /// defined in the given element. /// </summary> /// <param name="builder">the builder to add the prperty to</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 to populate the property</param> /// <param name="propertyName">the name of the property to be populated</param> public static void SetValueIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName, string propertyName) { string attributeValue = element.GetAttribute(attributeName); if (StringUtils.HasText(attributeValue)) { builder.AddPropertyValue(propertyName, attributeValue); } }
private void ParseAttribute(XmlElement element, ObjectDefinitionBuilder defBuilder, string property, string attribute) { string value = element.GetAttribute(attribute); if (StringUtils.HasText(value)) { defBuilder.AddPropertyValue(property, value); } }
public static void SetPropertyValue(XmlElement element, ObjectDefinitionBuilder builder, string attrName, string propertyName) { string attr = element.GetAttribute(attrName); if (StringUtils.HasText(attr)) { builder.AddPropertyValue(propertyName, attr); } }
/// <summary> /// Parse the supplied XmlElement and populate the supplied ObjectDefinitionBuilder as required. /// </summary> /// <remarks> /// The default implementation delegates to the /// <code> /// DoParse /// </code> /// version without /// ParameterContext argument. /// </remarks> /// <param name="element">The element.</param><param name="parserContext">The parser context.</param><param name="builder">The builder used to define the /// <code> /// IObjectDefinition /// </code> /// .</param> protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder) { NamespaceUtils.SetValueIfAttributeDefined(builder, element, nameof(RedisListener.TypeKey)); NamespaceUtils.SetValueIfAttributeDefined(builder, element, nameof(RedisListener.HandlerMethod)); //NamespaceUtils.SetValueIfAttributeDefined(builder, element, nameof(RedisListener.HandlerType)); var handler = element.GetAttributeValueForProperty(nameof(RedisListener.HandlerType)); builder.AddPropertyValue(nameof(RedisListener.HandlerType), Type.GetType(handler)); }
private void ParseContainerConfiguration(XmlElement ele, ParserContext parserContext, ObjectDefinitionBuilder containerDef) { string destinationType = ele.GetAttribute(DESTINATION_TYPE_ATTRIBUTE); bool pubSubDomain = false; bool subscriptionDurable = false; if (DESTINATION_TYPE_DURABLE_TOPIC.Equals(destinationType)) { pubSubDomain = true; subscriptionDurable = true; } else if (DESTINATION_TYPE_TOPIC.Equals(destinationType)) { pubSubDomain = true; } else if ("".Equals(destinationType) || DESTINATION_TYPE_QUEUE.Equals(destinationType)) { // the default: queue } else { parserContext.ReaderContext.ReportException(ele, destinationType, "Invalid listener container '" + DESTINATION_TYPE_ATTRIBUTE + "': only 'queue', 'topic' and 'durableTopic' supported"); } containerDef.AddPropertyValue("PubSubDomain", pubSubDomain); containerDef.AddPropertyValue("SubscriptionDurable", subscriptionDurable); if (ele.HasAttribute(CLIENT_ID_ATTRIBUTE)) { string clientId = ele.GetAttribute(CLIENT_ID_ATTRIBUTE); if (!StringUtils.HasText(clientId)) { parserContext.ReaderContext.ReportException(ele, clientId, "Listener '" + CLIENT_ID_ATTRIBUTE + "' attribute contains empty value."); } containerDef.AddPropertyValue("ClientId", clientId); } }
/** * 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>Sets the value 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>True if successful, else false.</returns> public static bool SetValueIfAttributeDefined(ObjectDefinitionBuilder builder, XmlElement element, string attributeName, string propertyName) { var attributeValue = element.GetAttribute(attributeName); if (!string.IsNullOrWhiteSpace(attributeValue)) { builder.AddPropertyValue(propertyName, new TypedStringValue(attributeValue)); return(true); } return(false); }
protected override void DoParse(XmlElement element, ObjectDefinitionBuilder builder) { foreach (XmlAttribute attribute in element.Attributes) { if (IsEligibleAttribute(attribute.Name)) { string propertyName = Conventions.AttributeNameToPropertyName(attribute.LocalName); AssertUtils.State(StringUtils.HasText(propertyName), "Illegal property name returned from 'extractPropertyName(String)': cannot be null or empty."); builder.AddPropertyValue(propertyName, attribute.Value); } } PostProcess(builder, element); }
private void SetPropertyValue(ObjectDefinitionBuilder builder, XmlElement element, string attrName, string propertyName) { AssertUtils.ArgumentNotNull(builder, "builder"); AssertUtils.ArgumentNotNull(element, "element"); AssertUtils.ArgumentHasText(attrName, "attrName"); AssertUtils.ArgumentHasText(propertyName, "propertyName"); string attr = element.GetAttribute(attrName); if (StringUtils.HasText(attr)) { builder.AddPropertyValue(propertyName, attr); } }
protected override AbstractObjectDefinition ParseConsumer(XmlElement element, ParserContext parserContext) { ObjectDefinitionBuilder invokerBuilder = ObjectDefinitionBuilder.GenericObjectDefinition(IntegrationNamespaceUtils.HANDLER_PACKAGE + ".MethodInvokingMessageHandler"); invokerBuilder.AddConstructorArgReference(element.GetAttribute("ref")); invokerBuilder.AddConstructorArg(element.GetAttribute("method")); string order = element.GetAttribute("order"); if (StringUtils.HasText(order)) { invokerBuilder.AddPropertyValue("order", order); } return(invokerBuilder.ObjectDefinition); }
private void ParseListenerConfiguration(XmlElement ele, ParserContext parserContext, ObjectDefinitionBuilder containerDef) { string destination = ele.GetAttribute(DESTINATION_ATTRIBUTE); if (!StringUtils.HasText(destination)) { parserContext.ReaderContext.ReportException(ele, LISTENER_ELEMENT, "Listener '" + DESTINATION_ATTRIBUTE + "' attribute contains empty value."); } containerDef.AddPropertyValue("DestinationName", destination); if (ele.HasAttribute(SUBSCRIPTION_ATTRIBUTE)) { string subscription = ele.GetAttribute(SUBSCRIPTION_ATTRIBUTE); if (!StringUtils.HasText(subscription)) { parserContext.ReaderContext.ReportException(ele, SUBSCRIPTION_ATTRIBUTE, "Listener '" + SUBSCRIPTION_ATTRIBUTE + "' attribute contains empty value."); } containerDef.AddPropertyValue("DurableSubscriptionName", subscription); } if (ele.HasAttribute(SELECTOR_ATTRIBUTE)) { string selector = ele.GetAttribute(SELECTOR_ATTRIBUTE); if (!StringUtils.HasText(selector)) { parserContext.ReaderContext.ReportException(ele, selector, "Listener '" + SELECTOR_ATTRIBUTE + "' attribute contains empty value."); } containerDef.AddPropertyValue("MessageSelector", selector); } }
/// <summary> /// Parse the supplied XmlElement and populate the supplied ObjectDefinitionBuilder as required. /// </summary> /// <remarks> /// The default implementation delegates to the /// <code> /// DoParse /// </code> /// version without /// ParameterContext argument. /// </remarks> /// <param name="element">The element.</param><param name="parserContext">The parser context.</param><param name="builder">The builder used to define the /// <code> /// IObjectDefinition /// </code> /// .</param> protected override void DoParse(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder) { var childNodes = element.ChildNodes; var knownTypeDictionary = new Dictionary <string, Type>(); foreach (var childNode in childNodes.Cast <XmlNode>() .Where(childNode => childNode.NodeType == XmlNodeType.Element && childNode.LocalName.Equals(KnownTypeElement))) { ParseKnownTypeElement((XmlElement)childNode, parserContext, knownTypeDictionary); } builder.AddPropertyValue(nameof(TypeMapper.Types), knownTypeDictionary); }
public static bool SetValueIfElementDefined(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder, string propertyName) { var childElement = element.GetSingleChildElement(propertyName.ToCamelCase()); if (childElement != null) { var parser = NamespaceParserRegistry.GetParser(childElement.NamespaceURI); var objectDefinition = parser.ParseElement(childElement, parserContext); builder.AddPropertyValue(propertyName, objectDefinition); return(true); } return(false); }
public void Factory_WhenObtainedFromContainer_HasContainerConfiguration() { RootObjectDefinition productTemplate = new RootObjectDefinition(); productTemplate.PropertyValues.Add(new Spring.Objects.PropertyValue("ChannelManager.ChannelFactory.Credentials.UserName.UserName", "un")); productTemplate.PropertyValues.Add(new Spring.Objects.PropertyValue("ChannelManager.ChannelFactory.Credentials.UserName.Password", "pw")); GenericApplicationContext context = new GenericApplicationContext(); IObjectDefinitionFactory objectDefinitionFactory = new DefaultObjectDefinitionFactory(); ObjectDefinitionBuilder builder = ObjectDefinitionBuilder.RootObjectDefinition(objectDefinitionFactory, typeof(ChannelManagerFactoryObject)); builder.AddPropertyValue("EndpointConfigurationName", EndpointName); builder.AddPropertyValue("ChannelType", typeof(IService)); builder.AddPropertyValue("ProductTemplate", productTemplate); context.RegisterObjectDefinition("myChannelFactoryObject", builder.ObjectDefinition); var obj = context.GetObject("myChannelFactoryObject") as ProxyChannel <IService>; Assert.IsNotNull(obj); ChannelManagerBase <IService> channelManager = obj.ChannelManager as ChannelManagerBase <IService>; Assert.IsNotNull(channelManager); Assert.AreEqual("un", ((ChannelFactory <IService>)channelManager.ChannelFactory).Credentials.UserName.UserName); Assert.AreEqual("pw", ((ChannelFactory <IService>)channelManager.ChannelFactory).Credentials.UserName.Password); }
// private IConfigurableObjectDefinition ParseDatabaseDefinition(XmlElement element, string name, ParserContext parserContext) // { // switch (element.LocalName) // { // case DbProviderFactoryObjectConstants.DbProviderFactoryObjectElement: // return ParseDatabaseConfigurer(element, name, parserContext); // } // return null; // } private void ParseDatabaseConfigurer(XmlElement element, ParserContext parserContext, ObjectDefinitionBuilder builder) { // string typeName = GetTypeName(element); string providerNameAttribute = GetAttributeValue(element, DbProviderFactoryObjectConstants.ProviderNameAttribute); string connectionString = GetAttributeValue(element, DbProviderFactoryObjectConstants.ConnectionStringAttribute); // MutablePropertyValues properties = new MutablePropertyValues(); if (StringUtils.HasText(providerNameAttribute)) { builder.AddPropertyValue("Provider", providerNameAttribute); // properties.Add("Provider", providerNameAttribute); } if (StringUtils.HasText(connectionString)) { builder.AddPropertyValue("ConnectionString", connectionString); // properties.Add("ConnectionString", connectionString); } // IConfigurableObjectDefinition cod = parserContext.ReaderContext.ObjectDefinitionFactory.CreateObjectDefinition( // typeName, null, parserContext.ReaderContext.Reader.Domain); // cod.PropertyValues = properties; // return builder.ObjectDefinition; }