cdi pooling

0

Cześć,

Jak działa POJO wstrzyknięte przez CDI w beanie EJB ?
Czy gdy w puli mam 50 obiektów EJB, to utworzony zostaje tylko jeden bean CDI ? (zakładam, że nie ma nigdzie adnotacji @New), czy może dla każdego beana zostanie skonstruowany nowy obiekt?

Pozdr,

np.

@Stateless
class Foo {
   @Inject Bar;
}

bar - mam Od razu zadeklarowane 50 obiektów, czy jest to ciągle ten sam udostępniany przez proxy? :>

0

A ten Bar to co? Mam zgadywać? To jest jakiś @Named czy co? To ile i jak będzie tworzone Bar zależy od tego jak ta klasa wygląda... Jak to jest zwykły singletonowy @Named to będzie jeden.

0
Shalom napisał(a):

A ten Bar to co? Mam zgadywać? To jest jakiś @Named czy co? To ile i jak będzie tworzone Bar zależy od tego jak ta klasa wygląda... Jak to jest zwykły singletonowy @Named to będzie jeden.

Zakładam, że tylko @default

0

W CDI domyślny scope to nie jest Singleton (to nie Spring). Domyślnym scope w CDI jest pseudoscope @Dependent.

An instance of a dependent bean is never shared between different clients or different injection points. It is strictly a dependent object of some other object. It is instantiated when the object it belongs to is created, and destroyed when the object it belongs to is destroyed.

https://docs.jboss.org/weld/reference/latest/en-US/html/scopescontexts.html

0
NiebieskiFlaming napisał(a):

W CDI domyślny scope to nie jest Singleton (to nie Spring). Domyślnym scope w CDI jest pseudoscope @Dependent.

An instance of a dependent bean is never shared between different clients or different injection points. It is strictly a dependent object of some other object. It is instantiated when the object it belongs to is created, and destroyed when the object it belongs to is destroyed.

https://docs.jboss.org/weld/reference/latest/en-US/html/scopescontexts.html

Dzięki :)
Czyli pool 50 beanów stateless tworzy mi 50 obiektów. Gitareczka! :)

0

Właśnie miałem pytać, w takim razie czy robi się jakaś optymalizacja proxy :P
Beans with scope @Dependent don’t need a proxy object. The client holds a direct reference to its instance.

0

Tak samo w @Signleton nie masz proxy. Pozostale scope'y ida przez proxy.

1 użytkowników online, w tym zalogowanych: 0, gości: 1