Card 01/ 06
All 6 cards
ConceptDifficulty: Beginner1 min
What Makes an Object a Bean
new RideNotifier() produces an object. It does not produce a bean — not until something other than your own code decided to create it, wired what it needs, and is holding on to it.
A bean is an object the Spring container created, configured and manages the life of. That is the whole definition, and it rules out two things people often assume: a bean is not any object a Spring-managed class happens to hold a reference to, and it is not limited to objects wearing one particular annotation, such as @Entity. It is defined by who made it and who is minding it, not by what it is.
So asking "is this a bean?" is really asking one question: did the container create this, or did I?