Skip navigation

JBoss Tools

1 Post authored by: Alexey Kazakov

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.

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 toProject Properties->CDI->CDI support to enable all the features.

 

00enableCDI.png

 

 

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 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


01examples.png

 

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


02wizards.png

 

03newStereotype.png

 

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.

 

04validation.png

 

 

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):

 

05nonBusinessProducer.png

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:

 

06elca.png

 

 

And code completion for the relevant types/annotations in beans.xml:

 

07beansXmlCA.gif

 

 

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.

 

08openOnInj.png

 

 

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).

 

09openOnsInj.png

 

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.

 

10eventOpenons.png

11observerOpenOns.png

 

 

As well as Producer and Disposer methods:

 

12producerOpenOn.png

 

13disposerOpenOn.png

 

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 demo movie.

 

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 JIRA! We are working to help you to enjoy this exciting world of CDI