If the parent is not single, then are the children single?

I have a Tao that is not Singleton, if other objects extend from it, is it solitary or not? code example

<bean id="dao" class="parentDao" scope="prototype"> </bean> <bean id="childrenDao" class="some.dao.extends.parentDao" parent="parentDao"> </bean> 

is childrenDao singleton?

+2
source share
2 answers

Update . It is checked using a test, the region is also inherited from the parent bean and can be overridden by the child. Therefore, in this case, childrendDao will be the prototype.

This is what the reference document states: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/beans.html#beans-child-bean-definitions

The definition of a child bean inherits the values โ€‹โ€‹of the constructor argument, the value property and method overrides the parent element, with the ability to add new values. Any initialization method, destruction method, and / or static factory Method parameters that you specify override the corresponding parent settings.

The rest of the settings are always taken from the definition of the child: it depends on the auto-mode, dependency checking, singleton , scope, lazy initialization.

+4
source
  <bean id="dao" class="parentDao" scope="prototype"> </bean> <bean id="childrenDao" class="some.dao.extends.parentDao" parent="parentDao"> 

In this case, childrenDao will be singleton . I tested it because I became friendly when I saw some confusing answers.

0
source

Source: https://habr.com/ru/post/1209279/


All Articles