org.geotools.factory
Class GeoTools

Object
  extended by GeoTools

public final class GeoTools
extends Object

Static methods relative to the global GeoTools configuration. GeoTools can be configured in a system-wide basis through system properties, some of them are declared as String constants in this class.

There are many aspects to the configuration of GeoTools:

Since:
2.4
Author:
Jody Garnett, Martin Desruisseaux
Module:
modules/library/metadata (gt-metadata.jar)

Field Summary
static String CRS_AUTHORITY_EXTRA_DIRECTORY
          The system property key for the default value to be assigned to the CRS_AUTHORITY_EXTRA_DIRECTORY hint.
static String EPSG_DATA_SOURCE
          The system property key for the default value to be assigned to the EPSG_DATA_SOURCE hint.
static String FORCE_LONGITUDE_FIRST_AXIS_ORDER
          The system property key for the default value to be assigned to the FORCE_LONGITUDE_FIRST_AXIS_ORDER hint.
 
Method Summary
static void addChangeListener(ChangeListener listener)
          Adds the specified listener to the list of objects to inform when system-wide configuration changed.
static void addFactoryIteratorProvider(FactoryIteratorProvider provider)
          Adds an alternative way to search for factory implementations.
static void fireConfigurationChanged()
          Informs every listeners that system-wide configuration changed.
static String fixName(Context context, String name)
          Converts a GeoTools name to the syntax used by the specified JNDI context.
static String fixName(String name)
          Converts a GeoTools name to the syntax used by the GeoTools JNDI context.
static Hints getDefaultHints()
          Returns the default set of hints used for the various utility classes.
static InitialContext getInitialContext(Hints hints)
          Returns the default initial context.
static Version getVersion()
          Reports back the version of GeoTools being used.
static void init(Hints hints)
          Initializes GeoTools for use.
static void init(InitialContext applicationContext)
          Forces the initial context for test cases, or as needed.
static void main(String[] args)
          Reports the GeoTools version number to the standard output stream.
static void removeChangeListener(ChangeListener listener)
          Removes the specified listener from the list of objects to inform when system-wide configuration changed.
static void removeFactoryIteratorProvider(FactoryIteratorProvider provider)
          Removes a provider that was previously added.
 void setLoggerFactory(LoggerFactory factory)
          Sets the global logger factory.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRS_AUTHORITY_EXTRA_DIRECTORY

public static final String CRS_AUTHORITY_EXTRA_DIRECTORY
The system property key for the default value to be assigned to the CRS_AUTHORITY_EXTRA_DIRECTORY hint.

See Also:
Hints.CRS_AUTHORITY_EXTRA_DIRECTORY, getDefaultHints(), Constant Field Values

EPSG_DATA_SOURCE

public static final String EPSG_DATA_SOURCE
The system property key for the default value to be assigned to the EPSG_DATA_SOURCE hint.

See Also:
Hints.EPSG_DATA_SOURCE, getDefaultHints(), Constant Field Values

FORCE_LONGITUDE_FIRST_AXIS_ORDER

public static final String FORCE_LONGITUDE_FIRST_AXIS_ORDER
The system property key for the default value to be assigned to the FORCE_LONGITUDE_FIRST_AXIS_ORDER hint. This setting can provide a transition path for projects expecting a (longitude, latitude) axis order on a system-wide level. Application developpers can set the default value as below:
 System.setProperty(FORCE_LONGITUDE_FIRST_AXIS_ORDER, "true");
 
Note that this system property applies mostly to the default EPSG factory. Most other factories ("CRS", "AUTO", etc.) don't need this property since they use (longitude, latitude) axis order by design.

See Also:
Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, getDefaultHints(), Constant Field Values
Method Detail

getVersion

public static Version getVersion()
Reports back the version of GeoTools being used.

Returns:
The current GeoTools version.

setLoggerFactory

public void setLoggerFactory(LoggerFactory factory)
Sets the global logger factory. This method is the same as Logging.GEOTOOLS.setLoggerFactory(factory). GeoTools ships with support for Commons-logging and log4j. This method exists to allow you supply your own implementation (this is sometimes required when using a GeoTools application in an exotic environment like Eclipse, OC4J or your application).

Parameters:
factory - The logger factory to use.
Since:
2.4
See Also:
Logging.setLoggerFactory(LoggerFactory)

