Class WebTargetBuilder

java.lang.Object
org.openremote.container.web.WebTargetBuilder

public class WebTargetBuilder extends Object
This is a factory for creating JAX-RS WebTarget instances. The instances share a common Client that uses a connection pool and has the following ContextResolvers registered (additional filters etc. should be registered on the WebTargetBuilder instances):
  • Field Details

    • CONNECTION_POOL_SIZE

      public static final int CONNECTION_POOL_SIZE
      See Also:
    • CONNECTION_CHECKOUT_TIMEOUT_MILLISECONDS

      public static final long CONNECTION_CHECKOUT_TIMEOUT_MILLISECONDS
      See Also:
    • CONNECTION_TIMEOUT_MILLISECONDS

      public static final long CONNECTION_TIMEOUT_MILLISECONDS
      See Also:
    • client

      protected org.jboss.resteasy.client.jaxrs.ResteasyClient client
    • executorService

      protected static ExecutorService executorService
    • basicAuthentication

      protected org.jboss.resteasy.client.jaxrs.internal.BasicAuthentication basicAuthentication
    • oAuthGrant

      protected org.openremote.model.auth.OAuthGrant oAuthGrant
    • baseUri

      protected URI baseUri
    • failureResponses

      protected List<Integer> failureResponses
    • followRedirects

      protected boolean followRedirects
  • Constructor Details

    • WebTargetBuilder

      public WebTargetBuilder(org.jboss.resteasy.client.jaxrs.ResteasyClient client, URI baseUri)
  • Method Details

    • setBasicAuthentication

      public WebTargetBuilder setBasicAuthentication(String username, String password)
      Add Basic authentication to requests sent by this WebTarget; this should not be used in conjunction with any other authentication.
    • setOAuthAuthentication

      public WebTargetBuilder setOAuthAuthentication(org.openremote.model.auth.OAuthGrant oAuthGrant)
      Add OAuth authentication to requests sent by this WebTarget; this should not be used in conjunction with any other authentication (note if basic authentication is also set then this OAuth authentication will take precedence).
    • setOverrideResponseHeaders

      public WebTargetBuilder setOverrideResponseHeaders(Map<String,List<String>> overrideResponseHeaders)
    • addPermanentFailureResponse

      public WebTargetBuilder addPermanentFailureResponse(jakarta.ws.rs.core.Response.Status... responseStatus)
      If the specified status code is returned from the server then it will be treated as a permanent failure and the web authTarget will no longer be usable (any future requests will immediately return a Response.Status.METHOD_NOT_ALLOWED response without hitting the server.

      NOTE: Any response in 200 range will always be treated as successful.

    • addPermanentFailureResponse

      public WebTargetBuilder addPermanentFailureResponse(Integer... responseStatus)
    • removePermanentFailureResponse

      public WebTargetBuilder removePermanentFailureResponse(jakarta.ws.rs.core.Response.Status... responseStatus)
    • removePermanentFailureResponse

      public WebTargetBuilder removePermanentFailureResponse(Integer... responseStatus)
    • followRedirects

      public WebTargetBuilder followRedirects(boolean followRedirects)
    • build

      public org.jboss.resteasy.client.jaxrs.ResteasyWebTarget build()
    • createClient

      public static org.jboss.resteasy.client.jaxrs.ResteasyClient createClient(ExecutorService executorService)
    • createClient

      public static org.jboss.resteasy.client.jaxrs.ResteasyClient createClient(ExecutorService executorService, int connectionPoolSize, long overrideSocketTimeout, UnaryOperator<org.jboss.resteasy.client.jaxrs.internal.ResteasyClientBuilderImpl> builderConfigurator)
    • mapToMultivaluedMap

      public static <K, V, W extends V> jakarta.ws.rs.core.MultivaluedMap<K,V> mapToMultivaluedMap(Map<K,List<W>> map)
    • addQueryParams

      public static <T extends jakarta.ws.rs.client.WebTarget, V> T addQueryParams(@NotNull T webTarget, @NotNull @NotNull Map<String,List<V>> multivaluedMap)
    • addHeaders

      public static <V> jakarta.ws.rs.client.Invocation.Builder addHeaders(@NotNull jakarta.ws.rs.client.Invocation.Builder requestBuilder, @NotNull @NotNull Map<String,List<V>> multiivaluedMap)