JAX-RS - 1.5

Extension ID

com.castsoftware.jaxrs

What’s new?

See JAX-RS - 1.5 - Release Notes for more information.

Compared to 1.4.x branch, the support for calls to web services through WebTarget has been removed because it was error prone. Please use REST Service Calls for Java (com.castsoftware.java.service) instead.

Description

This extension provides support for JAX-RS.

In what situation should you install this extension?

The main purpose of this extension is to create HTTP API entry points, to enable linking from a Web App front end. Therefore if your Web application contains source code which uses JAX-RS (1.0 (JSR 311) and 2.0 (JSR 339)) and you want to view these object types and their links with other objects, then you should install this extension. 

iOS Front-End Example AngularJS Front-End Example

Features

This extension handles JAX-RS Web Services used in J2EE applications, for example:

@Singleton
@Path("/printers")
public class PrintersResource {
     @GET
     @Produces({"application/json", "application/xml"})
     public WebResourceList getMyResources() { ... }
      
     @GET @Path("/list")
     @Produces({"application/json", "application/xml"})
     public WebResourceList getListOfPrinters() { ... }
   
     @PUT @Path("/ids/{printerid}")
     @Consumes({"application/json", "application/xml"})
     public void putPrinter(@PathParam("printerid") String printerId,  Printer printer) { ... }
    
     @DELETE @Path("/ids/{printerid}")
     public void deletePrinter(@PathParam("printerid") String printerId) { ... }
 }

For each class annotated with javax.ws.rs.Path (@Path):

  • A Web Service object will be created whose name is deduced from the value of @Path on the class
  • A Web Service Port object will be created that is a child of the web service with the same name and has with a prototype link to the class
  • For each method annotated with @GET, @PUT, @DELETE or @POST, the following will be created:
    • a Web Service operation child of the Web Service Port whose name is the concatenation of the @Path specified at the class level and the @Path specified at the method level. If no @Path on the method, then method path = /
    • a fire link from the Web Service operation to the method

Annotations considered

  • for the URLs:

    • javax.ws.rs.Path
    • jakarta.ws.rs.Path
  • for the access type:

    • javax.ws.rs.GET

    • javax.ws.rs.PUT

    • javax.ws.rs.DELETE

    • javax.ws.rs.POST

    • jakarta.ws.rs.GET

    • jakarta.ws.rs.PUT

    • jakarta.ws.rs.DELETE

    • jakarta.ws.rs.POST

Basic case

The following Java code:

import javax.ws.rs.Path;
import javax.ws.rs.GET;


@Path("Service")
public class MyClass
{
    @Path("/getter")
    @GET
    public void getter() {}
}

will generate :

Inheritance case

The annotations may also be in the parent class or interface:

import javax.ws.rs.Path;


@Path("Service")
public class MyClass implements MyInterface
{
    public void getter() {}
}

Here the interface defines the exposed methods:

import javax.ws.rs.Path;
import javax.ws.rs.GET;


public interface MyInterface
{
    @Path("/getter")
    @GET
    public void getter();
}

and will generate :

Here the interface exposes the main path and the implementation defines the exposed methods:

import javax.ws.rs.Path;


public class MyClass implements MyInterface
{
    @Path("/getter")
    @GET
    public void getter() {}
}
import javax.ws.rs.Path;
import javax.ws.rs.GET;

@Path("Service")
public interface MyInterface
{

    public void getter();
}

and will generate :

Support for User Input Security

Service entry points are created automatically for applications that have a presentation layer based on JAX-RS with @Path (and associated annotations) usage. This can be seen in the analysis log file as follows:

2018-07-04 20:27:29,227 INFO  SecurityAnalyzer.Processor LoadBlackboxesForApplication cast#spec cast#lib JAXRSServiceEntryPoints

This corresponds to the generation of a file in the following location:

<BytecodeFolder>\com.castsoftware.jaxrs\ServiceEntryPoints.blackbox.xml

Note that while the ServiceEntryPoints.blackbox.xml file is generated when the extension is used with any release of CAST AIP, it will only be exploited by the CAST User Input Security feature in CAST AIP ≥ 8.3.3.

Function Point, Quality and Sizing support

This extension provides the following support:

  • Function Points (transactions): a green tick indicates that OMG Function Point counting and Transaction Risk Index are supported
  • Quality and Sizing: a green tick indicates that CAST can measure size and that a minimum set of Quality Rules exist
Function Points
(transactions)
Quality and Sizing
(tick) (error)

CAST AIP compatibility

This extension is compatible with:

CAST AIP release Supported
8.3.x (tick)

Dependencies with other extensions

Some CAST extensions require the presence of other CAST extensions in order to function correctly. The JAX-RS extension requires that the following other CAST extensions are also installed:

  • Web services linker service (internal technical extension)

Note that when using the CAST Extension Downloader to download the extension and the Manage Extensions interface in CAST Server Manager to install the extension, any dependent extensions are automatically downloaded and installed for you. You do not need to do anything.

CAST Transaction Configuration Center (TCC) Entry Points

In JAX-RS ≥ 1.3.x, if you are using the extension with CAST AIP ≥ 8.3.x, a set of JAX-RS specific Transaction Entry Points are now automatically imported when the extension is installed. These Transaction Entry Points will be available in the CAST Transaction Configuration Center:

What results can you expect?

Objects

Icon Description

JAX-RS Delete Operation Service

JAX-RS Get Operation Service

JAX-RS Post Operation Service

JAX-RS Put Operation Service

JAX-RS Port

JAX-RS Service

JAX-RS Get Resource Service

Rules

None.