Java Magazine, Nov/Dec 2017
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2017 40 java ee 8 And consider this @ Named informal public class MyGreeting2 implements MyGreeting @ Override public String getGreet return Hiya With CDI 20 you can easily look up all MyGreeting candidates and process these via a JDK 8 stream Instance MyGreeting myGreetings CDI current select MyGreeting class myGreetings stream forEach e out println e getGreet This code prints Ay up and Hiya to the standard output Because its a normal JDK 8 stream any other operation can be applied to it if needed such as filtering mapping and so on Selecting a single specific instance from the myGreetings preselection can be done as follows MyGreeting greeting myGreetings select NamedLiteral of northern get Or without the preselection it can be done in one step MyGreeting greeting CDI current
You must have JavaScript enabled to view digital editions.