EJB Remote Invocations over REST: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


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


=GitHub Example=
=GitHub Example=


{{External|https://github.com/NovaOrdis/playground/tree/master/jee/ejb/ejb-over-rest}}
{{External|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.
 
<pre>
@Remote
@Path("/")
public interface Callee {
    @POST
    @Consumes("application/json")
    String businessMethodA(String arg);
}
</pre>
* 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.

Latest revision as of 18:45, 2 May 2017

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.