Slide 1

Slide 1 text

C D G 9 6 02 1# 5 8 0/ / 2 5 8 0/ / 2 .2 /1 2

Slide 2

Slide 2 text

( ) ● Japan JBoss User Group ● Red Hat Consultant ● Twitter: @neverbird 2

Slide 3

Slide 3 text

● 4 ○ J ○ E ○ a ○ ○ ○ J ○ ○

Slide 4

Slide 4 text

5 Application CDI Container CDI API CDI SPI Extension Extension Extension ●

Slide 5

Slide 5 text

fminamot-OSX:base fminamot$ grep -r javax.enterprise.inject.spi.Extension . Binary file ./org/wildfly/microprofile/opentracing-smallrye/main/wildfly-microprofile-opentracing-smallrye- 7.2.0.GA-redhat-00005.jar matches Binary file ./org/jboss/jts/main/narayana-jts-idlj-5.9.0.Final-redhat-00001.jar matches Binary file ./org/jboss/resteasy/resteasy-jaxrs/main/resteasy-client-microprofile-3.6.1.SP2-redhat-00001.jar matches Binary file ./org/jboss/resteasy/resteasy-cdi/main/resteasy-cdi-3.6.1.SP2-redhat-00001.jar matches Binary file ./org/jboss/narayana/txframework/main/txframework-5.9.0.Final-redhat-00001.jar matches Binary file ./org/jboss/narayana/compensations/main/compensations-5.9.0.Final-redhat-00001.jar matches Binary file ./org/jberet/jberet-core/main/jberet-core-1.3.1.Final-redhat-00001.jar matches Binary file ./org/picketlink/core/main/picketlink-impl-2.5.5.SP12-redhat-2.jar matches Binary file ./org/hibernate/validator/cdi/main/hibernate-validator-cdi-6.0.14.Final-redhat-00001.jar matches Binary file ./org/glassfish/soteria/main/javax.security.enterprise-1.0.0.redhat-1.jar matches Binary file ./io/smallrye/config/main/smallrye-config-1.3.4.redhat-00001.jar matches Binary file ./javax/enterprise/api/main/cdi-api-2.0.0.SP1-redhat-00001.jar matches Binary file ./com/sun/jsf-impl/main/jsf-impl-2.3.5.SP2-redhat-00001.jar matches 6

Slide 6

Slide 6 text

● 65 .50 ( 50 5 5 365 26 . . )) ○ a S ○ aP e ○ J B ● S D ( ○ . . )E I R B ○ Ce f d F JE E / A ( Cic 7 8 8

Slide 7

Slide 7 text

8 @Inject Foo foo; @Scoped public class FooImpl implements Foo @ApplicationScoped public class MyApp !

Slide 8

Slide 8 text

● B . ● . 10 Application CDI Container CDI API Bean Metadata Bean Archives Bean .

Slide 9

Slide 9 text

● ● I> ● CA I> ● T B ● D < @ ● 11

Slide 10

Slide 10 text

D C ● ● / / / B ● ● B ● ● 12

Slide 11

Slide 11 text

C 13 CDI Container Bean Archives 1. 2. ProcessAnnotatedType 3. event.add (…) Extension

Slide 12

Slide 12 text

● 14

Slide 13

Slide 13 text

15 P M M B I O B I DA

Slide 14

Slide 14 text

B CIA 16 >B ; C A ( C E C A C A AE> E E ; > >>; A . > ; -B ; ( B;A A ; . ) > B A D E E @Observes CDI 2.0 A D @ O D LI

Slide 15

Slide 15 text

R E / / / 17 @ApplicationScoped public class MyBean { @Retry(maxRetries=3) public void sendMessage(String message) { / } }

Slide 16

Slide 16 text

● 3 H S R @I 3 18 / ( . . . ( . ) ( . 3 ) . . ( ; ; 1 1 1 1 =

Slide 17

Slide 17 text

● D ○ B ● D ○ I ■ C 1 19

Slide 18

Slide 18 text

RetyExtension 20 public class RetryExtension implements Extension { / public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager bm) { event.addAnnotatedType(RetryInterceptor.class, RetryInterceptor.class.getName()); } 1 public void processManagedBean(@Observes ProcessManagedBean event) { AnnotatedType> annotatedType = event.getAnnotatedBeanClass(); for (AnnotatedMethod> annotatedMethod : annotatedType.getMethods()) { Retry anno= annotatedMethod.getAnnotation(Retry.class); if (anno != null && anno.maxRetries() < 1) { event.addDefinitionError(new Exception("illegal maxRetry:" + anno.maxRetries())); } } } }

Slide 19

Slide 19 text

21

Slide 20

Slide 20 text

● SmallRye config ○ " #$' ● SmallRye fault tolerant ○ CircuitBreaker, Retry, Timeout% $' ● SmallRye metrics ○ (!& $' / / /. . 22

Slide 21

Slide 21 text

● CDI http://cdi-spec.org/ ● Next Presso http://www.next-presso.com/ ● Weld https://tanoseam.wordpress.com/ ● SmallRye (Eclipse MicroProfile implementation) https://smallrye.io/ https://github.com/smallrye 23

Slide 22

Slide 22 text

Red Hat 24

Slide 23

Slide 23 text

● E D C 25 ./

Slide 24

Slide 24 text

IBD A IC 26 J J J J J J J J J J n J n J J J e J BJ a J J

Slide 25

Slide 25 text

. 27 / b I D / i c d E I S E I 0 / : > ErnJ D -/ / . mtJ D -/ / / / 2 o 0 / : > / 0 / : > B >:2C / 0 / : > B >:2C / 2 :1 2 / / 2 / s 0 / : > B >:2C :1/ >1 <2 a e li

Slide 26

Slide 26 text

. 28 < B A > javax.enterprise.inject.spi. >A ● < . . / . -

Slide 27

Slide 27 text

29 / . -

Slide 28

Slide 28 text

CDI 2.0AnnotatedTypeConfigurator CDI 1.x CDI 2.0 AnnotatedTypeConfigurator 30 public interface BeforeBeanDiscovery { void addQualifier(Class extends Annotation> qualifier); void addQualifier(AnnotatedType extends Annotation> qualifier); void addScope(Class extends Annotation> scopeType, boolean normal, boolean passivating); void addStereotype(Class extends Annotation> stereotype, Annotation... stereotypeDef); void addInterceptorBinding(AnnotatedType extends Annotation> bindingType); void addInterceptorBinding(Class extends Annotation> bindingType, Annotation... bindingTypeDef); void addAnnotatedType(AnnotatedType extends Annotation> type, String id); AnnotatedTypeConfigurator addAnnotatedType(Class type, String id); AnnotatedTypeConfigurator configureQualifier(Class qualifier); AnnotatedTypeConfigurator configureInterceptorBinding(Class bt); }

Slide 29

Slide 29 text

CDI 2.0AnnotatedTypeConfigurator CDI 1.x CDI 2.0 AnnotatedTypeConfigurator 31 public interface ProcessAnnotatedType { AnnotatedType getAnnotatedType(); void setAnnotatedType(AnnotatedType type); void veto(); AnnotatedTypeConfigurator configureAnnotatedType(); }