Class ServiceRemoteInclusion

java.lang.Object
eu.cloudnetservice.driver.service.ServiceRemoteInclusion
All Implemented Interfaces:
DefaultedDocPropertyHolder, DocPropertyHolder, Cloneable

public final class ServiceRemoteInclusion extends Object implements DefaultedDocPropertyHolder, Cloneable
An inclusion which can be added to a service and will download a file from the specified url to the given destination. This can be anything for example a plugin or configuration file.
Since:
4.0
  • Field Details

    • NO_CACHE_STRATEGY

      public static final String NO_CACHE_STRATEGY
      See Also:
    • KEEP_UNTIL_RESTART_STRATEGY

      public static final String KEEP_UNTIL_RESTART_STRATEGY
      See Also:
    • HEADERS

      public static final DocProperty<Map<String,String>> HEADERS
      A property which can be added to a service inclusion to set the http headers to send when making the download http request. All key-value pairs of the given document will be set as headers in the request.
    • url

      private final String url
    • destination

      private final String destination
    • cacheStrategy

      private final String cacheStrategy
    • properties

      private final Document properties
  • Constructor Details

    • ServiceRemoteInclusion

      private ServiceRemoteInclusion(@NonNull @NonNull String url, @NonNull @NonNull String destination, @NonNull @NonNull String cacheStrategy, @NonNull @NonNull Document properties)
      Constructs a new service remote inclusion instance.
      Parameters:
      url - the url to download the associated file from.
      destination - the destination inside the service directory to copy the downloaded file to.
      cacheStrategy - the cache strategy to use when downloading files from the remote.
      properties - the properties of the remote inclusion, these can for example contain the http headers to send.
      Throws:
      NullPointerException - if one of the given parameters is null.
  • Method Details

    • builder

      Constructs a new builder instance for a service remote inclusion.
      Returns:
      a new service remote inclusion builder.
    • builder

      Constructs a new builder for a service remote inclusion which has the properties of the given inclusion already set.

      When calling build directly after constructing a builder using this method, it will result in a service remote inclusion which is equal but not the same as the given one.

      Parameters:
      inclusion - the inclusion to copy the properties of.
      Returns:
      a new service remote inclusion builder with the properties of the given one already set.
      Throws:
      NullPointerException - if the given inclusion is null.
    • url

      @NonNull public @NonNull String url()
      Get the url to download the remote inclusion from. The only supported schemes are http and https by default.
      Returns:
      the download url of the remote inclusion.
    • destination

      @NonNull public @NonNull String destination()
      The target file name of the inclusion download. An inclusion destination which is outside the service directory will result in an exception.
      Returns:
      the destination of the downloaded inclusion file.
    • cacheStrategy

      @NonNull public @NonNull String cacheStrategy()
      The caching strategy that is used when downloading the inclusion.
      Returns:
      the caching strategy.
    • propertyHolder

      @NonNull public @NonNull Document propertyHolder()
      Get the underlying document that all read and write operations are delegated to.
      Specified by:
      propertyHolder in interface DocPropertyHolder
      Returns:
      the underlying document.
    • toString

      @NonNull public @NonNull String toString()
      Overrides:
      toString in class Object
    • clone

      Overrides:
      clone in class Object
    • equals

      public boolean equals(@Nullable @Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object