Overview of the JAX-RS support in JBoss Tools 3.3M2
Posted by xcoulon in JBoss Tools on Jun 30, 2011 5:17:36 PMFollowing the release of JBoss Tools 3.3M2 that was announced yesterday, this article highlights the main features provided by the new JAX-RS tooling which is part of this new milestone.
Installing the plugin
As explained in the announcement, the fastest and easiest way to get started with JBoss Tools is to download & install the Eclipse 3.7 (Indigo) JEE bundle. Once you have installed Eclipse, you use our update site directly.
The updatesite URL to use from Help > Install New Software... is:
http://download.jboss.org/jbosstools/updates/development/indigo/
Then, go to the "All JBoss Tools 3.3" section and select "JBoss JAX-RS Tools"
Using a sample project
A quick way to get started with the tooling is to download the JBoss AS7 Quickstarts from their download page. Once you've unzipped the archive, import the "KitchenSink" project into your workspace using the Import > Existing Maven Project menu.
You'll need to install the m2eclipse plugin to import the project.
Activating the support for JAX-RS
One way to activate support for JAX-RS in your project is to click on "Configure > Add JAX-RS 1.1 support..." in the project's contextual menu, which in turn will add the "JAX-RS Nature" to it.
If the project you're working on is a "Dynamic Web Project", you can also install the standard Eclipse "JAX-RS (REST Web Services)" Facet, which will in turn will add the "JAX-RS Nature" as described in the previous case.
In both cases, a "JAX-RS Builder" will be added to your project.
Current features
In this milestone, the JAX-RS Builder offers the features described below.
Mapping of JAX-RS elements to the source
The JAX-RS Builder computes and keeps in sync' an im-memory metamodel of the JAX-RS elements of your project. The metamodel is reinitialized during a clean/full build of your project, and all kinds of changes to compilation units are applied to the metamodel.
RESTful Web Services explorer
The RESTful Web Services outline in the the Project Explorer view is certainly the most attractive feature of this plugin, as it displays the resolved URI Path Templates based on the metamodel described above.
The URI Path Templates resolution works with both Methods and Submethods of Root Resources and Subresources. In addition, each node in the outline indicates the consumed and produced media-types and the Java method that would be called when a request matching the combo {HTTP Method + URI Path Template + Content Negociation}. Double-clicking on the elements of the outline opens the Java Editor to the associated location in the source code.
Event tough the classes annotated with the @javax.ws.rs.ext.Provider are not shown on the Project Explorer's view yet, they are already taken into account by the JAX-RS Builder, so you can expect further features around those elements in the next releases.
Code completion for JAX-RS annotation values
Code completion for @javax.ws.rs.PathParam annotation value is available. The completion processor analyses the source of the Java Type to return proposals based on the @javax.ws.rs.PathParam annotations values both at the method and at the type levels. The additional information of each proposal highlights the part of the code from which the proposal was computed.
Those completion proposals support the regular expressions, too.
Validation of JAX-RS constructs
The plugin currently validates that a method parameter annotated with @javax.ws.rs.PathParam annotation matches with the @javax.ws.rs.Path annotation value on the same method.
That's it for now. Remember that the tooling is not yet complete but is very functional and we are looking forward to get feedback on its current functionality and what you would like to see in the future !
Have fun !
PS : as an individual contributor, I'd also like to thank the JBoss Tools team for the support and confidence they've put in the work I've done so far. As Max Andersen says, it's the way OSS works, and it's really great !
Comments