Sunday 13, Apr 2025
We are moved to new domain
Click -> www.ehowtonow.com
Sunday, 2 March 2014

Spring Configuration metadata

In this tutorial we are going to see configuration metadata in Spring.
You can configure the metadata to Spring container in following way.
  1. XML based configuration
  2. Annotation based configuration
  3. Java based configuration
spring ioc
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.

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer

Related Posts:

  • Spring BeanFactory ContainerIn this tutorial we are going to see Spring bean factory container and example program using spring BeanFactory container.The BeanFactory container provides basic support for Dependency Injection (DI) , which is defined by or… Read More
  • Spring - Introduction In this tutorial we are going to see brief introduction about Spring  Framework.This tutorials created by referring spring framework 3.2.4 reference document. Overview of Spring Framework The Spring framework is a … Read More
  • Spring FileSystemXmlApplicationContextIn this tutorial we are going to see FileSystemXmlApplicationContext with example program.FileSystemXmlApplicationContext The FileSystemXmlApplicationContext container load the bean definition from XML file.In this container … Read More
  • Spring Framework Modules The Spring Framework consist of features organized into about 20 modules. These modules are grouped into Core Container, Data Access/Integration, AOP(Aspect Oriented Programming), Instrumentation, and Test, as shown in the… Read More
  • Spring Configuration metadataIn this tutorial we are going to see configuration metadata in Spring.You can configure the metadata to Spring container in following way.XML based configurationAnnotation based configurationJava based configuration In above … Read More
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: Spring Configuration metadata Rating: 5 Reviewed By: eHowToNow