ProtoScope
and SingletonScope
. The SingletonScope
is the default scope, used when no scope is specified explicitly. Beans of this scope are unique for the whole Petite container and will be instantiated by container only once. On the other hand, beans of ProtoScope
are instantiated every time when lookuped.foo
is retrieved from the container, a new instance of Foo
class will be created. And each time Petite will inject the same instance of Boo
class, since scope of boo
bean is (implicitly set as) SingletonScope
.ProtoScope
- beans are created each time requested.SingletonScope
- beans are singletons for the container.SessionScope
- beans are singletons in current HTTP session. To have this feature, the RequestContextListener
must be used.ThreadLocalScope
- beans are unique in the current thread.SessionScope
(in a servlet container), the following listeners has to be added to the web.xml
: