Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CDIポータブルエクステンションを作ってみよう
Search
Fusayuki Minamoto
May 18, 2019
Technology
0
10k
CDIポータブルエクステンションを作ってみよう
JJUG CCC 2019 Spring登壇資料 (ccc_m6b)
Fusayuki Minamoto
May 18, 2019
Tweet
Share
Other Decks in Technology
See All in Technology
ドメインイベントを活用したPHPコードのリファクタリング
kajitack
2
780
心に火を灯すヒントは自分の中にある/The clue to lighting a fire in your heart is within you.
bitkey
1
130
年末調整プロダクトの内部品質改善活動について
kaomi_wombat
0
130
製造業の会計システムをDDDで開発した話
caddi_eng
2
780
Keynote - KCD Brazil - Platform Engineering on K8s (portuguese)
salaboy
0
110
BCMathを高速化した一部始終をC言語でガチ目に解説する / BCMath performance improvement explanation
sakitakamachi
2
600
AIエージェントキャッチアップと論文リサーチ
os1ma
3
250
Alpine.js を活用した Laravel MPA フロントエンド最適化戦略 / Alpine.js MPA
tzmfreedom
1
600
バクラクでのSystem Risk Records導入による変化と改善の取り組み/Changes and Improvement Initiatives Resulting from the Implementation of System Risk Records
taddy_919
0
150
Go の analysis パッケージで自作するリファクタリングツール
kworkdev
PRO
1
330
一人QA時代が終わり、 QAチームが立ち上がった話
ma_cho29
0
220
ソフトウェア開発現代史: なぜ日本のソフトウェア開発は「滝」なのか?製造業の成功体験とのギャップ #jassttokyo
takabow
1
280
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
244
12k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
The Language of Interfaces
destraynor
156
24k
Being A Developer After 40
akosma
89
590k
Java REST API Framework Comparison - PWX 2021
mraible
29
8.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
It's Worth the Effort
3n
184
28k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.4k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
Transcript
C D G 9 6 02 1# 5 8 0/
/ 2 5 8 0/ / 2 .2 /1 2
( ) • Japan JBoss User Group • Red Hat
Consultant • Twitter: @neverbird 2
• 4 ◦ J ◦ E ◦ a ◦ ◦
◦ J ◦ ◦
5 Application CDI Container CDI API
CDI SPI Extension Extension Extension •
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
• 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
8 @Inject Foo foo; @Scoped public class
FooImpl implements Foo @ApplicationScoped public class MyApp !
• B . • . 10 Application CDI Container CDI
API Bean Metadata Bean Archives Bean .
• •
I> • CA I> • T B • D < @ • 11
D C • • / / / B • •
B • • 12
C 13 CDI Container Bean Archives 1. 2.
ProcessAnnotatedType<MyBean> 3. event.add (…) Extension
•
14
15 P M M B
I O B I DA
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
R E / / /
17 @ApplicationScoped public class MyBean { @Retry(maxRetries=3) public void sendMessage(String message) { / } }
• 3 H S R @I 3 18 / (
. . . ( . ) ( . 3 ) . . ( ; ; 1 1 1 1 =
• D ◦
B • D ◦ I ▪ C 1 19
RetyExtension 20 public class RetryExtension implements Extension { / public
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager bm) { event.addAnnotatedType(RetryInterceptor.class, RetryInterceptor.class.getName()); } 1 public <T> void processManagedBean(@Observes ProcessManagedBean<T> 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())); } } } }
21
• SmallRye config ◦ " # $' • SmallRye fault
tolerant ◦ CircuitBreaker, Retry, Timeout% $' • SmallRye metrics ◦ (!& $' / / /. . 22
• 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
Red Hat 24
• E D C
25 ./
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
. 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
. 28 < B A > javax.enterprise.inject.spi. >A • <
. . / . -
29 / . -
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); <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> type, String id); <T extends Annotation> AnnotatedTypeConfigurator<T> configureQualifier(Class<T> qualifier); <T extends Annotation> AnnotatedTypeConfigurator<T> configureInterceptorBinding(Class<T> bt); }
CDI 2.0AnnotatedTypeConfigurator CDI 1.x CDI 2.0
AnnotatedTypeConfigurator 31 public interface ProcessAnnotatedType<X> { AnnotatedType<X> getAnnotatedType(); void setAnnotatedType(AnnotatedType<X> type); void veto(); AnnotatedTypeConfigurator configureAnnotatedType(); }