Class JerseyClient


public class JerseyClient extends AbstractClient
The main entrance class.
Author:
ralph
  • Field Details

    • NAME

      public static String NAME
      Default name for User-Agent
    • VERSION

      public static String VERSION
      Default version for User-Agent
    • URL

      public static String URL
      Default URL for User-Agent
  • Constructor Details

    • JerseyClient

      public JerseyClient(JerseyClientConfig config)
      Constructor.

      Be aware that the constructor immediately calls configure(JerseyClientConfig) and authorize().

      Parameters:
      config - - the config to be used
    • JerseyClient

      public JerseyClient(javax.ws.rs.client.Client config)
      Constructor.

      Be aware that the constructor immediately calls authorize().

      Parameters:
      config - - the config to be used
  • Method Details

    • configure

      protected void configure(JerseyClientConfig config)
      Configures JAX-RS client and main web target based on this config.

      Calls createClient() to actually create the client.

      Parameters:
      config - - the config to be used
      See Also:
    • createClientConfig

      protected org.glassfish.jersey.client.ClientConfig createClientConfig()
      Creates the Jersey client configuration based on the config for this client.

      Descendants can override this method in order to manipulate the config.

      Returns:
      the config to be used for the JAX-WS Jersey client.
    • createClient

      protected javax.ws.rs.client.Client createClient()
      Creates the actual JAX-WS Jersey client instance.

      Desecendants can override this method when they want full control over the creation of the client.

      Also calls configure(Client).

      Returns:
      the client
      See Also:
    • configure

      protected void configure(javax.ws.rs.client.Client client)
      Configures the client by setting the default auth filter and - if applicable - the proxy filter.
      Parameters:
      client - the client to configure
      See Also:
    • getUserAgent

      protected String getUserAgent()
      Returns the User-Agent string to be injected in calls.
      Returns:
      the user agent string
      See Also:
    • getAuthorizationFilter

      protected javax.ws.rs.client.ClientRequestFilter getAuthorizationFilter()
      Returns the default filter(s) for authorization.
      Returns:
      the authorization filter.
      See Also:
    • getClient

      public javax.ws.rs.client.Client getClient()
      Returns the configured Jersey client.
      Returns:
      the client
    • getConfig

      public JerseyClientConfig getConfig()
      Returns the config of this client.
      Returns:
      the config
    • authorize

      protected void authorize()
      Base method for authentication.

      The method is called after configuration from Constructor. You can override it to implement an automatic authentication.

      The default implementation does nothing.

    • close

      public void close()
      Close the client.