Alexey Kazakov [
http://community.jboss.org/people/akazakov] modified the blog post:
"Overview of Context Dependency Injection Tools"
To view the blog post, visit:
http://community.jboss.org/community/tools/blog/2011/01/31/overview-of-co...
--------------------------------------------------------------
The very first version of Context Dependency Injection (CDI) Tools was introduced as a
part of JBoss Tools 3.1.0. But now JBoss Tools 3.2 is moving to its first stable release.
Let's have some review of main features of the improved and up coming CDI Tools in
JBoss Tools 3.2.
h3. *Enabling CDI support*
First at all we need to enable CDI support for the project. If you already have some CDI
project and don't want to start from scratch then just go to+Project
Properties->CDI->CDI support+ to enable all the features.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11251/00...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
If your project is Maven-based and the pom.xml references the CDI api jars CDI support
will be enabled automatically. If you want to create a brand new WTP project with CDI
support, just add a CDI facet to the list of installing facets.
See Max's blog
http://community.jboss.org/community/tools/blog/2010/12/10/simple-cdi-hel...
Simple CDI Hello World with Eclipse and JBoss Tools for details.
Make sure you have CDI support enabled for all the related projects. For instance if you
have a web project (is to deployed as WAR) which uses some Java project (JAR) then both
projects should have CDI support enabled.
If you are interested in Weld examples (Weld is the reference implementation of CDI spec.)
you can download it from JBoss Tools example site.+Help->Project Examples->Weld
1.0.1+
+
+
+http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11252/01examples.png
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
+
h3. *CDI Wizards*
There are a set of CDI Wizards to help you to create basic CDI artifacts. The wizards are
available in +File->New->Other...->CDI+
+
+
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11253/02...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11254/03...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
h3. *CDI validation*
CDI validation covers most of the rules declared in the JSR-299 specification. There are
100+ validation rules including definition errors and deployment problems. You can see the
full list in the CDI Preferences, where you can also control which rules you want to be
Errors, Warnings or simply Ignored.
*http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11255/04validation.png
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
*
The CDI validator checks for problems in java source files, JSP, XHTML and beans.xml
files.
Some of the validation problems can be fixed via Quick Fixes menu (Ctrl+1):
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11256/05...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
h3. *Code completion*
Another useful feature is a code completion. CDI tools provides two types of code
completion. Code completion for @Named beans and their members which are available in EL
expressions:
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11257/06...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
And code completion for the relevant types/annotations in beans.xml:
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11258/07...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
h3. *Hyperlinks (OpenOns)*
Hyperlinks help you to navigate between source files. For example Ctrl+Click or F3 on any
EL will navigate you to the corresponding java source.
For Injection's it is a bit more tricky. The built-in Java hyperlink for its declared
type will open the type. But for Injection there are additional relevant items to navigate
to. CDI Tools offers you an alternative navigation to the actual bean which is to be
injected.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11259/08...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1125...
If the injection has multiple eligible beans, you can see a full list of these beans.
Btw. you can fix the multiple eligible beans via a quick-fix (Ctrl+1).
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11260/09...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1126...
Also you can open the corresponding class/interface mentioned in beans.xml via the same
Ctrl+Click on the type name.
Observers and Events can be navigated to via OpenOn too.
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11261/10...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1126...
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11262/11...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1126...
As well as Producer and Disposer methods:
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11263/12...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1126...
http://community.jboss.org/servlet/JiveServlet/showImage/38-3559-11264/13...
http://community.jboss.org/servlet/JiveServlet/downloadImage/38-3559-1126...
At last we also have:
* EL refactoring. For example if your name the method/field or class name of some bean
using Java refactoring dialogs CDI Tools will offer you to update all the EL expressions
that use this method/field/type.
* Related CDI Beans are added in search result for field/method references search. See
http://screencast.com/t/NGUxOTA5YmQt demo movie.
h3. Feedback
This was a quick overview of the main features of up coming JBoss Tools 3.2 for CDI
developers.
If you think CDI Tools misses some useful functionality then please create a feature
request in
https://issues.jboss.org/browse/JBIDE JIRA! We are working to help you to
enjoy this exciting world of CDI :)
--------------------------------------------------------------
Comment by going to Community
[
http://community.jboss.org/community/tools/blog/2011/01/31/overview-of-co...]