- Developing Middleware in Java EE 8
- Abdalla Mahmoud
- 84字
- 2021-07-23 19:24:34
Initializer method parameter injection
Initializer method parameter injection is a mechanism for injecting CDI beans, where a method is marked with @Inject to be called by the container in order to inject the required CDI bean. Here, we will show the previous example rewritten to use the initializer method parameter injection mechanism rather than the constructor parameter injection:
@Dependent public class AnotherPojo { private MyPojo myPojo; @Inject public void setMyPojo(MyPojo myPojo) { this.myPojo = myPojo; } public String getMessage() {
return myPojo.getMessage(); } }
推薦閱讀
- Android Wearable Programming
- Beginning Java Data Structures and Algorithms
- HoloLens Beginner's Guide
- Python爬蟲開發:從入門到實戰(微課版)
- 實戰Java程序設計
- AIRAndroid應用開發實戰
- AngularJS深度剖析與最佳實踐
- Visual Basic程序設計教程
- 64位匯編語言的編程藝術
- Mastering Swift 2
- JavaScript 程序設計案例教程
- RabbitMQ Cookbook
- Learning Concurrent Programming in Scala
- CoffeeScript Application Development Cookbook
- DevOps 精要:業務視角