Middleware for PAAS model
SDK.finance – middleware – Spring Edition
How to use SDK Client for communication with SDK.finance core via APIs
General description
This project can be used as an example of how to build an external application with appropriate business logic or integration with 3rd parties and use the functionality provided by the SDK.finance API.
For now, version 1 of the middleware is implemented.
Link to repository: https://git.sdk.finance/pub/sdk5/middleware/-/tree/master?ref_type=heads
SDK.finance – middleware – Spring Edition
Requirements |
Reason |
---|---|
Java 21 LTS |
Application |
Maven version 3.9.0+ |
Builder |
Technology stack
Technology name |
Version |
---|---|
JDK |
21 LTS |
Web server |
Apache Tomcat 10.1.34 |
Spring Boot |
3.4.2 |
Spring |
6.2.2 |
Hibernate |
6.6.5. Final |
H2 database |
2.3 |
Maven build
To build project using maven tool, please do the follow commands:
mvn clean install
To get javadoc
To get javadoc, please do the follow commands:
mvn -X clean javadoc:aggregate-jar
Project structure
Project middleware include parts:
-
app – package with classes for client business logic.
-
RESTResponseEntityExceptionHandler.java – file for handling exceptions in the application.
-
endpoint – package for REST Controllers
-
model – package for Entities
-
repository – package for JPA Repositories
-
service – package for Services
-
utils – package for utils
-
-
client – package is responsible for setup REST Client for communication with adapters for generated files by OpenAPI schema.
-
adapter – package with adapters (e.g.: AuthorizationApi) for generated files (e.g.: AuthorizationClient) by OpenAPI schema.
-
config – package with SDKClient Configuration.
-
dto – package with DTO files to use for SDKClient.
-
enums – package with enum files to use for SDKClient.
-
mapper – package with MapStruct mappers to use for SDKClient.
-
utils – package with Util Services to simplify work with adapters. Service injects adapters and MapStruct mappers to use for SDKClient.
-
PrototypeSDKClientConfiguration.java – configuration class for defining the Prototype Scoped SDK clients.
-
SDKAbstractAPI.java – abstract base class for SDK API implementations providing common functionality.
-
-
application.yaml – application configuration yaml file.
sdk:
contains data for communication with SDK.finance core application -
logbacl-spring.yaml – file for application logging settings.
The project structure is
src
└── main
├── java
| └── sdk
| └── finance
| └── middleware
| ├── app
| | ├── config
| | | └── exception
| | | └── RESTResponseEntityExceptionHandler.java
| | ├── endpoint
| | ├── model
| | ├── repository
| | ├── service
| | └── utils
| ├── client
| | ├── adapter
| | ├── config
| | ├── dto
| | ├── enums
| | ├── mapper
| | ├── utils
| | ├── PrototypeSDKClientConfiguration.java
| | └── SDKAbstractAPI.java
| └── MiddlewareApplication.java
└── resourses
├── application.yaml
└── logbacl-spring.yaml

According to the schema implemented in phase I – interaction between SDK.finance core application and SDK.finance middleware application.
As an example in src/main/java/sdk/finance/middleware/app
implemented the logic to Create a new user, updating their user profile, retrieving created user data and deleting creating user.
The appropriate REST API is located in sdk/finance/middleware/app/endpoint/UserManagementController.java
REST Controller injected sdk/finance/middleware/app/service/UserService.java
service and then this service use sdk/finance/middleware/app/service/SDKClientService.java
for communication with the SDK.finance core application and sdk/finance/middleware/app/repository/UserRepository.java
to store data in DB.
How to use SDK Client for communication with SDK.finance core via APIs
-
There is a library
sdk5-openapi-middleware
with generated classes by OpenAPI schema provided with SDK.finance core application. Open API schema updated per release of SDK.finance core application. There are generated classes with suffix -Clinet. Each class reflect the group of APIs in the OpenAPI schema. -
Generated class (-Client) should be configured as bean in
sdk/finance/middleware/client/PrototypeSDKClientConfiguration.java
. -
Create an adapter class – bean with prototype scope in
sdk/finance/middleware/client/adapter
created bean should be extended fromsrc/main/java/sdk/finance/middleware/client/SDKAbstractAPI.java
. For example look atsdk/finance/middleware/client/adapter/AuthorizationApi.java
. -
Create Utils Component to aggregate several adapter beans in
sdk/finance/middleware/client/utils
. And then use created Utils Component in Service to implement required business logic.
For example look atsdk/finance/middleware/client/utils/RegistrationUtils.java
and it usage insdk/finance/middleware/app/service/impl/SDKClientServiceImpl.java
The Middleware project version is the same as the released version of SDK.finance core application. The project is updated regularly at every SDK.finance core application release.
References
-
Public access to OpenAPI libraries https://artifactory.sdk.finance/artifactory/free/