A couple of different ways to consume the RHPAM API using REST.

Grega Bremec 0ec4a2ba05 removed camel dependencies 3 年之前
src 86b533a99f added three REST-activated client options 3 年之前
.gitignore 729cd551dd initial import; shell script and pom only 3 年之前
COPYING 729cd551dd initial import; shell script and pom only 3 年之前
README.md 0f3afbd4ca fixed some markdown bits 3 年之前
curl-client.conf 729cd551dd initial import; shell script and pom only 3 年之前
curl-client.sh 9affa004aa added startWithXid 3 年之前
pom.xml 0ec4a2ba05 removed camel dependencies 3 年之前

README.md

Using the remote RHPAM API in 100 ways

This project contains essentially two completely different things:

  • a fairly complete curl-based REST client for RHPAM
  • a number of JAX-RS implementations of various RHPAM clients

The first one is called curl-client.sh and (optionally) loads its configuration from curl-client.conf (or some other file, as might be specified by command-line options. Run with --help to learn more about it.

The other are three implementations RHPAM clients, each of which exposes two endpoints, one that will start a process, and one that will send a process a signal. They are all designed to work with the StartStopStart process model from the pam-simple-process project.

They all use CDI to inject an instance of a corresponding WS-client into the implementation class, using CDI qualifier annotations to tell the CDI container which of the producer methods in WebTargetProducer need to be invoked to instantiate the client.

In turn, the CDI producer class uses ConfigProducer to get access to configuration settings from rhpam-rest-client.properties that tell it what endpoint to use when talking to RHPAM and how to authenticate.

More detail on the implementations:

  • ManualInvocationClient is much like the UseRestEasyManualClient class from kie-rules-processes project; it talks to the RHPAM REST endpoints using an instance of WebTarget and does the response "unmarshalling" with the help of a simple class called ManualRhpamResponse

  • ProxyInvocationClient is alike to UseRestEasyProxyClient from the kie-rules-processes project, and uses a made-up JAX-RS interface defined in RhpamEndpoints to generate the RestEasy proxy client

  • SwaggerInvocationClient uses Java code generated by the swagger-codegen Maven plugin, which is still configured in pom.xml, but disabled (that is, disconnected from Maven lifecycle); only the minimum amount of code needed to perform basic ProcessInstanceApi operations was added to the project, and some of the low-level ApiClient and ProcessInstanceApi code had to be modified to support basic HTTP authentication (see comments), thanks to the missing authentication data in swagger.json from RHPAM

The exposed endpoints just forward the various parameters to the actual JAX-RS clients:

  • Kie Container ID
  • Process Model ID
  • Process Instance ID
  • Signal Name

See the code for more information in the comments.