Skip to main content

Spring Bean LifeCycle and Configuration

  • Chapter
  • 1079 Accesses

Abstract

The Spring Framework provides an easy way to create, initialize, and connect objects into competent, decoupled, easy to test enterprise-ready applications. Every software application consists of software components that interact, that collaborate and depend on other components to successfully execute a set of tasks. Each software component provides a service to other components, and linking the customer and the provider component is the process known as Dependency Injection. Spring provides a very simplistic way to define the connections between them in order to create an application.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    If you are interested in more books about Java Design Patterns, you can check out this book from Apress: http://www.apress.com/9781484218013?gtmf=s .

  2. 2.

    Oracle was used for data storage in this example because most production applications use Oracle for storage, and this book aims to provide real configurations such as you will probably encounter and need while working in software development.

  3. 3.

    The term “scalar” comes from linear algebra, where it is used to differentiate a number from a vector or matrix. In computing, the term has a similar meaning. It distinguishes a single value such as an integer or float from a data structure like an array. In Spring, scalar refers to any value that is not a bean and cannot be treated as such.

  4. 4.

    You can find them all listed in the Spring Reference http://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#beans-beans-conversion .

  5. 5.

    Factory Method is a design pattern that implies using factory methods to create objects without specifying the exact type of the object being created. More information about this pattern can easily be found on the Internet using a simple search on Google, but here is a quick good source: https://en.wikipedia.org/wiki/Factory_method_pattern .

  6. 6.

    Singleton is a creation pattern that is characterized by the fact that a singleton class can be instantiated only once. More about it can be read here: https://en.wikipedia.org/wiki/Singleton_pattern .

  7. 7.

    Most companies use three types of environments: development, testing, and production.

  8. 8.

    An expression language used to configure web flows: http://docs.spring.io/spring-webflow/docs/current/reference/html/el.html .

  9. 9.

    Unified EL is the Java expression language used to add logic in JSP pages: https://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html .

  10. 10.

    The full list of capabilities is not in the scope of this book. If you are interested in SpEL, the official documentation is the best resource: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/expressions.html .

  11. 11.

    Unfortunately there is no other way to formulate this. We are talking about beans that have the ability to post process other beans. And they are called, confusingly: bean post process beans.

  12. 12.

    Beginning with Spring 2.5, a few annotations are supported.

  13. 13.

    Java Request Specification 250 https://jcp.org/en/jsr/detail?id=250 .

  14. 14.

    DisposableBeanAdapter is an internal infrastructure bean type that performs various destruction steps on a given bean instance. Its code is available here: https://github.com/spring-projects/spring-framework/blob/master/spring-beans/src/main/java/org/springframework/beans/factory/support/DisposableBeanAdapter.java .

  15. 15.

    The Singleton design pattern is therefore used heavily in Spring.

  16. 16.

    AOP is an acronym for Aspect Oriented Programming and is a programming paradigm aiming to increase modularity by allowing the separation of cross-cutting concerns. This is done by defining something called “pointcut,” which represents a point in the code where new behavior will be injected. This allows for business logic agnostic code to be separated from the code, avoiding code cluttering.

  17. 17.

    The Proxy programming design pattern is characterized by the use of a surrogate or placeholder instead of the real intended object. This design template is heavily used in AOP and remoting.

  18. 18.

    Extension of the Java dependency injection API https://jcp.org/en/jsr/detail?id=330 .

  19. 19.

    Bootstrapping in Spring means loading an application context.

  20. 20.

    If you are interested in this feature, you can follow the evolution of the issue here: https://jira.spring.io/browse/SPR-6736 .

  21. 21.

    In practice, you will probably never need to do this; we are doing this to give a concrete example of the use of @AliasFor.

  22. 22.

    It only supports the <constructor-arg /> element for constructor injection and <property /> element for setter injection.

  23. 23.

    The log entries were cleaned up a little, and only a snippet of the log is presented here for obvious reasons.

  24. 24.

    ConfigurationClassBeanDefinitionReader is a Spring internal class and does not appear in the Spring API, but the source code can be found on GitHub at https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassBeanDefinitionReader.java .

  25. 25.

    Java Configuration and stereotype annotations were introduced together, because the Java Configuration is just the second Spring step in totally removing configuration via XML.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2017 Iuliana Cosmina

About this chapter

Cite this chapter

Cosmina, I. (2017). Spring Bean LifeCycle and Configuration. In: Pivotal Certified Professional Spring Developer Exam. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-0811-3_2

Download citation

Publish with us

Policies and ethics