This project provides a library for Spring and POJO-based REST client instantiation. It includes special classes with classifiers for two popular JAXRS-based client frameworks: Apache CXF and Jersey.
## Usage
First, you will need to include the library in your project.
```xml
<project>
...
<dependencies>
...
<dependency>
<groupId>com.inteligr8</groupId>
<artifactId>common-rest-client</artifactId>
<classifier>...</classifier>
<version>...</version>
</dependency>
...
</dependencies>
...
</project>
```
Valid `classifier` values are `cxf` or `jersey`.
### 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.cxf")// may be optional
privateClientclient;
}
```
Next, you need to configure that client. You can do that by providing a single implementation of the `ClientConfiguration` (or `ClientCxfConfiguration`) interface.
```java
@Configuration
publicclass...implementsClientCxfConfiguration{
...
}
```
For Jersey implementations, just use `client.jersey` and `ClientJerseyConfiguration`. If you want to provide one of each, then follow the instructions for multiple clients below.
#### Multiple Clients
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")
publicclassMyClientextendsClientCxfImpl{
@Autowired
publicMyClient(MyClientConfigurationconfig){
super(config);
}
}
```
You can then inject your client(s) into your Spring beans. Like the example below: