This project provides a library for Spring and POJO-based REST client instantiation.
This project provides a library for Spring and POJO-based REST client instantiation. It includes special classes for the Jersey JAXRS-based client frameworks.
## Usage
@@ -15,7 +15,7 @@ First, you will need to include the library in your project.
<dependency>
<groupId>com.inteligr8</groupId>
<artifactId>common-rest-client</artifactId>
<version>...</version>
<version>...-jersey</version>
</dependency>
...
</dependencies>
@@ -23,4 +23,65 @@ First, you will need to include the library in your project.
</project>
```
See the `cxf` and `jersey` branches for examples and more documentation.
### Spring Framework
#### Single Client
If you will only be declaring a single client in your Spring context, this is easy. You will just need two things. First, inject the single client into any of your Spring beans. You may do inject it into more than one. An example is below:
```java
@Component
publicclass...{
@Autowired
@Qualifier("client.jersey")// may be optional
privateClientclient;
}
```
Next, you need to configure that client. You can do that by providing a single implementation of the `ClientConfiguration` (or `ClientJerseyConfiguration`) interface.
If you will or may have multiple clients in your Spring context, there is an extra step. You will still need to define a `ClientConfiguration` for each. On top of that, you will need to create specialized implementations of each client. That special implementation will reference the configuration directly. An example is below.
```java
@Component("my.client")
publicclassMyClientextendsClientJerseyImpl{
@Autowired
publicMyClient(MyClientConfigurationconfig){
super(config);
}
}
```
You can then inject your client(s) into your Spring beans. Like the example below: