In traditional Java applications, bean lifecycle is very simple. Java keyword new is used to instantiate Bean (maybe non-serialized ). This is enough. On the contrary, bean lifecycle is more detailed in spring containers. Understanding the lifecycle of spring bean is very important, because you may need to use the oppo
Directory
Objective
Body
1. Custom initialization methods and destruction methods
2. How to use annotations
3.InitializingBean, Disposablebean
4. Implement the *aware interface
5.BeanPostProcessor Enhanced Processor
Summarize
What is the life cycle of the bean in the reference link 1:spring?Reference links 2:spring Bean life cycleObjectiveRecent
I. Enterprise Beans
Two different categories of Enterprise beans are defined in the EJB (Enterprise Java Beans):
* Sessions Bean (Session bean)
* Entity Bean (Entity Bean)
1. Sessions Bean (Session bean)
The session
Transfer from http://elim.iteye.com/blog/2017466Execution order:Beanfactorypostprocessor.postprocessbeanfactoryUserBean ' s constructorUserBean ' s Username property setBeanpostprocessor.postprocessbeforeinitializationInitializingbean.afterpropertiessetBeanpostprocessor.postprocessafterinitializationSpring Bean processing--callback functionSpring defines three interfaces that can be used to process the beanfactory of a spring
In the previous blog mentioned in the container launch Get Beandefinition object has a scope property. This property controls the scope of the Bean object. This section describes the scope and life cycle of the bean, and how it does not.
I. Scope of the BeanThe bean container starts reading the bean's XML configuration file, and then converts each
1. Named Bean Each bean has one or more identifiers. These identifiers must be unique within the container in which they are loaded. A bean often has and has only one identifier, but if more than one name is required, additional aliases can be considered. XML-based configuration source file, you can use the ID or the name attribute to specify the
Bean's life cycle:The Spring IOC container can manage the Bean's life cycle,Spring allows custom tasks to be performed at specific points in the Bean life cycle.The process by which the Spring IOC container manages the Bean's life cycle:1 Creating a Bean instance from a constructor or factory method2 setting values and references to other beans for the Bean's properties3 Call the
Configuring a factory bean is usually created by the application using new, and in order to separate the creation and use of the object, the factory pattern is used, where the application takes the creation and initialization responsibility of the object to the factory object. In general, the application has its own factory object to create the bean. If you give the application's own factory object to sprin
Default ScopeIn Spring IOC containers, there are two default bean scopes:
Singleton, the Bean's lifetime and container are synchronized once the bean is created, the bean is destroyed only when the container is closed, the bean with the same ID is instantiated only once during the lifetime of the container, an
Bean's Chinese meaning is "beans", as the name implies JavaBean is aJava applet。 JavaBean actually refers to a special Java class that is typically used toimplement some of the more common simple functions, and can be easily reused or inserted into other applications. All Java classes that follow certain programming principles can be called JavaBean.I. Java Bean Technology OverviewJava beans are Java-based component models that are composed of propert
First, what is a bean?1, Java object-oriented, the object has methods and properties, then you need an object instance to invoke methods and properties (i.e. instantiation);2. All classes that have methods or attributes need to be instantiated to use these methods and attributes in order to be figurative;3. Rule: All subclasses and classes with methods or attributes are added to the annotations of the registered b
One, the spring framework supports five scopes (three of which are available only in the Web-based Spring ApplicationContext).The scope of the built-in support is as follows: Scope description
Singleton
A bean definition corresponds to an object instance in each spring IOC container.
Prototype
A bean definition corresponds to multiple object instances.
Request
The two often come together, or they are often used together. But in fact it is divided into two situations:1 simultaneous use of Factory-bean and Factory-methodIf we configure Factory-bean and factory-method on a bean element at the same time, then it means that the bean is created using the Factory mode, the creator
boiled barley bean porridge has a lot of skills and attention. The barley is very hard, the red bean is also very hard, suppose already boiled in the pot, probably boil one hours not bad, this is a kind of waste fire or electricity, it can even boil water, cause crux.I suggest two ways: the first is to add enough water to the pot. Burn off and then stall. Let the barley and red beans in the pot for half an
In the previous blog mentioned in the container launch Get Beandefinition object has a scope property. This property controls the scope of the Bean object. This section describes the scope and life cycle of the bean, and how it does not.I. Scope of the BeanThe bean container starts reading the bean's XML configuration file, and then converts each
ConceptThe scope described in the Spring Bean, which is the scope property in the configuration file. In object-oriented programming, generally refers to the visible range between an object or a variable. In the spring container, it refers to the requested visible range of the bean object it creates relative to the other bean objectsType of scopeIn the spring con
2.1 ReviewsThe first day I wrote about the bean assembly was some basic syntax or some of the rules of spring itself, but I didn't delve into it. Next, let's discuss the details carefully. Compare the definition of a traditional class with the invocation of a method.This will reflect the characteristics of the IOC. The following UML diagram is one of the interfaces I defined earlier and one of my own implementations. Public Interface Compactdisc {
The spring container is responsible for creating the beans in the application and reconciling the relationships between these objects by ID. As a developer, we need to tell spring which beans to create and how to assemble them together.There are two ways in which bean assembly in spring
Implicit bean discovery mechanism and automatic assembly
Display configuration in Java code or XML
Of co
The Spring IoC container instantiates bean in the following ways:
Singleton only has one bean instance in the Spring IoC container, and the bean exists as a single instance.
Each time prototype calls bean from the container, a new instance is returned, that is, every time getbean () is called, the operation of new xxx
I. OverviewThe container is the core of the spring framework, and the spring container uses IOC to manage all components that comprise the application system. Spring has two different containers: Beanfactory provides the simplest container, provides the most basic dependency injection support, ApplicationContext based on Beanfactory, provides system architecture services such as subordinate files to read text information, Event delivery, and so on.When you assemble a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.