/// <summary>
        /// Registers the attribute config processors.
        /// </summary>
        /// <param name="registry">The registry.</param>
        public static void RegisterAttributeConfigProcessors(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(ConfigurationClassPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(AutowiredAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(RequiredAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            if (!registry.ContainsObjectDefinition(INITDESTROY_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(InitDestroyAttributeObjectPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, INITDESTROY_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }
        }
 /// <summary>
 /// Generates an object name for the given object definition.
 /// </summary>
 /// <param name="definition">The object definition to generate a name for.</param>
 /// <param name="registry">The object definitions registry that the given definition is
 ///             supposed to be registerd with</param>
 /// <returns>
 /// the generated object name
 /// </returns>
 public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     if (definition is ScannedGenericObjectDefinition)
     {
         string objectName = ((ScannedGenericObjectDefinition) definition).ComponentName;
         if (!string.IsNullOrEmpty(objectName))
             return objectName;
     }
     return BuildDefaultObjectName(definition);
 }
 public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     var objectDefinition = definition as ScannedGenericObjectDefinition;
     if (objectDefinition != null)
     {
         string componentName = objectDefinition.ComponentName;
         if (!string.IsNullOrEmpty(componentName))
             return componentName;
     }
     return BuildDefaultObjectName(definition);
 }
 /// <summary>
 /// Generates an object name for the given object definition.
 /// </summary>
 /// <param name="definition">The object definition to generate a name for.</param>
 /// <param name="registry">The object definitions registry that the given definition is
 /// supposed to be registerd with</param>
 /// <returns>the generated object name</returns>
 public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     IConfigurableObjectDefinition objectDef = definition as IConfigurableObjectDefinition;
     if (objectDef == null)
     {
         throw new ArgumentException(
             "DefaultObjectNameGenerator is only able to handle IConfigurableObjectDefinition subclasses: " +
             definition);
     }
     return ObjectDefinitionReaderUtils.GenerateObjectName(objectDef, registry);
 }
        /// <summary>
        /// Registers the attribute config processors.
        /// </summary>
        /// <param name="registry">The registry.</param>
        public static void RegisterAttributeConfigProcessors(IObjectDefinitionRegistry registry)
        {
            if (!registry.ContainsObjectDefinition(CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(typeof(ConfigurationClassPostProcessor));
                RegisterPostProcessor(registry, objectDefinition, CONFIGURATION_ATTRIBUTE_PROCESSOR_OBJECT_NAME);
            }

            //AUTOWIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME

            //REQUIRED_ATTRIBUTE_PROCESSOR_OBJECT_NAME
        }
        /// <summary>
        /// Registers the defintions for types.
        /// </summary>
        /// <param name="registry">The registry.</param>
        /// <param name="typesToRegister">The types to register.</param>
        private void RegisterDefinitionsForTypes(IObjectDefinitionRegistry registry, IEnumerable<Type> typesToRegister)
        {
            foreach (Type type in typesToRegister)
            {
                var definition = new ScannedGenericObjectDefinition(type, Defaults);
                string objectName = ObjectNameGenerator.GenerateObjectName(definition, registry);
                string fullname = type.FullName;

                Logger.Debug(m => m("Register Type: {0} with object name '{1}'", fullname, objectName));
                registry.RegisterObjectDefinition(objectName, definition);
            }
        }
        /// <summary>
        /// Scans the and register types.
        /// </summary>
        /// <param name="registry">The registry within which to register the types.</param>
        public virtual void ScanAndRegisterTypes(IObjectDefinitionRegistry registry)
        {
            IEnumerable<Type> configTypes = base.Scan();

            //if we have at least one config class, ensure the post-processor is registered
            if (configTypes.Count() > 0)
            {
                AttributeConfigUtils.RegisterAttributeConfigProcessors(registry);
            }

            RegisterDefinitionsForTypes(registry, configTypes);
        }
        /// <summary>
        /// Registers the internal auto proxy creator if necessary.
        /// </summary>
        public static void RegisterAutoProxyCreatorIfNecessary(IObjectDefinitionRegistry registry)
        {
            AssertUtils.ArgumentNotNull(registry, "registry");

            if (!registry.ContainsObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME))
            {
                RootObjectDefinition objectDefinition = new RootObjectDefinition(InfrastructureAutoProxyCreatorType);
                objectDefinition.Role = ObjectRole.ROLE_INFRASTRUCTURE;
                objectDefinition.PropertyValues.Add("order", int.MaxValue);
                registry.RegisterObjectDefinition(AUTO_PROXY_CREATOR_OBJECT_NAME, objectDefinition);
            }
        }
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Spring.Objects.Factory.Support.AbstractObjectDefinitionReader"/>
		/// class.
		/// </summary>
		/// <param name="registry">
		/// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
		/// instance that this reader works on.
		/// </param>
		/// <remarks>
		/// <p>
		/// This is an <see langword="abstract"/> class, and as such exposes no public constructors.
		/// </p>
		/// </remarks>
		protected AbstractObjectDefinitionReader(IObjectDefinitionRegistry registry)
			: this(registry, AppDomain.CurrentDomain)
		{
		}
 public static String RegisterWithGeneratedName(AbstractObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     String generatedName = GenerateObjectName(definition, registry, false);
     registry.RegisterObjectDefinition(generatedName, definition);
     return generatedName;
 }
Ejemplo n.º 11
0
 public TestWebObjectDefinitionReader(string contextVirtualPath, IObjectDefinitionRegistry registry, XmlResolver resolver)
     : base(contextVirtualPath, registry, resolver)
 {
 }
 /// <summary>
 /// Generates the name of the object for a top-level object definition unique within the given object factory.
 /// </summary>
 /// <param name="definition">The object definition to generate an object name for.</param>
 /// <param name="registry">The registry to check for existing names.</param>
 /// <returns>The generated object name</returns>
 /// <exception cref="ObjectDefinitionStoreException">if no unique name can be generated for the given
 /// object definition</exception>
 public static string GenerateObjectName(IConfigurableObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     return(GenerateObjectName(definition, registry, false));
 }
        private void ProcessConfigObjectDefinitions(IObjectDefinitionRegistry registry)
        {
            ISet<ObjectDefinitionHolder> configCandidates = new HashedSet<ObjectDefinitionHolder>();
            foreach (string objectName in registry.GetObjectDefinitionNames())
            {
                IObjectDefinition objectDef = registry.GetObjectDefinition(objectName);
                if (ConfigurationClassObjectDefinitionReader.CheckConfigurationClassCandidate(objectDef))
                {
                    configCandidates.Add(new ObjectDefinitionHolder(objectDef, objectName));
                }
            }

            //if nothing to process, bail out
            if (configCandidates.Count == 0) { return; }

            ConfigurationClassParser parser = new ConfigurationClassParser(_problemReporter);
            foreach (ObjectDefinitionHolder holder in configCandidates)
            {
                IObjectDefinition bd = holder.ObjectDefinition;
                try
                {
                    if (bd is AbstractObjectDefinition && ((AbstractObjectDefinition)bd).HasObjectType)
                    {
                        parser.Parse(((AbstractObjectDefinition)bd).ObjectType, holder.ObjectName);
                    }
                    else
                    {
                        //parser.Parse(bd.ObjectTypeName, holder.ObjectName);
                    }
                }
                catch (ObjectDefinitionParsingException ex)
                {
                    throw new ObjectDefinitionStoreException("Failed to load object class: " + bd.ObjectTypeName, ex);
                }
            }
            parser.Validate();

            // Read the model and create Object definitions based on its content
            ConfigurationClassObjectDefinitionReader reader = new ConfigurationClassObjectDefinitionReader(registry, _problemReporter);
            reader.LoadObjectDefinitions(parser.ConfigurationClasses);
        }
 /// <summary>
 /// Scans the and register types.
 /// </summary>
 /// <param name="registry">The registry within which to register the types.</param>
 public virtual void ScanAndRegisterTypes(IObjectDefinitionRegistry registry)
 {
     IEnumerable<Type> configTypes = Scan();
     RegisterDefinitionsForTypes(registry, configTypes);
 }
 private void RegisterComponents(XmlElement element, IObjectDefinitionRegistry registry)
 {
     bool attributeConfig = true;
     var attr = element.GetAttribute(ATTRIBUTE_CONFIG_ATTRIBUTE);
     if (attr != null)
         bool.TryParse(attr, out attributeConfig);
     if (attributeConfig)
         AttributeConfigUtils.RegisterAttributeConfigProcessors(registry);
 }
Ejemplo n.º 16
0
        public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
        {
            string typeName = definition.ObjectType.Name;

            return(typeName.ToLower());
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Oragon.Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Oragon.Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 public XmlObjectDefinitionReader(IObjectDefinitionRegistry registry)
     : this(registry, new XmlUrlResolver())
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Oragon.Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Oragon.Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">
 /// The <see cref="System.Xml.XmlResolver"/>to be used for parsing.
 /// </param>
 /// <param name="objectDefinitionFactory">the <see cref="IObjectDefinitionFactory"/> to use for creating new <see cref="IObjectDefinition"/>s</param>
 protected XmlObjectDefinitionReader(IObjectDefinitionRegistry registry, XmlResolver resolver, IObjectDefinitionFactory objectDefinitionFactory)
     : base(registry)
 {
     Resolver = resolver;
     this.objectDefinitionFactory = objectDefinitionFactory;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Oragon.Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Oragon.Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">
 /// The <see cref="System.Xml.XmlResolver"/>to be used for parsing.
 /// </param>
 public XmlObjectDefinitionReader(IObjectDefinitionRegistry registry, XmlResolver resolver)
     : this(registry, resolver, new DefaultObjectDefinitionFactory())
 {
     Resolver = resolver;
 }
        public static String RegisterWithGeneratedName(AbstractObjectDefinition definition, IObjectDefinitionRegistry registry)
        {
            String generatedName = GenerateObjectName(definition, registry, false);

            registry.RegisterObjectDefinition(generatedName, definition);
            return(generatedName);
        }
 public TestXmlObjectDefinitionReader(IObjectDefinitionRegistry registry)
     : base(registry)
 { }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="contextVirtualPath">the (rooted) virtual path to resolve relative virtual paths.</param>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">the <see cref="XmlResolver"/> to use for resolving entities.</param>
 public WebObjectDefinitionReader(string contextVirtualPath, IObjectDefinitionRegistry registry, XmlResolver resolver)
     : base(registry, resolver, new WebObjectDefinitionFactory())
 {
     this.contextVirtualPath = contextVirtualPath;
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="contextVirtualPath">the (rooted) virtual path to resolve relative virtual paths.</param>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">the <see cref="XmlResolver"/> to use for resolving entities.</param>
 public WebObjectDefinitionReader(string contextVirtualPath, IObjectDefinitionRegistry registry, XmlResolver resolver)
     : base(registry, resolver, new WebObjectDefinitionFactory())
 {
     this.contextVirtualPath = contextVirtualPath;
 }
 /// <summary>
 /// Initializes a new instance of the ConfigurationClassObjectDefinitionReader class.
 /// </summary>
 /// <param name="registry"></param>
 /// <param name="problemReporter"></param>
 public ConfigurationClassObjectDefinitionReader(IObjectDefinitionRegistry registry,
     IProblemReporter problemReporter)
 {
     _registry = registry;
     _problemReporter = problemReporter;
 }
 /// <summary>
 /// Registers the defintions for types.
 /// </summary>
 /// <param name="registry">The registry.</param>
 /// <param name="typesToRegister">The types to register.</param>
 private void RegisterDefinitionsForTypes(IObjectDefinitionRegistry registry, IEnumerable<Type> typesToRegister)
 {
     foreach (Type type in typesToRegister)
     {
         var definition = new ScannedGenericObjectDefinition(type, Defaults);
         string objectName = ObjectNameGenerator.GenerateObjectName(definition, registry);
         registry.RegisterObjectDefinition(objectName, definition);
     }
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.PropertiesObjectDefinitionReader"/>
 /// class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 public PropertiesObjectDefinitionReader(IObjectDefinitionRegistry registry)
     : base(registry)
 {}
 /// <summary>
 /// Postsprocesses the object definition registry.
 /// </summary>
 /// <param name="registry">The registry.</param>
 public void PostProcessObjectDefinitionRegistry(IObjectDefinitionRegistry registry)
 {
     if (_postProcessObjectDefinitionRegistryCalled)
     {
         throw new InvalidOperationException("PostProcessObjectDefinitionRegistry already called for this post-processor");
     }
     if (_postProcessObjectFactoryCalled)
     {
         throw new InvalidOperationException("PostProcessObjectFactory already called for this post-processor");
     }
     _postProcessObjectDefinitionRegistryCalled = true;
     ProcessConfigObjectDefinitions(registry);
 }
        /// <summary>
        /// Generates an object definition name for the supplied
        /// <paramref name="objectDefinition"/> that is guaranteed to be unique
        /// within the scope of the supplied <paramref name="registry"/>.
        /// </summary>
        /// <param name="objectDefinition">The <see cref="Spring.Objects.Factory.Config.IObjectDefinition"/>
        /// that requires a generated name.</param>
        /// <param name="registry">The
        /// <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
        /// that the supplied <paramref name="objectDefinition"/> is to be
        /// registered with (needed so that the uniqueness of any generated
        /// name can be guaranteed).</param>
        /// <param name="isInnerObject">if set to <c>true</c> if the given object
        /// definition will be registed as an inner object or as a top level objener objects
        /// verses top level objects.</param>
        /// <returns>
        /// An object definition name for the supplied
        /// <paramref name="objectDefinition"/> that is guaranteed to be unique
        /// within the scope of the supplied <paramref name="registry"/> and
        /// never <cref lang="null"/>.
        /// </returns>
        /// <exception cref="System.ArgumentNullException">
        /// If either of the <paramref name="objectDefinition"/> or
        /// <paramref name="registry"/> arguments is <see langword="null"/>.
        /// </exception>
        /// <exception cref="Spring.Objects.Factory.ObjectDefinitionStoreException">
        /// If a unique name cannot be generated.
        /// </exception>
        public static string GenerateObjectName(
            IConfigurableObjectDefinition objectDefinition, IObjectDefinitionRegistry registry, bool isInnerObject)
        {
            AssertUtils.ArgumentNotNull(objectDefinition, "objectDefinition");
            AssertUtils.ArgumentNotNull(registry, "registry");

            string generatedObjectName = objectDefinition.ObjectTypeName;
            if (StringUtils.IsNullOrEmpty(generatedObjectName))
            {
                if (objectDefinition is ChildObjectDefinition)
                {
                    generatedObjectName = ((ChildObjectDefinition)objectDefinition).ParentName + "$child";
                }
                else if (objectDefinition.FactoryObjectName != null)
                {
                    generatedObjectName = objectDefinition.FactoryObjectName + "$created";
                }
            }
            if (StringUtils.IsNullOrEmpty(generatedObjectName))
            {
                if (!isInnerObject)
                {
                    throw new ObjectDefinitionStoreException(
                        objectDefinition.ResourceDescription, String.Empty,
                        "Unnamed object definition specifies neither 'Type' nor 'Parent' " +
                        "nor 'FactoryObject' property values so a unique name cannot be generated.");
                }
                generatedObjectName = "$nested";
            }

            String id = generatedObjectName;
            if (isInnerObject)
            {
                id = generatedObjectName + GENERATED_OBJECT_NAME_SEPARATOR + ObjectUtils.GetIdentityHexString(objectDefinition);
            }
            else
            {
                int counter = -1;
                while (counter == -1 || registry.ContainsObjectDefinition(id))
                {
                    counter++;
                    id = generatedObjectName + GENERATED_OBJECT_NAME_SEPARATOR + counter;
                }
            }

            return id;
        }
 public string GenerateObjectName(IObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     string typeName = definition.ObjectType.Name;
     return typeName.ToLower();
 }
        /// <summary>
        /// Scans the and register types.
        /// </summary>
        /// <param name="registry">The registry within which to register the types.</param>
        public virtual void ScanAndRegisterTypes(IObjectDefinitionRegistry registry)
        {
            IEnumerable <Type> configTypes = Scan();

            RegisterDefinitionsForTypes(registry, configTypes);
        }
Ejemplo n.º 31
0
        private void ConfigureObjectFactory(IObjectDefinitionRegistry factory)
        {
            XmlObjectDefinitionReader reader = new XmlObjectDefinitionReader(factory);
            reader.LoadObjectDefinitions(new StringResource(@"<?xml version='1.0' encoding='UTF-8' ?>
                <objects xmlns='http://www.springframework.net'
                          xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                          xsi:schemaLocation='http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd'>

                      <object id='Parent' type='Spring.Objects.Factory.SPRNET_1334+ParentClass, Spring.Core.Tests'>
                        <property name='Name' value='Foo!'/>
			                <property name='InnerObject'>
				                <object type='Spring.Objects.Factory.SPRNET_1334+DisposableClass, Spring.Core.Tests'/>
			                </property>
                      </object>
<!--
                      <object id='Parent' type='Spring.Objects.Factory.SPRNET_1334+ParentClass, Spring.Core.Tests'>
                        <property name='Name' value='Foo!'/>
			                <property name='InnerObject' ref='Inner'/>
                      </object>

                      <object id='Inner' type='Spring.Objects.Factory.SPRNET_1334+DisposableClass, Spring.Core.Tests'/>
-->			          
                      
                </objects>
            "));
        }
 public void SetUp()
 {
     mocks = new MockRepository();
     registry = mocks.StrictMock<IObjectDefinitionRegistry>();
     definition = mocks.StrictMock<IObjectDefinition>();
 }
 private void ParseAlias(XmlElement aliasElement, IObjectDefinitionRegistry registry)
 {
     string name = GetAttributeValue(aliasElement, ObjectDefinitionConstants.NameAttribute);
     string alias = GetAttributeValue(aliasElement, ObjectDefinitionConstants.AliasAttribute);
     registry.RegisterAlias(name, alias);
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">
 /// The <see cref="System.Xml.XmlResolver"/>to be used for parsing.
 /// </param>
 public XmlObjectDefinitionReader(IObjectDefinitionRegistry registry, XmlResolver resolver)
     : this(registry, resolver, new DefaultObjectDefinitionFactory())
 {
     Resolver = resolver;
 }
 /// <summary>
 /// Generates the name of the object for a top-level object definition unique within the given object factory.
 /// </summary>
 /// <param name="definition">The object definition to generate an object name for.</param>
 /// <param name="registry">The registry to check for existing names.</param>
 /// <returns>The generated object name</returns>
 /// <exception cref="ObjectDefinitionStoreException">if no unique name can be generated for the given
 /// object definition</exception>
 public static string GenerateObjectName(IConfigurableObjectDefinition definition, IObjectDefinitionRegistry registry)
 {
     return GenerateObjectName(definition, registry, false);
 }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 /// <param name="resolver">
 /// The <see cref="System.Xml.XmlResolver"/>to be used for parsing.
 /// </param>
 /// <param name="objectDefinitionFactory">the <see cref="IObjectDefinitionFactory"/> to use for creating new <see cref="IObjectDefinition"/>s</param>
 protected XmlObjectDefinitionReader(IObjectDefinitionRegistry registry, XmlResolver resolver, IObjectDefinitionFactory objectDefinitionFactory)
     : base(registry)
 {
     Resolver = resolver;
     this.objectDefinitionFactory = objectDefinitionFactory;
 }
        /// <summary>
        /// Registers the supplied <paramref name="objectDefinition"/> with the
        /// supplied <paramref name="registry"/>.
        /// </summary>
        /// <remarks>
        /// <p>
        /// This is a convenience method that registers the
        /// <see cref="Spring.Objects.Factory.Config.ObjectDefinitionHolder.ObjectDefinition"/>
        /// of the supplied <paramref name="objectDefinition"/> under the 
        /// <see cref="Spring.Objects.Factory.Config.ObjectDefinitionHolder.ObjectName"/>
        /// property value of said <paramref name="objectDefinition"/>. If the
        /// supplied <paramref name="objectDefinition"/> has any
        /// <see cref="Spring.Objects.Factory.Config.ObjectDefinitionHolder.Aliases"/>,
        /// then those aliases will also be registered with the supplied
        /// <paramref name="registry"/>.
        /// </p>
        /// </remarks>
        /// <param name="objectDefinition">
        /// The object definition holder containing the
        /// <see cref="Spring.Objects.Factory.Config.IObjectDefinition"/> that
        /// is to be registered.
        /// </param>
        /// <param name="registry">
        /// The registry that the supplied <paramref name="objectDefinition"/>
        /// is to be registered with.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// If either of the supplied arguments is <see langword="null"/>.
        /// </exception>
        /// <exception cref="Spring.Objects.ObjectsException">
        /// If the <paramref name="objectDefinition"/> could not be registered
        /// with the <paramref name="registry"/>.
        /// </exception>
        public static void RegisterObjectDefinition(
            ObjectDefinitionHolder objectDefinition, IObjectDefinitionRegistry registry)
        {
            AssertUtils.ArgumentNotNull(objectDefinition, "objectDefinition");
            AssertUtils.ArgumentNotNull(registry, "registry");

            registry.RegisterObjectDefinition(objectDefinition.ObjectName, objectDefinition.ObjectDefinition);
            IList<string> aliases = objectDefinition.Aliases;
            for (int i = 0; i < aliases.Count; ++i)
            {
                string alias = aliases[i];
                registry.RegisterAlias(objectDefinition.ObjectName, alias);
            }
        }
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Xml.XmlObjectDefinitionReader"/> class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 public XmlObjectDefinitionReader(IObjectDefinitionRegistry registry)
     : this(registry, new XmlUrlResolver())
 { }
		/// <summary>
		/// Creates a new instance of the
		/// <see cref="Spring.Objects.Factory.Support.AbstractObjectDefinitionReader"/>
		/// class.
		/// </summary>
		/// <param name="registry">
		/// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
		/// instance that this reader works on.
		/// </param>
		/// <param name="domain">
		/// The <see cref="System.AppDomain"/> against which any class names
		/// will be resolved into <see cref="System.Type"/> instances.
		/// </param>
		/// <remarks>
		/// <p>
		/// This is an <see langword="abstract"/> class, and as such exposes no public constructors.
		/// </p>
		/// </remarks>
		protected AbstractObjectDefinitionReader(
			IObjectDefinitionRegistry registry,
			AppDomain domain)
		{
		    log = LogManager.GetLogger(this.GetType());

		    AssertUtils.ArgumentNotNull(registry, "registry", "IObjectDefinitionRegistry must not be null");
			_registry = registry;
			_domain = domain;
            if (registry is IResourceLoader)
            {
                _resourceLoader = registry as IResourceLoader;
            }
            else
            {
                _resourceLoader = new ConfigurableResourceLoader();
            }
		}
Ejemplo n.º 40
0
 /// <summary>
 /// Creates a new instance of the
 /// <see cref="Spring.Objects.Factory.Support.PropertiesObjectDefinitionReader"/>
 /// class.
 /// </summary>
 /// <param name="registry">
 /// The <see cref="Spring.Objects.Factory.Support.IObjectDefinitionRegistry"/>
 /// instance that this reader works on.
 /// </param>
 public PropertiesObjectDefinitionReader(IObjectDefinitionRegistry registry)
     : base(registry)
 {
 }