- All Implemented Interfaces:
Serializable
,Comparable<LocalServer>
,Constable
The Local Server product is an optional component of this API 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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
An event which indicates that the status of aLocalServer
changed.static interface
The listener interface for receivingLocalServer.StatusChangedEvent
changed events fromLocalServer
resources.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener that will be fired when the Local Server status changes.boolean
Returns true if the Local Server install is found.Returns the path to the directory being used to hold app data or null ifsetAppDataPath(String)
has not been used.getError()
Returns any error if the server's status is FAILED.Returns the path to the local server directory.Returns a read only list of available services on the Local Server instance.Returns the Local Server's status.Returns the path to the directory being used to hold temporary data.getUrl()
Returns the server's URL.boolean
Returns true if web content filtering is enabled.boolean
Removes a listener that would have been fired when the Local Server status changes.void
setAppDataPath
(String path) Sets the path to a directory to be used to hold app data.void
setFilterWebContent
(boolean enable) Turns on filtering of HTML content for feature service text fields.void
setInstallPath
(String path) Sets the path to the local server directory.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.Asynchronously starts the Local Server.Asynchronously stops the Local Server.static LocalServer
Returns the enum constant of this class with the specified name.static LocalServer[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INSTANCE
The singleton instance of Local Server
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- if the argument is null
-
setInstallPath
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 FAILEDIllegalArgumentException
- if the path is empty- Since:
- 100.0.0
-
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
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 FAILEDIllegalArgumentException
- if the path is null or emptyIllegalArgumentException
- if the path is not to a directory- Since:
- 100.0.0
-
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
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 usePaths.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 FAILEDIllegalArgumentException
- if the path is null or emptyIllegalArgumentException
- if the path is not to a directory- Since:
- 100.0.0
-
getAppDataPath
Returns the path to the directory being used to hold app data or null ifsetAppDataPath(String)
has not been used.- Returns:
- the app data path or null if not set
- Since:
- 100.0.0
-
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:
-
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
Returns the Local Server's status. After the Local Server instance is started using thestartAsync()
method, status changes can be listened to using a done listener. The Local Server status should beSTARTED
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 thesetInstallPath(String)
has been set, then it will be checked in this location. If it is not found here, it will return false
- If thesetInstallPath(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 environment variable.- Returns:
- true if local server is found
- Since:
- 100.0.0
-
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 theListenableFuture
returned will correspond to the previousstartAsync
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
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 theListenableFuture
returned will correspond to the previousstopAsync
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
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
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
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
-