org.geotoolkit.lang
Class Setup

Object
  extended by Static
      extended by Setup

public final class Setup
extends Static

A central place where to perform initialization and shutdown of all Geotk services. Users are not required to perform explicit initialization and shutdown for most services (except a few cases like World File Image Readers), since services are automatically discovered when needed (using ServiceLoader) and disposed on JVM termination (using shutdown hook). However the above-cited mechanism is not sufficient when an application is undeployed and re-deployed in a JEE environment without restarting the JVM. For example the Geotk Image I/O plugins needs to be deregistered during the undeploy phase before they get registered again during the re-deploy phase. Explicit invocations of initialize(Properties) and shutdown() methods can improve the system stability in such cases.

The amount of works performed by this class depends on the modules available in the classpath. The table below lists the work performed by current implementation. Users wanting more control can perform those tasks themselves instead than relying on the methods defined in this Setup class.

Module Methods invoked by initialize(Properties) Work done by shutdown()
geotk-utility  
geotk-coverage Remove from the JAI OperationRegistry every plugins defined in any org.geotoolkit package.
geotk-coverageio Remove from IIORegistry every plugins defined in any org.geotoolkit package.
geotk-coverageio-netcdf NetcdfDataset.shutdown().


Note on system preferences
In current implementation, invoking initialize(Properties) with a property entry platform=server also disable the usage of system preferences. This is a temporary workaround for the JDK 6 behavior on Unix system, which display "WARNING: Couldn't flush system prefs" if the etc/.java directory has not been created during the Java installation process.

This workaround may be removed in a future version if JDK 7 uses its new java.nio.file package for performing a better work with system preferences.

Since:
3.10
Version:
3.11
Author:
Martin Desruisseaux (Geomatys)
Module:
utility/geotk-utility (download)    View source code for this class

Method Summary
static void initialize(Properties properties)
          Performs the initialization of all Geotk services.
static void showControlPanel()
          Shows the Swing Graphical User Interface for configuring the Geotk library.
static void shutdown()
          Shutdowns all Geotk services.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

@Configuration
public static void initialize(Properties properties)
                       throws IllegalStateException
Performs the initialization of all Geotk services. This method is typically invoked only once. If it is invoked more than once and shutdown() has not been invoked, then every calls after the first method call are ignored.

The properties map allows some control on the initialization process. Current implementation recognizes the entries listed in the table below. Any entry not listed in this table are silently ignored.

 Key   Valid values   Default   Meaning 
 platform   server|desktop   desktop   Whatever the library is run for a desktop application or a server. 
 netcdfCacheLimit   Positive integer   0   Maximum number of elements in the NetCDF cache (0 for no cache). 
 force   true|false   false   If true, attempt a re-initialization after a shutdown. 

Parameters:
properties - Optional set of properties controlling the initialization process, or null.
Throws:
IllegalStateException - If the Geotk library has been shutdown and the given properties map doesn't contain a force=true entry.

shutdown

@Configuration
public static void shutdown()
Shutdowns all Geotk services. This method can be safely invoked even if the initialize(Properties) method has never been invoked.

The Geotk library should not be used anymore after this method call.


showControlPanel

public static void showControlPanel()
                             throws UnsupportedOperationException
Shows the Swing Graphical User Interface for configuring the Geotk library. This method requires the geotk-setup module to be present on the classpath.

Users can also display the same GUI from the command line by running the following command in the shell (replace SNAPSHOT by the actual Geotk version number):

java -jar geotk-setup-SNAPSHOT.jar

Throws:
UnsupportedOperationException - if the geotk-setup module is not on the classpath.


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.