EJB Remote Invocations over REST

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

EJB calls can routed over REST invocations by changing "@EJB(lookup = "")" into "@Inject" and adding a RestClientProducer as shown in the example linked below.

GitHub Example

https://github.com/NovaOrdis/playground/tree/master/jee/ejb/ejb-over-rest

Changes from EJB to REST

  • The business interfaces of the target services must be annotated with JAX-RS annotations (business method(s) and
 association to a @Path). Note that the EJB @Remote annotation may remain on the business interface.
 
@Remote
@Path("/")
public interface Callee {

    @POST
    @Consumes("application/json")
    String businessMethodA(String arg);
}
  • The target service must be deployed in such a way that it bootstraps a JAX-RS service endpoint (WAR instead of EJB JAR)

The code is the first attempt and it is sub-optimal, it can be further improved.