[cdi-dev] Full rewrite for CDI 558 / PR 270

Antoine Sabot-Durand antoine at sabot-durand.net
Fri Feb 5 09:24:01 EST 2016


Hi all,

Following discussion during last meeting, I rewrote most of my PR for
builders.

We now have 2 clean and distinct ways of using them

1) in DSL style (with a Configurator interface without build() method)

public void processAT(@Observes ProcessAnnotatedType<?> pat) {
  pat.setAnnotatedType().read(pat.getAnnotatedType()).addToType(new
AnnotationLiteral<MyInterceptor>() {};);
}


2) In classical reusable builder mode (builders extends configurator and
only add build() method)

public void processAT(@Observes ProcessAnnotatedType<?> pat) {
 AnnotatedTypeBuilder atb = Builders.annotatedTypeBuilder();
 atb.read(pat.getAnnotatedType()).addToType(new
 AnnotationLiteral<MyInterceptor>() {};);
  pat.setAnnotatedType(atb.build());
}


As Configurators don't have build() method there's no risk that users mix
them with standard builders.
For clarity sake, builders are no more available in lifecycle event but in
Builders class for consistency.

I'm quite happy with the result, but I'm sure you'll have comment ;). So
thanks for your feedback

https://github.com/cdi-spec/cdi/pull/270

Antoine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20160205/6d66234b/attachment.html 


More information about the cdi-dev mailing list