public class DependentScopedClass {
//This class has no scoping annotations, so a new instance gets created at every injection point.
@Inject
public DependentScopedClass(SomeDependency someDependency) {
doSomethingWith(someDependency);
}
}
The default scope for most CDI beans is referred to as dependent scope. A class that does not contain any scope annotation will be treated as dependent scope, unless it is a JAX-RS resource or provider (resources default to request scoped, and providers default to application scoped). An instance of a dependent scope class lives as long as the object it is injected into does. Any time a class gets constructed and has a dependent scope class as a dependency, the dependent scoped class gets created and injected directly into the object which needs it. The significance of this will become apparent after later examples.