Class RestClientFactory

java.lang.Object
com.atlassian.confluence.rest.client.RestClientFactory

public class RestClientFactory extends Object

Factory for creating jersey Client instances that can deserialize json returned from the Confluence REST API into confluence java api model objects.

Example usage :

     Client client = RestClientFactory.newClient();
 

Consumers who need to register additional jersey providers might do the following :

      JacksonJsonProvider defaultProvider = RestClientFactory.createProvider(RestClientFactory.createJacksonModule());
      MyDelegatingProvider extraProvider = new MyDelegatingProvider(defaultProvider);
      Client client = RestClientFactory.newClient(defaultProvider, extraProvider);
 
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.glassfish.jersey.client.ClientConfig
    createConfig(Object... providers)
    Helper method to create a jersey client config with the given providers registered.
    static com.fasterxml.jackson.databind.Module
     
    static org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider
    createProvider(@Nullable com.fasterxml.jackson.databind.Module jacksonModule)
    Creates Provider instance to perform custom serialization needed for using the remote API model objects.
    static javax.ws.rs.client.Client
    Create a client with default configuration suitable for remotely communicating with the Confluence REST API.
    static javax.ws.rs.client.Client
    newClient(com.fasterxml.jackson.databind.Module jacksonModule)
     
    static javax.ws.rs.client.Client
    newClient(Object provider, Object... providers)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RestClientFactory

      public RestClientFactory()
  • Method Details

    • newClient

      public static javax.ws.rs.client.Client newClient()
      Create a client with default configuration suitable for remotely communicating with the Confluence REST API.
      Returns:
      a new jersey client that can serialize and deserialize confluence model objects.
    • newClient

      public static javax.ws.rs.client.Client newClient(com.fasterxml.jackson.databind.Module jacksonModule)
    • newClient

      public static javax.ws.rs.client.Client newClient(Object provider, Object... providers)
    • createConfig

      public static org.glassfish.jersey.client.ClientConfig createConfig(Object... providers)
      Helper method to create a jersey client config with the given providers registered.
      Parameters:
      providers - instances of providers annotated with Provider
    • createJacksonModule

      public static com.fasterxml.jackson.databind.Module createJacksonModule()
      Returns:
      the serialization module for serializing and deserializing java model objects.
    • createProvider

      public static org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider createProvider(@Nullable com.fasterxml.jackson.databind.Module jacksonModule)
      Creates Provider instance to perform custom serialization needed for using the remote API model objects. Registers the jacksonModule with the provider.
      Parameters:
      jacksonModule - custom serialization module to register with the provider