Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

when will spring container manage objects?  RSS feed

 
nilesh shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what makes spring container maintain lifecycle and resources of an object? Is it only when the object is instantiated using spring config files? If I extend a spring class, for example, I extend LDAPContextSource and instantiate an object of the extended class in my java module (and not via spring config files) will this object be maintained by spring? I am mainly asking if spring will still manage the resources and connection pooling for this context source.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or example, I extend LDAPContextSource and instantiate an object of the extended class in my java module (and not via spring config files) will this object be maintained by spring?

No. If you instantiate it yourself, how Spring is going to know about it ?
 
nilesh shah
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christopher for the response. I was leaning towards the same answer but I just wanted to make sure that spring is not magically tracking all spring related objects.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!