I’m quite new to Spring Framework. Could someone please help me understand the spring configuration below?
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
</objects>
</spring>
</configuration>
Basically questions in my mind are:
What does this line means:
<resource uri="config://spring/objects" />
and this:
<object type="Test.aspx">
<property name="AService" ref="AService" />
<property name="BService" ref="BService" />
</object>
Does config: means configuration file?
Does ref means Classes in C#?
<resource uri="config://spring/objects" />means that the spring container should read a configuration section from an application configuration file (app.config or web.config).<object ...is an object definition; this defines an object in your container. An object can have dependencies. In your case, theTest.aspxpage has properties namedAServiceandBService. The container will set these properties to the objects defined elsewhere in your container.What might be a bit confusing here is the double usage of
="AService"in<property name="AService" ref="AService" />:name=: refers to the name of the property on your classTest, there is a property defined aspublic IMyService AService { get; set; }ref=: refers to another object defined in your container, there is an object definition like<object id="AService" type="MyNamespace.MyClass, MyAssembly" />somewhere in your configuration.The “Instantiating the container” section of the spring docs does a good job of explaining this further.