Inheritance: IConfigurableObjectDefinition
        public static String RegisterWithGeneratedName(AbstractObjectDefinition definition, IObjectDefinitionRegistry registry)
        {
            String generatedName = GenerateObjectName(definition, registry, false);

            registry.RegisterObjectDefinition(generatedName, definition);
            return(generatedName);
        }
        /// <summary>
        /// Override settings in this object definition from the supplied
        /// <paramref name="other"/> object definition.
        /// </summary>
        /// <param name="other">
        /// The object definition used to override the member fields of this instance.
        /// </param>
        public virtual void OverrideFrom(IObjectDefinition other)
        {
            AssertUtils.ArgumentNotNull(other, "other");

            IsAbstract = other.IsAbstract;
            Scope      = other.Scope;
            IsLazyInit = other.IsLazyInit;
            ConstructorArgumentValues.AddAll(other.ConstructorArgumentValues);
            PropertyValues.AddAll(other.PropertyValues.PropertyValues);
            EventHandlerValues.AddAll(other.EventHandlerValues);
            if (StringUtils.HasText(other.ObjectTypeName))
            {
                ObjectTypeName = other.ObjectTypeName;
            }
            if (StringUtils.HasText(other.InitMethodName))
            {
                InitMethodName = other.InitMethodName;
            }
            if (StringUtils.HasText(other.DestroyMethodName))
            {
                DestroyMethodName = other.DestroyMethodName;
            }
            if (StringUtils.HasText(other.FactoryObjectName))
            {
                FactoryObjectName = other.FactoryObjectName;
            }
            if (StringUtils.HasText(other.FactoryMethodName))
            {
                FactoryMethodName = other.FactoryMethodName;
            }
            if (other.DependsOn != null && other.DependsOn.Count > 0)
            {
                List <string> deps = new List <string>(other.DependsOn);
                if (DependsOn != null && DependsOn.Count > 0)
                {
                    deps.AddRange(DependsOn);
                }
                DependsOn = deps;
            }
            AutowireMode        = other.AutowireMode;
            ResourceDescription = other.ResourceDescription;
            IsPrimary           = other.IsPrimary;
            IsAutowireCandidate = other.IsAutowireCandidate;

            AbstractObjectDefinition aod = other as AbstractObjectDefinition;

            if (aod != null)
            {
                if (aod.HasObjectType)
                {
                    ObjectType = other.ObjectType;
                }

                MethodOverrides.AddAll(aod.MethodOverrides);
                DependencyCheck = aod.DependencyCheck;
                CopyQualifiersFrom(aod);
            }
        }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     String name = base.ResolveId(element, definition, parserContext);
     if (!StringUtils.HasText(name))
     {
         name = "gemfire-pool";
     }
     return name;
 }
        /// <summary>
        /// Override settings in this object definition from the supplied
        /// <paramref name="other"/> object definition.
        /// </summary>
        /// <param name="other">
        /// The object definition used to override the member fields of this instance.
        /// </param>
        public virtual void OverrideFrom(IObjectDefinition other)
        {
            AssertUtils.ArgumentNotNull(other, "other");

            IsAbstract = other.IsAbstract;
            Scope      = other.Scope;
            IsLazyInit = other.IsLazyInit;
            ConstructorArgumentValues.AddAll(other.ConstructorArgumentValues);
            PropertyValues.AddAll(other.PropertyValues.PropertyValues);
            EventHandlerValues.AddAll(other.EventHandlerValues);
            if (StringUtils.HasText(other.ObjectTypeName))
            {
                ObjectTypeName = other.ObjectTypeName;
            }
            if (StringUtils.HasText(other.InitMethodName))
            {
                InitMethodName = other.InitMethodName;
            }
            if (StringUtils.HasText(other.DestroyMethodName))
            {
                DestroyMethodName = other.DestroyMethodName;
            }
            if (StringUtils.HasText(other.FactoryObjectName))
            {
                FactoryObjectName = other.FactoryObjectName;
            }
            if (StringUtils.HasText(other.FactoryMethodName))
            {
                FactoryMethodName = other.FactoryMethodName;
            }
            if (ArrayUtils.HasLength(other.DependsOn))
            {
                ArrayList deps = new ArrayList(other.DependsOn);
                if (ArrayUtils.HasLength(DependsOn))
                {
                    deps.AddRange(DependsOn);
                }
                DependsOn = (string[])deps.ToArray(typeof(string));
            }
            AutowireMode        = other.AutowireMode;
            ResourceDescription = other.ResourceDescription;

            AbstractObjectDefinition aod = other as AbstractObjectDefinition;

            if (aod != null)
            {
                if (aod.HasObjectType)
                {
                    ObjectType = other.ObjectType;
                }

                MethodOverrides.AddAll(aod.MethodOverrides);
                DependencyCheck = aod.DependencyCheck;
            }
        }
 /// <summary>
 /// Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.
 /// </summary>
 /// <param name="source">the AbstractBeanDefinition to copy from</param>
 public void CopyQualifiersFrom(AbstractObjectDefinition source)
 {
     Trace.Assert(source != null, "Source must not be null");
     foreach (var qualifier in source.qualifiers)
     {
         if (!qualifiers.Contains(qualifier))
         {
             qualifiers.Add(qualifier);
         }
     }
 }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     string id = base.ResolveId(element, definition, parserContext);
     if(!StringUtils.HasText(id)) {
         id = element.GetAttribute("name");
     }
     if(!StringUtils.HasText(id)) {
         id = parserContext.ReaderContext.GenerateObjectName(definition);
     }
     return id;
 }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     string id = element.GetAttribute("id");
     if(!element.HasAttribute("channel")) {
         // the created channel will get the 'id', so the adapter's object name includes a suffix
         id = id + ".adapter";
     }
     else if(!StringUtils.HasText(id)) {
         id = parserContext.ReaderContext.GenerateObjectName(definition);
     }
     return id;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new instance of the
        /// <see cref="Spring.Objects.Factory.Support.AbstractObjectDefinition"/>
        /// class.
        /// </summary>
        /// <param name="other">
        /// The object definition used to initialise the member fields of this
        /// instance.
        /// </param>
        /// <remarks>
        /// <p>
        /// This is an <see langword="abstract"/> class, and as such exposes no
        /// public constructors.
        /// </p>
        /// </remarks>
        protected AbstractObjectDefinition(IObjectDefinition other)
        {
            AssertUtils.ArgumentNotNull(other, "other");
            OverrideFrom(other);

            AbstractObjectDefinition aod = other as AbstractObjectDefinition;

            if (aod != null)
            {
                if (aod.HasObjectType)
                {
                    ObjectType = other.ObjectType;
                }
                else
                {
                    ObjectTypeName = other.ObjectTypeName;
                }
                MethodOverrides = new MethodOverrides(aod.MethodOverrides);
                DependencyCheck = aod.DependencyCheck;
            }
            ParentName = other.ParentName;
            IsAbstract = other.IsAbstract;
//            IsSingleton = other.IsSingleton;
            Scope      = other.Scope;
            Role       = other.Role;
            IsLazyInit = other.IsLazyInit;
            ConstructorArgumentValues
                               = new ConstructorArgumentValues(other.ConstructorArgumentValues);
            PropertyValues     = new MutablePropertyValues(other.PropertyValues);
            EventHandlerValues = new EventValues(other.EventHandlerValues);

            InitMethodName      = other.InitMethodName;
            DestroyMethodName   = other.DestroyMethodName;
            IsAutowireCandidate = other.IsAutowireCandidate;
            IsPrimary           = other.IsPrimary;
            CopyQualifiersFrom(aod);
            if (other.DependsOn.Count > 0)
            {
                DependsOn = other.DependsOn;
            }
            FactoryMethodName   = other.FactoryMethodName;
            FactoryObjectName   = other.FactoryObjectName;
            AutowireMode        = other.AutowireMode;
            ResourceDescription = other.ResourceDescription;
        }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     string id = base.ResolveId(element, definition, parserContext);
     if(element.GetAttribute("default").Equals("true")) {
         if(parserContext.Registry.GetObjectDefinition(IntegrationContextUtils.DefaultPollerMetadataObjectName) != null) {
             parserContext.ReaderContext.ReportException(element, element.Name, "Only one default <poller/> element is allowed per context.");
         }
         if(StringUtils.HasText(id)) {
             parserContext.Registry.RegisterAlias(id, IntegrationContextUtils.DefaultPollerMetadataObjectName);
         }
         else {
             id = IntegrationContextUtils.DefaultPollerMetadataObjectName;
         }
     }
     else if(!StringUtils.HasText(id)) {
         parserContext.ReaderContext.ReportException(element, element.Name, "The 'id' attribute is required for a top-level poller element unless it is the default poller.");
     }
     return id;
 }
 public static String RegisterWithGeneratedName(AbstractObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     String generatedName = GenerateObjectName(definition, registry, false);
     registry.RegisterObjectDefinition(generatedName, definition);
     return generatedName;
 }
        /// <summary>
        /// Resolves the ID for the supplied <see cref="IObjectDefinition"/>.
        /// </summary>
        /// <remarks>
        /// When using <see cref="ShouldGenerateId"/> generation, a name is generated automatically.
        /// Otherwise, the ID is extracted from the "id" attribute, potentially with a
        /// <see cref="ShouldGenerateIdAsFallback"/> fallback to a generated id.
        /// </remarks>
        /// <param name="element">The element that the object definition has been built from.</param>
        /// <param name="definition">The object definition to be registered.</param>
        /// <param name="parserContext">The the object encapsulating the current state of the parsing process;
        /// provides access to a <see cref="IObjectDefinitionRegistry"/> </param>
        /// <returns>the resolved id</returns>
        /// <exception cref="ObjectDefinitionStoreException">
        /// if no unique name could be generated for the given object definition
        /// </exception>
        protected virtual string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
	    {

		    if (ShouldGenerateId) {
			    return parserContext.ReaderContext.GenerateObjectName(definition);
		    }
		    else {
                string id = GetAttributeValue(element, ID_ATTRIBUTE);
			    if (!StringUtils.HasText(id) && ShouldGenerateIdAsFallback) {
				    id = parserContext.ReaderContext.GenerateObjectName(definition);
			    }
			    return id;
		    }
	    }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     // TODO return AbstractApplicationContext.APPLICATION_EVENT_MULTICASTER_BEAN_NAME;
     return AbstractApplicationContext.EventRegistryObjectName; //.APPLICATION_EVENT_MULTICASTER_BEAN_NAME;
 }
 private bool IndicatesPubSub(AbstractObjectDefinition configDef)
 {
     return (bool) configDef.PropertyValues.GetPropertyValue("PubSubDomain").Value;
 }
        private static object ParsePropertySubElement(XmlElement childElement,
            AbstractObjectDefinition rawObjectDefinition,
            ParserContext parserContext)
        {
            string localName = childElement.LocalName;
            if ("object".Equals(localName))
            {
                ObjectDefinitionHolder holder = parserContext.ParserHelper.ParseObjectDefinitionElement(childElement);

                return holder;
            }
            if ("ref".Equals(localName))
            {
                string reference = childElement.GetAttribute("object");
                return new RuntimeObjectReference(reference);
            }
            parserContext.ReaderContext.ReportException(childElement, localName, "unsupported element");
            return null;
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Parse qualifier sub-elements of the given bean element.
 /// </summary>
 public void ParseQualifierElements(string name, XmlElement element, ParserContext parserContext, AbstractObjectDefinition od)
 {
     foreach (XmlNode node in this.SelectNodes(element, ObjectDefinitionConstants.QualifierElement))
     {
         ParseQualifierElement(name, (XmlElement) node, parserContext, od);
     }
 }
 /// <summary>
 /// Copy the qualifiers from the supplied AbstractBeanDefinition to this bean definition.
 /// </summary>
 /// <param name="source">the AbstractBeanDefinition to copy from</param>
 public void CopyQualifiersFrom(AbstractObjectDefinition source)
 {
     Trace.Assert(source != null, "Source must not be null");
     foreach (var qualifier in source.qualifiers)
     {
         if (!qualifiers.Contains(qualifier))
             qualifiers.Add(qualifier);
     }
 }
 protected override string ResolveId(XmlElement element, AbstractObjectDefinition definition, ParserContext parserContext)
 {
     return IntegrationNamespaceUtils.CONFIG_ANNOTATION_PACKAGE + ".InternalMessagingAnnotationPostProcessor";
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Parse a qualifier element.
        /// </summary>
        public void ParseQualifierElement(string name, XmlElement element, ParserContext parserContext, AbstractObjectDefinition od)
        {
            string typeName = GetAttributeValue(element, ObjectDefinitionConstants.TypeAttribute);
            string value = GetAttributeValue(element, ObjectDefinitionConstants.ValueAttribute);

            if (string.IsNullOrEmpty(typeName))
            {
                throw new ObjectDefinitionStoreException(
                                    parserContext.ReaderContext.Resource, name,
                                    "Tag 'qualifier' must have a 'type' attribute");
            }
            
            var qualifier = new AutowireCandidateQualifier(typeName);
            qualifier.Source = element;

            if (!string.IsNullOrEmpty(value))
                qualifier.SetAttribute(AutowireCandidateQualifier.VALUE_KEY, value);

            foreach (XmlNode node in this.SelectNodes(element, ObjectDefinitionConstants.AttributeElement))
            {
                var attributeEle = node as XmlElement;
                string attributeKey = GetAttributeValue(attributeEle, ObjectDefinitionConstants.KeyAttribute);
                string attributeValue = GetAttributeValue(attributeEle, ObjectDefinitionConstants.ValueAttribute);

                if (!string.IsNullOrEmpty(attributeKey) && !string.IsNullOrEmpty(attributeValue))
                {
                    var attribute = new ObjectMetadataAttribute(attributeKey, attributeValue);
                    attribute.Source = attributeEle;
                    qualifier.AddMetadataAttribute(attribute);
                }
                else
                {
                    throw new ObjectDefinitionStoreException(
                                        parserContext.ReaderContext.Resource, name,
                                        "Qualifier 'attribute' tag must have a 'key' and 'value'");
                }
            }
            od.AddQualifier(qualifier);
        }