When is Spring bean destroyed by default? - spring

By default Spring beans are singletons, so are beans destroyed if application is shut-down? Or is there any bean time-out?

Related

In spring are all the beans created at the time of container creation

If I have 1000 bean configurations in .xml file are all these beans created at the time of creation of the container
By default yes. All beans get created on startup. There's the #Lazy annotation which allows you to delay the initialization until the bean gets used.

Spring Dependency injection, singleton bean injection

In Spring Dependency injection, if a prototype bean is injected in a singleton bean and after declaring the applicationcontext i am calling the getbean method for the singleton class object, then how many new instances are created for the prototype bean inside the singleton object?
Spring creates new instance of prototype bean every time it needed (for each #Autowired in application context). So in your case Spring creates only one instance of prototype (to inject it into a singleton bean).

Spring PropertyPlaceholderConfigurer loads property files during startup?

Anyone know, if Spring PropertyPlaceholderConfigurer loads property files during app startup?
If so, does it do by default or we have to set some kind of parameter to make sure it loads during app startup
PropertyPlaceholderConfigurer is a bean factory postprocessor. A bean post processor works with the bean factory before any bean has bean instantiated (other than other bean factory postprocessors).It alters the bean factory.
Therefore it always runs at application startup to resolve property values delimited with ${}. It will never execute again in the lifecycle of the Spring application.

Inject spring bean into CDI(weld) bean

I have see articles around how we can inject spring beans into JSF managed bean. We don't use JSF managed bean but use CDI(Weld) bean. How can we inject spring bean into CDI(weld) bean.

Spring ServletContext bean (i.e. Controller) injection into ApplicationContext bean (i.e. Service, Dao)

In Spring, relationship between Application Context and Servlet Context is like parent-child. Application Context is the parent here. So, beans of Servlet Context know beans of Application Context, but vise versa is not true. But if I need to do that, is there any way ?
For simplicity, if I inject an Controller into an Service class, what I need to do ? Is there any Application Context refreshing mechanism, after Servlet Context is initialized ?

Resources