Enum LocalServer

  • All Implemented Interfaces:
    Serializable, Comparable<LocalServer>

    public enum LocalServer
    extends Enum<LocalServer>
    A singleton class representing a Local Server instance.

    The Local Server product is an optional component of the ArcGIS Runtime SDKs which can be downloaded for Windows and Linux platforms. The Local Server product is not supported for OS X platforms.

    The Local Server is primarily for executing offline geoprocessing tasks in your runtime applications. Local Server also allows developers to consume Map Image Layers or Feature Layers which require a map package (.mpk).

    Before any services can be used on Local Server, the Local Server process must be started. Only one instance of the Local Server can be running at any time.

     
      // start the Local Server instance
      ListenableFuture<Void> localServerFuture = LocalServer.INSTANCE.startAsync();
      // listen to the done listener
      localServerFuture.addDoneListener(() -> {
        // check it started and not failed
        if (LocalServer.INSTANCE.getStatus() == LocalServerStatus.STARTED) {
          // you can now start services here:
        }
      });
     
    Once the Local Server is started, local services can be started which will use packages generated from ArcGIS Desktop.

    When an application is closed down, the Local Server should be closed down too with the following code:

    LocalServer.INSTANCE.stopAsync();
     
    Since:
    100.0.0
    • Enum Constant Detail

      • INSTANCE

        public static final LocalServer INSTANCE
        The singleton instance of Local Server
    • Method Detail

      • values

        public static LocalServer[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (LocalServer c : LocalServer.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static LocalServer valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • setInstallPath

        public void setInstallPath​(String path)
        Sets the path to the local server directory. The default value is null. Set null here to use app local or environment variable locations.
        Parameters:
        path - the location of the local server directory, can be null
        Throws:
        IllegalStateException - if the server is not STOPPED or FAILED
        IllegalArgumentException - if the path is empty
        Since:
        100.0.0
      • getInstallPath

        public String getInstallPath()
        Returns the path to the local server directory.
        Returns:
        the path to the local server directory or null if not set
        Since:
        100.0.0
      • setTempDataPath

        public void setTempDataPath​(String path)
        Sets a path to a directory to be used to hold temporary data (such as Local Server log file) used whilst running a Local Server instance. The default value is defined by the system property java.io.tmpdir.
        Parameters:
        path - the path to a directory to use for temporary data
        Throws:
        IllegalStateException - if the server is not STOPPED or FAILED
        IllegalArgumentException - if the path is null or empty
        IllegalArgumentException - if the path is not to a directory
        Since:
        100.0.0
      • getTempDataPath

        public String getTempDataPath()
        Returns the path to the directory being used to hold temporary data.
        Returns:
        the temporary data path or null if not set
        Since:
        100.0.0
      • setAppDataPath

        public void setAppDataPath​(String path)
        Sets the path to a directory to be used to hold app data. If not specified, Paths.get(getTempDataPath(), "ArcGISRuntime") will be used. It is recommended to use ths property when it is necessary to differentiate the application data from that of another runtime application using the local server. For example, on Windows you could use Paths.get(System.getenv("APPDATA"), "Vendor", "MyAppName").
        Parameters:
        path - the path to a directory to use for app data
        Throws:
        IllegalStateException - if the server is not STOPPED or FAILED
        IllegalArgumentException - if the path is null or empty
        IllegalArgumentException - if the path is not to a directory
        Since:
        100.0.0
      • getAppDataPath

        public String getAppDataPath()
        Returns the path to the directory being used to hold app data or null if setAppDataPath(String) has not been used.
        Returns:
        the app data path or null if not set
        Since:
        100.0.0
      • getUrl

        public String getUrl()
        Returns the server's URL.
        Returns:
        the server's url, null if the server is not running
        Since:
        100.0.0
      • setFilterWebContent

        public void setFilterWebContent​(boolean enable)
        Turns on filtering of HTML content for feature service text fields. By default this is enabled. When this is enabled only a small subset of HTML is accepted and an error will occur if unsupported HTML is used. Filter web content should be set to disabled if you want to use unfiltered HTML.
        Parameters:
        enable - true to enable, false to disable filtering
        Throws:
        IllegalStateException - if the server is not STOPPED or FAILED
        Since:
        100.0.0
      • isFilterWebContent

        public boolean isFilterWebContent()
        Returns true if web content filtering is enabled.
        Returns:
        true, if filtering is enabled
        Since:
        100.0.0
        See Also:
        setFilterWebContent(boolean)
      • getError

        public ArcGISRuntimeException getError()
        Returns any error if the server's status is FAILED.
        Returns:
        the current error, null if there is no error
        Since:
        100.0.0
      • getStatus

        public LocalServerStatus getStatus()
        Returns the Local Server's status. After the Local Server instance is started using the startAsync() method, status changes can be listened to using a done listener. The Local Server status should be STARTED before starting any local services.
         
             // listen to the done listener
             localServerFuture.addDoneListener(() -> {
               // check it started and not failed
               if (LocalServer.INSTANCE.getStatus() == LocalServerStatus.STARTED) {
                 // you can now start services here:
               }
             });
         
         
        Returns:
        the server's status
        Since:
        100.0.0
      • checkInstallValid

        public boolean checkInstallValid()
        Returns true if the Local Server install is found. If true is returned then calling getInstallPath will return the path that the server will run from. If false then getInstallPath's value will be unchanged.

        The Local Server install with be searched for as follows:
        - If the setInstallPath(String) has been set, then it will be checked in this location. If it is not found here, it will return false
        - If the setInstallPath(String) is not set, then it will be checked in the path from where the application is executing. If it is not found then it will be checked in the location set in the RUNTIMELOCALSERVER_100_0 environment variable.

        Returns:
        true if local server is found
        Since:
        100.0.0
      • startAsync

        public ListenableFuture<Void> startAsync()
        Asynchronously starts the Local Server. Add a listener to the returned future to know when the server has completed starting. If the Local Server is already starting or started this call will have no effect and the ListenableFuture returned will correspond to the previous startAsync that is starting or started the server. The previous ListenableFuture will become unavailable if the service moves from STARTED into the STOPPING state. The Local Server can only be started from the STOPPED or FAILED states - calling startAsync from other states will cause an exception.
        Returns:
        A listenable future that will be complete when the server has started
        Throws:
        IllegalStateException - if the server is not in the STOPPED or FAILED state
        Since:
        100.0.0
      • stopAsync

        public ListenableFuture<Void> stopAsync()
        Asynchronously stops the Local Server. Add a listener to the returned future to know when the server has completed stopping. If the server is already stopping or stopped this call will have no effect and the ListenableFuture returned will correspond to the previous stopAsync that is stopping or stopped the server. The previous ListenableFuture will become unavailable if the service moves from STOPPED into the STARTING state. The server can only be stopped from the STARTED state - calling stopAsync from other states will cause an exception.
        Returns:
        A listenable future that will be complete when the server has stopped
        Throws:
        IllegalStateException - if the server is not in the STARTED state and there is no previous future available to return
        Since:
        100.0.0
      • addStatusChangedListener

        public void addStatusChangedListener​(LocalServer.StatusChangedListener listener)
        Adds a listener that will be fired when the Local Server status changes. The listener will be run on the UI thread if the listener is added from the UI thread, otherwise it will be invoked on the current thread.
        Parameters:
        listener - the listener
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0
      • removeStatusChangedListener

        public boolean removeStatusChangedListener​(LocalServer.StatusChangedListener listener)
        Removes a listener that would have been fired when the Local Server status changes.
        Parameters:
        listener - the listener
        Returns:
        true, if successful
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0
      • getServices

        public ListenableList<LocalService> getServices()
        Returns a read only list of available services on the Local Server instance. To know when the list changes add a listener.
        Returns:
        the available services
        Since:
        100.0.0