Skip to content

Provides a CDI structure for injecting RESTEasy proxy classes

License

Notifications You must be signed in to change notification settings

anigenero/jersey-proxy-cdi

Repository files navigation

Build Status

jersey-proxy-cdi

This library provides a quick, easy way to inject Jersey proxies into your project, with minimal setup.

Note: this project is still in very early stages of development. Do not use in production.

Java Implementation

Create the java interface for the proxy, marked with the com.anigenero.resteasy.cdi.proxy.ResteasyProxy annotation.

@ResourceProxy(name = "myproxy", url = "https://example.com:8080/api/v1")
public interface FooProxy {

    @Path("foo")
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    ResponseBean getBar();

}
Property Type Description
name java.lang.String refrences the proxy name you will use in the configuration. You may have multiple instances for the same name (e.g. if you want to implement separate proxy classes for different functionality)
url java.lang.String the url of the proxy
requestFilter javax.ws.rs.client.ClientRequestFilter (optional) a request filter
responseFilter javax.ws.rs.client.ClientResponseFilter (optional) a response filter
credentialsProvider org.apache.http.client.CredentialsProvider (optional)

It's then as simple as creating the injection point for the proxy in your class.

public class BarHandler {

    private final FooProxy fooProxy;
    
    @Inject
    public BarHandler(FooProxy fooProxy) {
        this.fooProxy = fooProxy;
    }
    
    // ... handler code
    
}

About

Provides a CDI structure for injecting RESTEasy proxy classes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages