1. Home
  2. ...
  3. Custom Java Interceptors
  4. Custom Java: Creation

Custom Java: Creation

Creation of a Maven project, dependency configuration and generation of the interceptor .jar.

Generating a .jar from a Custom Java Interceptor

The first step to create a custom Java interceptor is to create a new Java project. Here, we'll create a Maven project. Inside it, we are going to configure and install the dependency interceptor-java-spec, which can be downloaded on this page.

IMPORTANT

Can I upload any external library?

No, but you can use any lib among the dependencies the API gateway supports. You can see the list of supported dependencies here.

pom.xml

This is an example of a pom.xml from one of the GitHub repositories with Custom Java examples.

NOTE

The dependency interceptor-java-spec must be inside the folder src/main/resources, and its version must be informed in the file pom.xml with the tag <interceptor-java-spec.version>.

Install the dependency with the following command:

Custom Interceptor

With the project and dependencies configured, the interceptors can be coded and compiled. This is an example:

Once the interceptor is coded, we can compile it, upload it to the API Platform and then start using it on API flows.

To compile the interceptor into a .jar file, you can use the following command:

After the command runs, a .jar file will be generated inside the /target folder. Then, you can upload the interceptor to the Platform and start using it.

How happy are you with this page?

We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more