init

public static void init(Hints hints)
Initializes GeoTools for use. This convenience method performs various tasks (more may be added in the future), including setting up the Java logging framework in one of the following states:

In addition, the default hints are initialized to the specified hints.

Note that invoking this method is usually not needed for proper working of the Geotools library. It is just a convenience method for overwriting some Java and Geotools default settings in a way that seems to be common in server environment. Such overwriting may not be wanted for every situations.

Example of typical invocation in a Geoserver environment:

 Hints hints = new Hints();
 hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
 hints.put(Hints.FORCE_AXIS_ORDER_HONORING, "http");
 GeoTools.init(hints);
 

Parameters:
hints - The hints to use.
See Also:
Logging.setLoggerFactory(String), Logging.forceMonolineConsoleOutput(), Hints.putSystemDefault(java.awt.RenderingHints), getDefaultHints()

init

public static void init(InitialContext applicationContext)
Forces the initial context for test cases, or as needed.

Parameters:
applicationContext - The initial context to use.
Since:
2.4
See Also:
getInitialContext(org.geotools.factory.Hints)

getDefaultHints

public static Hints getDefaultHints()
Returns the default set of hints used for the various utility classes. This default set is determined by:

Long term plan: We would like to transition the utility classes to being injected with their required factories, either by taking Hints as part of their constructor, or otherwise. Making this change would be a three step process 1) create instance methods for each static final class method 2) create an singleton instance of the class 3) change each static final class method into a call to the singleton. With this in place we could then encourage client code to make use of utility class instances before eventually retiring the static final methods.

Returns:
A copy of the default hints. It is safe to add to it.

getInitialContext

public static InitialContext getInitialContext(Hints hints)
                                        throws NamingException
Returns the default initial context.

Parameters:
hints - An optional set of hints, or null if none.
Returns:
The initial context (never null).
Throws:
NamingException - if the initial context can't be created.
Since:
2.4
See Also:
init(InitialContext)

fixName

public static String fixName(String name)
Converts a GeoTools name to the syntax used by the GeoTools JNDI context. Names may be constructed in a variety of ways depending on the implementation of InitialContext. GeoTools uses "jdbc:EPSG" internally, but many implementaitons use the form "jdbc/EPSG". Calling this method before use will set the name right.

Parameters:
name - Name of the form "jdbc:EPSG", or null.
Returns:
Name fixed up with Context.composeName(String,String), or null if the given name was null.
Since:
2.4

fixName

public static String fixName(Context context,
                             String name)
Converts a GeoTools name to the syntax used by the specified JNDI context. This method is similar to fixName(String), but uses the specified context instead of the GeoTools one.

Parameters:
context - The context to use, or null if none.
name - Name of the form "jdbc:EPSG", or null.
Returns:
Name fixed up with Context.composeName(String,String), or null if the given name was null.
Since:
2.4

addFactoryIteratorProvider

public static void addFactoryIteratorProvider(FactoryIteratorProvider provider)
Adds an alternative way to search for factory implementations. FactoryRegistry has a default mechanism bundled in it, which uses the content of all META-INF/services directories found on the classpath. This addFactoryIteratorProvider method allows to specify additional discovery algorithms. It may be useful in the context of some frameworks that use the constructor injection pattern, like the Spring framework.

Parameters:
provider - A new provider for factory iterators.

removeFactoryIteratorProvider

public static void removeFactoryIteratorProvider(FactoryIteratorProvider provider)
Removes a provider that was previously added. Note that factories already obtained from the specified provider will not be deregistered by this method.

Parameters:
provider - The provider to remove.

addChangeListener

public static void addChangeListener(ChangeListener listener)
Adds the specified listener to the list of objects to inform when system-wide configuration changed.

Parameters:
listener - The listener to add.

removeChangeListener

public static void removeChangeListener(ChangeListener listener)
Removes the specified listener from the list of objects to inform when system-wide configuration changed.

Parameters:
listener - The listener to remove.

fireConfigurationChanged

public static void fireConfigurationChanged()
Informs every listeners that system-wide configuration changed.


main

public static void main(String[] args)
Reports the GeoTools version number to the standard output stream.

Parameters:
args - Command line arguments.


Copyright © 1996-2010 Geotools. All Rights Reserved.