In this tutorial we are going to see configuration metadata in Spring.
You can configure the metadata to Spring container in following way.
In above diagram shows, the Spring IoC container consumes a form of configuration metadata.This configuration metadata represents how an application developer tell the Spring container to insatiate, configure, and assemble the objects in your application.
Configuration metadata is traditionally supplied in a simple and intuitive XML format, which is what most of this chapter uses to convey key concepts and features of the Spring IoC container.XML-based metadata is not the only allowed form of configuration metadata. The Spring IoC container itself is totally decoupled from the format in which this configuration metadata is actually written.
Annotation based configuration is introduced in Spring 2.5. We will see the Annotation based configuration in separate chapter.
Java Based Configuration . This feature is introduced in Spring 3.0, using Java based configuration you can define beans external to your application classes rather than XML files. We will see the Java based configuration in separate chapter.
Spring configuration consists of at least one and typically more than one bean definition that the container must manage. XML-based configuration metadata shows these beans configured as <bean/> elements inside a top-level <beans/> element.
These bean definitions correspond to the actual objects that make up your application. Typically you define service layer objects, data access objects (DAOs), presentation objects such as Struts Action instances, infrastructure objects such as Hibernate SessionFactories, JMS Queues, and so forth. Typically one does not configure fine-grained domain objects in the container, because it is usually the responsibility of DAOs and business logic to create and load domain objects. However, you can use Spring's integration with AspectJ to configure objects that have been created outside the control of an IoC container.
Bean.xml
The id attribute is a string that you use to identify the individual bean definition. The class attribute defines the type of the bean and uses the fully qualified classname. The value of the id attribute refers to collaborating objects.
You can configure the metadata to Spring container in following way.
- XML based configuration
- Annotation based configuration
- Java based configuration
In above diagram shows, the Spring IoC container consumes a form of configuration metadata.This configuration metadata represents how an application developer tell the Spring container to insatiate, configure, and assemble the objects in your application.
Configuration metadata is traditionally supplied in a simple and intuitive XML format, which is what most of this chapter uses to convey key concepts and features of the Spring IoC container.XML-based metadata is not the only allowed form of configuration metadata. The Spring IoC container itself is totally decoupled from the format in which this configuration metadata is actually written.
Annotation based configuration is introduced in Spring 2.5. We will see the Annotation based configuration in separate chapter.
Java Based Configuration . This feature is introduced in Spring 3.0, using Java based configuration you can define beans external to your application classes rather than XML files. We will see the Java based configuration in separate chapter.
Spring configuration consists of at least one and typically more than one bean definition that the container must manage. XML-based configuration metadata shows these beans configured as <bean/> elements inside a top-level <beans/> element.
These bean definitions correspond to the actual objects that make up your application. Typically you define service layer objects, data access objects (DAOs), presentation objects such as Struts Action instances, infrastructure objects such as Hibernate SessionFactories, JMS Queues, and so forth. Typically one does not configure fine-grained domain objects in the container, because it is usually the responsibility of DAOs and business logic to create and load domain objects. However, you can use Spring's integration with AspectJ to configure objects that have been created outside the control of an IoC container.
Bean.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="classpathxml" class="com.javatutorialscorner.spring.SpringClassPathXmlApplicationContext">
<property name="sayHello" value="say Hello"></property>
</bean>
<bean id="..." class="...">
<!-- collaborators and configuration for this bean go here -->
</bean>
<!-- more bean definitions go here -->
</beans>
The id attribute is a string that you use to identify the individual bean definition. The class attribute defines the type of the bean and uses the fully qualified classname. The value of the id attribute refers to collaborating objects.
0 comments:
Post a Comment