Giriş
Normalde sadece @Inject anotasyonunu kullanmak yeterli. CDI bu anotasyonu tarar ve gerekli bean bilgilerini toplar. Açıklaması şöyle
All the classes on your classpath are scanned and metadata is assembled for all possible CDI beans.Ancak eğer arzu edilirse CDI davranışı değiştirilebilir ve sadece anotasyonlara sahip bean'lerin taranması sağlanabilir. Açıklaması şöyle
There is an option to exclude certain packages from scanning, if you want to limit the creation of the metadata. This is checked with all injection points that are defined to see if there is a match which guarantees that the entire dependency mechanism will work properly for your application.
Açıklaması şöyle
By default, CDI picks up annotated beans with the aforementioned bean-defining annotations. This behavior can be changed as topick up all beanspick up no beans at all (none)by providing the corresponding value to the attribute bean-discovery-mode in the beans.xml file, which is located either in /WEB-INF/, or in /WEB-INF/classes/META-INF/
Açıklaması şöyle
Providing an empty beans.xml file is equivalent to explicitly using the value all:BEANS.XML PRESENT? BEAN-DISCOVERY-MODE IN BEANS.XML EFFECTIVE BEAN- DISCOVERY-MODEno - annotatedyes (empty file) - allyes annotated annotatedyes all allyes none none
Örnek - all
Şöyle yaparız.
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> </beans>
Örnek - all
Şöyle yaparız
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" version="2.0" bean-discovery-mode="all"> </beans>
Örnek - annotated
Şöyle yaparız. Burada CDI davranışı değiştiriliyor
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaeehttps://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"bean-discovery-mode="annotated"></beans>
alternatives Tag
Jakarta EE @AlternativeAnotasyonu yazısına taşıdım
Jakarta EE @Interceptor Anotasyonu yazısına taşıdım
Hiç yorum yok:
Yorum Gönder