Interceptors 1.2 Specification
This session was held by Marina Vatkina and Emmanuel Bernard about JSR-318, the Interceptors 1.2 specification. Its basically a cleanup of the previous version with a few new features. Summary:
- Better, more organized, cleaner specification with better separation from other specs.
- Interceptor binding is now part of this specification (moved from CDI spec).
- No ejb-jar.xml elements in the specification (moved to EJB spec).
- New @AroundConstruct annotation to apply around object constructors. Note that this completes before injection happens!
- New @Priority annotation in EE 7 for ordering interceptors.
Influence of Bean Validation 1.1
Emmanuel Bernard went on explaining how the Bean Validation 1.1 features influenced the new Interceptors specification, namely:
- Return value and parameter (including constructor parameter) validation upon method calls. This was a strongly missing feature from BV 1.0. In this context the validation should really happen on method calls, not triggered by some clever framework or custom enforcement point, so there needs to be a way to do this. This is where interceptors come into the picture.
- Validations need to be executed as late as possible in the interceptor chain, so there needs to be some kind of ordering. @Priority is the solution for this.
Note: The BV 1.1 reference implementation uses a CDI portable extension to programmatically add interceptors based on the validation annotations, so it is fully standard and interoperable Java EE solution.
Interceptor Ordering
Important properties of the @Priority annotation:- It is defined on the interceptor class, not on the intercepted class.
- Ordering is undefined for interceptors that have the same priority.
- EJB style interceptor declaration (@Interceptors) ignores this annotation as there would be no reasonable way to resolve priority conflicts.
- There are some useful predefined values in the Interceptor.Priority class like PLATFORM_BEFORE, LIBRARY_BEFORE, APPLICATION etc. Suggested best practice is to define your custom ranges between these values so that they have a meaning in this context.
- interceptors bound using @Interceptors as ordered in the annotation
- interceptors bound using @InterceptorBinding, ordered by their @Priority
- interceptors on the target class (superclass first) (e.g. @PostConstruct)
- interceptors on the target method or constructor
Others
Other slight modifications are that lifecycle callback method signatures can have return values and can throw checked exceptions now. This is just to avoid boilerplate try-catch code as InvocationContext.proceed() can throw checked exceptions. Note that this is only the signature, they are still not allowed to do so!
There is a new @Transactional annotation in EE 7 for JTA declarative transactions that can be applied to CDI managed beans, but not to EJBs (as it would conflict with JTA EJB interceptors). (Note that transactional interceptors have a mandated predefined @Priority. See the javadoc.)
That was it, it was nice to hear the new Interceptor and Bean Validation features. BTW did you know that in BV 1.1 you can inject resources into your constraint validators? That was missing before as well.
Cheers.
Update: Here is the link for the presentation's site and the slides.
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.
VálaszTörlésGreat Article
VálaszTörlésIEEE Final Year Projects for CSE
IEEE Project Centers in Chennai
Lovely blog...! It is one of the best posts for this topic and I really appreciate your great efforts. Keep continuing...
VálaszTörlésPlacement Training in Chennai
Best placement Training institutes in Chennai
Power BI Training in Chennai
Graphic Design Courses in Chennai
Pega Training in Chennai
Oracle DBA Training in Chennai
Oracle Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Tableau Training in Chennai
Appium Training in Chennai
Placement Training in Anna Nagar
This Blog is really informative!! keep update more about this...
VálaszTörlésAviation Academy in Chennai
Air Hostess Training in Chennai
Airport Management Courses in Chennai
Best Aviation Academy in Chennai
Ground Staff Training in Chennai
Air Hostess Academy in Chennai
Airport Management Training in Chennai
Airport Ground Staff Training Courses in Chennai
I'm very pleased to discover this site. I need to to thank you for ones time just for this wonderful read!!
VálaszTörlésSelenium Training in chennai | Selenium Training in annanagar | Selenium Training in omr | Selenium Training in porur | Selenium Training in tambaram | Selenium Training in velachery
The blog is really informative. Thanks for sharing this awesome blog with us.
VálaszTörlésAngularJS training in chennai | AngularJS training in anna nagar | AngularJS training in omr | AngularJS training in porur | AngularJS training in tambaram | AngularJS training in velachery
[no anchor text]
VálaszTörlés[no anchor text]
[no anchor text]
http://www.happierit.com
http://www.happierit.com
http://www.happierit.com
http://www.happierit.com
[no anchor text]
[no anchor text]
VálaszTörléshttp://www.happierit.com
http://www.happierit.com
http://www.happierit.com
http://www.happierit.com
http://scottish government topics
http://scottish Government Topics
yaando.com
Amazing Article ! I would like to thank you for the efforts you had made for writing this awesome article.
VálaszTörlésThanks for sharing such a nice info.I hope you will share more information like this. please keep on sharing!
internship in chennai
internship in chennai for cse
internship for mba in chennai
internship in chennai for hr
internship in chennai for mba
companies for internship in chennai
internship in chennai for ece
paid internship in chennai
internship in chennai for biotechnology
internship in chennai for b.com students
Amazing Article,Really useful information to all So, I hope you will share more information to be check and share here.
VálaszTörlésinternship in chennai for electrical engineering students
one month internship in chennai
vlsi internship in chennai
unpaid internship in chennai
internship for hr in chennai
internship training chennai
internship for freshers in chennai
internship in chennai for it students with stipend
internship in accenture chennai
naukri internship in chennai