Class InstallationResources

Object
InstallationResources
Direct Known Subclasses:
Installation­Script­Provider, Optional­Installations

public abstract class InstallationResources extends Object
Resources needed for installation of third-party or optional components. Installation­Resources can be used for downloading large files that may not be of interest to every users, or data that are subject to more restricting terms of use than the Apache license.

Examples

  • The NADCON grid files provide datum shifts data for North America. Since those files are in the public domain, they could be bundled in Apache SIS. But the weight of those files (about 2.4 Mb) is unnecessary for users who do not live in North America.
  • On the other hand, the EPSG geodetic dataset is important for most users. Codes like "EPSG:4326" became a de-facto standard in various places like Web Map Services, images encoded in GeoTIFF format, etc. But the EPSG terms of use are more restrictive than the Apache license and require that we inform the users about those conditions.

Recognized authorities

Some authorities implemented in Apache SIS modules are listed below. In this list, "Embedded" is a pseudo-authority for an embedded database containing EPSG and other data. The embedded database is provided as a convenience for avoiding the need to define a SIS_DATA directory on the local machine.
Authorities supported by Apache SIS
Authority Provided by Maven artifact Used by class
"EPSG" org.apache.sis.non-free:sis-epsg EPSGFactory
"Embedded" org.apache.sis.non-free:sis-embedded-data All the above
In order to allow those classes to discover which resources are available, Installation­Resources implementations shall be declared in the module-info​.java file as providers of the org​.apache​.sis​.setup​.Installation­Resources service.

Above registration is usually done automatically when extension modules are added on the module path. For example, adding the org​.apache​.sis​.non-free:sis-epsg Maven dependency as documented on the Apache SIS web site is the only step needed for allowing Apache SIS to read the EPSG scripts (however SIS still needs an installation directory for writing the database; see above-cited web page for more information).

Since:
0.7
  • Constructor Details

    • InstallationResources

      protected InstallationResources()
      For subclass constructors.
  • Method Details

    • load

      public static ServiceLoader<InstallationResources> load()
      Returns installation resources found on the module path..
      Returns:
      installation resources found on the module path
      Since:
      1.4
    • getAuthorities

      public abstract Set<String> getAuthorities()
      Returns identifiers of the resources provided by this instance. The values recognized by SIS are listed below (note that this list may be expanded in any future SIS versions):
      Authorities supported by Apache SIS
      Authority Resources
      "EPSG" SQL installation scripts for EPSG geodetic dataset.
      "Embedded" Data source of embedded database containing EPSG and other resources.
      Note: "Embedded" is a pseudo-authority for an embedded database containing EPSG and other data. This embedded database is provided by the org​.apache​.sis​.referencing​.database module as a convenience for avoiding the need to define a SIS_DATA directory on the local machine. In this particular case, the resource is more for execution than for installation.
      This method may return an empty set if this Installation­Resources instance did not find the resources (for example because of files not found) or does not have the permission to distribute them.
      Returns:
      identifiers of resources that this instance can distribute.
    • getInstructionURL

      public String getInstructionURL()
      Returns a URL where users can get more information about the installation process.
      Returns:
      URL to installation instruction, or null if none.
      Since:
      1.2
    • getLicense

      public abstract String getLicense(String authority, Locale locale, String mimeType) throws IOException
      Returns the terms of use of the resources distributed by the specified authority, or null if none. The terms of use can be returned in either plain text or HTML.
      Licenses for some supported authorities
      Authority License
      "EPSG" A copy of the https://epsg.org/terms-of-use.html page.
      "Embedded" Above EPSG license.
      Parameters:
      authority - one of the values returned by get­Authorities().
      locale - the preferred locale for the terms of use.
      mime­Type - either "text/plain" or "text/html".
      Returns:
      the terms of use in plain text or HTML, or null if none.
      Throws:
      Illegal­Argument­Exception - if the given authority argument is not one of the expected values.
      IOException - if an error occurred while reading the license file.
    • getResourceNames

      public abstract String[] getResourceNames(String authority) throws IOException
      Returns the names of all resources of the specified authority that are distributed by this instance. The resources will be used in the order they appear in the array. Examples:
      • "EPSG" authority: the resource names are the filenames of all SQL scripts to execute. One of the first script creates tables, followed by a script that populates tables with data, followed by a script that creates foreigner keys.
      • "Embedded" pseudo-authority: the database name, which is "Spatial­Metadata". When embedded, this database is read-only.
      Parameters:
      authority - one of the values returned by get­Authorities().
      Returns:
      the names of all resources of the given authority that are distributed by this instance.
      Throws:
      Illegal­Argument­Exception - if the given authority argument is not one of the expected values.
      IOException - if fetching the resource names required an I/O operation and that operation failed.
    • getResource

      public Object getResource(String authority, int index) throws IOException
      Returns an installation resource for the given authority, or null if not available. The return value may be an instance of any type, at implementation choice. This may be for example a URL referencing the actual resource, or a Data­Source for an embedded database.

      The default implementation returns null. A null value means that the resource is fetched by open­Script(String, int) instead of this method. We do not return URL to text files in order to ensure that the file is opened with proper character encoding.

      Parameters:
      authority - one of the values returned by get­Authorities().
      index - index of the resource to get, from 0 inclusive to get­Resource­Names(authority)​.length exclusive.
      Returns:
      the resource as an URL or any other type (at implementation choice), or null if not available.
      Throws:
      Illegal­Argument­Exception - if the given authority argument is not one of the expected values.
      Index­Out­Of­Bounds­Exception - if the given resource argument is out of bounds.
      IOException - if an error occurred while fetching the resource.
      Since:
      0.8
      See Also:
    • openScript

      public abstract BufferedReader openScript(String authority, int resource) throws IOException
      Returns a reader for the resources at the given index. The resource may be a SQL script or any other resources readable as a text. The returned Buffered­Reader instance shall be closed by the caller.
      Parameters:
      authority - one of the values returned by get­Authorities().
      resource - index of the script to open, from 0 inclusive to get­Resource­Names(authority)​.length exclusive.
      Returns:
      a reader for the installation script content.
      Throws:
      Illegal­Argument­Exception - if the given authority argument is not one of the expected values.
      Index­Out­Of­Bounds­Exception - if the given resource argument is out of bounds.
      IOException - if an error occurred while creating the reader.