Home » Enterprise Java » spring » Beans

Beans

Spring 3 Scheduler Example – JDK Timer and Quartz Showcase

Spring Framework provides abstractions for execution and scheduling of tasks, supporting thread pools or delegation to CommonJ within an application server environment. Spring also features integration classes for supporting scheduling with the JDK Timer and the Quartz Scheduler, provided by the Quartz scheduling library. Both schedulers are set up using a FactoryBean with optional references to Timer or org.quartz.Trigger instances, ...

Read More »

Spring Object to XML Mapper

With this tutorial we shall show you how to convert Objects to xml and vice versa, using Spring’s Object/XML Mapping support. Object/XML Mapping, or O/X mapping for short, is the act of converting an XML document to and from an object. This conversion process is also known as XML Marshalling, or XML Serialization. Within the field of O/X mapping, a ...

Read More »

Spring Autowire Example

In this example we shall show you how to use Spring Autowiring features to wire beans in other beans. The Spring container can autowire relationships between collaborating beans. Spring offers the auto-wiring modes below: Auto-Wiring ‘no’ : It is the default mode that includes no autowiring. Bean references must be defined via a ref element. Changing the default setting is ...

Read More »

Spring Bean Lifecycle Example

With this tutorial we shall show you how to use Spring’s initialization and destruction methods to control a Spring Bean’s lifecycle. Sometimes, specific actions need to be performed upon a bean creation or when a bean is destroyed. Spring provides simple ways to perform actions in a bean’s lifecycle start and end. The first way provided by Spring to perform ...

Read More »

Spring Dependency Checking Example

This is an example of how to check dependencies in a Spring Bean. A Spring Bean can have dependencies of any type, such as primitive types, Collections or even Objects that are references to other beans. Sometimes it is necessary that specific dependencies have to be set, so that a Spring Bean is instantiated correctly. Spring provides developers the ability ...

Read More »

Spring Bean Configuration Inheritance Example

This is a tutorial about the Configuration Inheritance between Spring Beans. In Spring, a bean definition can contain a lot of configuration information, including constructor arguments, property values, and container-specific information such as initialization method, static factory method name, and so on. A child bean definition is able to inherit configuration data from a parent definition. The child definition can ...

Read More »

Spring PropertyPlaceholderConfigurer Example

With this tutorial we are going to demonstrate how to use the PropertyPlaceholderConfigurer. The PropertyPlaceholderConfigurer is a property resource configurer that resolves placeholders in bean property values of context definitions. It pulls values from a properties file into bean definitions. We can use it to externalize property values from a bean definition in a separate file using the standard Java ...

Read More »

Spring Inject Date into Bean property with CustomDateEditor

In this example we shall show you how to inject a Date property in a Spring Bean, using the CustomDateEditor. The CustomDateEditor is a class provided by the Spring API and is used as a Property editor for java.util.Date, supporting a custom java.text.DateFormat. In order to use CustomDateEditor for date injection in a Spring Bean property, we first have to ...

Read More »

Spring Collections (List, Set, Map and Properties) Example

With this example we shall show you how to inject Collections in Spring Beans properties. The types of Collections that are supported by Spring are List, Set, Map and Properties. In order to show how the Collections can be injected in a Spring Bean we will create a simple Spring Bean with four properties, List, Set, Map and Properties. Our ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns