org.geotools.factory

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.factory 
org.geotools.factory
org.geotools.factory Utility classes which enable dynamic binding to factory implementations at runtime.

Because Geotools core API consists almost exclusively of interfaces (including GeoAPI), factories play a role in how developers use the API. Although the interfaces that are declared in GeoAPI are implemented in various Geotools packages you should not use those classes directly. Instead you should use factories.

J2SE's {@link javax.imageio.spi.ServiceRegistry} provides a general way (even if it is defined in a {@code javax.imageio} subpackage) to instantiate and manage factories (also called providers). Each factory implementation should be declared in {@code META-INF/services} directory, usually bundled in every JAR file. For example if a JAR file provides one or more {@link org.opengis.referencing.datum.DatumFactory} implementations, then it must provide the following file:

META-INF/services/org.opengis.referencing.datum.DatumFactory

with a content similar to the one below:

com.mycompany.MyDatumFactory1
com.mycompany.MyDatumFactory2
com.mycompany.MyDatumFactory3

The ordering is initially unspecified. Users can {@linkplain javax.imageio.spi.ServiceRegistry#setOrdering set an ordering} explicitly themselves, or implementations can do that automatically {@linkplain javax.imageio.spi.RegisterableService#onRegistration on registration}. The {@link org.geotools.factory.AbstractFactory} class provides a simple way to setup ordering on registration on the basis of a {@linkplain org.geotools.factory.AbstractFactory#priority priority} number.

If a user wants a specific implementation, he can {@linkplain javax.imageio.spi.ServiceRegistry#getServiceProviders iterates through registered ones} and pickup the desired implementation himself. An alternative is to bundle the criterions in a {@linkplain org.geotools.factory.Hints map of hints} and lets the registry selects an implementation accordingly. This later functionality is not provided by the standard {@link javax.imageio.spi.ServiceRegistry}, but is provided by Geotools's {@link org.geotools.factory.FactoryRegistry} extension. This class extends the service registry API with the following functionalities:

  • A {@link org.geotools.factory.FactoryRegistry#scanForPlugins() scanForPlugins()} method that scans for plugins in the {@linkplain java.lang.Class#getClassLoader registry class loader}, the {@linkplain java.lang.Thread#getContextClassLoader thread context class loader} and the {@linkplain java.lang.ClassLoader#getSystemClassLoader system class loader}. Additionally, {@code scanForPlugins()} looks for any implementation specified as {@linkplain java.lang.System#getProperty(String) system property}.

  • Filters out automatically {@linkplain org.geotools.factory.OptionalFactory optional factories} when they are not {@linkplain org.geotools.factory.OptionalFactory#isAvailable available}.

  • When more than one implementation is available for the same {@link org.geotools.factory.Factory} subinterface, an optional set of {@linkplain org.geotools.factory.Hints hints} can specifies the criterions that the desired implementation must meets. If a factory implementation depends on other factories, the dependencies hints are checked recursively.

  • Optionally, if no factory matches the given hints, a new instance can be {@linkplain org.geotools.factory.FactoryCreator#createServiceProvider automatically created}. However, those new instances are not registered. If creation of new instances at every {@link org.geotools.factory.FactoryRegistry#getServiceProvider getServiceProvider(...)} method invocation is undesired, an implementation matching the expected {@linkplain org.geotools.factory.Hints hints} should be registered in the {@code META-INF/services} directory, as explained above.

Note that the {@linkplain org.geotools.factory.Hints hints}, if provided, don't need to apply directly to the requested factory category. They may apply indirectly through some dependency. A typical example is a request for any {@link com.vividsolutions.jts.geom.GeometryFactory} instance, providing that this instance uses a particular {@link com.vividsolutions.jts.geom.CoordinateSequenceFactory} implementation.

Java Source File NameTypeComment
AbstractFactory.javaClass Skeletal implementation of factories.
AbstractFactoryTest.javaClass Tests AbstractFactory .
BasicFactories.javaClass Defines a common abstraction for getting the different factories.
BufferedFactory.javaInterface A marker interface for factories that are buffering their objects in some way.
CommonFactoryFinder.javaClass Defines static methods used to access the application's default implementation for some common factories.
CommonFactoryFinderTest.javaClass
DummyFactory.javaInterface An internal dummy factory for testing factory dependencies. It doesn't matter if this factory is registered or not.
DummyFactoryIteratorProvider.javaClass An implementation of FactoryIteratorProvider over the DummyFactory .
Factories.javaClass Utility methods that apply to all .
Factory.javaInterface Base interface for Geotools factories (i.e.
FactoryComparator.javaClass Compares two factories for equality.
FactoryConfigurationError.javaClass Deadly error.
FactoryCreator.javaClass A capable to creates factories if no appropriate instance was found in the registry.

This class maintains a cache of previously created factories, as .

FactoryFinder.javaClass Base class for factory finders.
FactoryIteratorProvider.javaInterface Provides iterators over factories of specified categories.
FactoryIteratorProviderTest.javaClass Tests FactoryIteratorProvider addition in Factories .
FactoryNotFoundException.javaClass Thrown when a factory can't be found in the registery.
FactoryRegistry.javaClass A registry for factories, organized by categories (usualy by interface). For example org.opengis.referencing.crs.CRSFactory .class is a category, and org.opengis.referencing.operation.MathTransformFactory .class is an other category.

For each category, implementations are registered in a file placed in the META-INF/services/ directory, as specified in the ServiceRegistry javadoc.

FactoryRegistryException.javaClass Thrown when a factory can't be found or can't be instantiate.
FactoryRegistryTest.javaClass Tests FactoryRegistry implementation.
FactoryUsingVolatileDependencies.javaClass A factory that can not determines all its dependencies at construction time. Because this factory may creates new factories at any time, it must keep all user-supplied hints.
GeoTools.javaClass Static methods relative to the global GeoTools configuration.
GeoToolsTest.javaClass Tests GeoTools .
Hints.javaClass A set of hints providing control on factories to be used.
OptionalFactory.javaInterface An optional factory that may not be available in all configurations.

Such factories often need some external resources.

RecursiveSearchException.javaClass Thrown when FactoryRegistry is invoked recursively for the same category.
StrictHints.javaClass Hints which should not be merged with global hints, usually because the global hints have already been merged.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.