Giriş
Açıklaması şöyle
Even though the @Produces annotation is used for defining injectable beans, methods with this annotation also benefit from dependency injection
Örnek
Şöyle yaparız
@Produces MyBean mb(InjectMe injectMe) { // "injectMe" is injected and can be used for constructing "MyBean" return new MyBean(injectMe); }
Örnek
Şöyle yaparız
public interface Connection extends AutoCloseable {void commit(String execute);}@ApplicationScopedclass ConnectionProducer {@ProducesConnection getConnection() {return new SimpleConnection();}public void dispose(@Disposes Connection connection) throws Exception {connection.close();}}
Hiç yorum yok:
Yorum Gönder