Java Doc for FactoryRegistry.java in  » GIS » GeoTools-2.4.1 » org » geotools » factory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javax.imageio.spi.ServiceRegistry
      org.geotools.factory.FactoryRegistry

All known Subclasses:   org.geotools.factory.FactoryCreator,
FactoryRegistry
public class FactoryRegistry extends ServiceRegistry (Code)
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. Those files are usually bundled into the JAR file distributed by the vendor. If the same META-INF/services/ file appears many time in different JARs, they are processed as if their content were merged.

Example use:

Set categories = Collections.singleton(new Class[] {MathTransformProvider.class});
FactoryRegistry registry = new FactoryRegistry(categories);

// get the providers
Filter filter = null;
Hints hints = null;
Iterator providers = registry.getServiceProviders(MathTransformProvider.class, filter, hints);

NOTE: This class is not thread safe. Users are responsable for synchronisation. This is usually done in an utility class wrapping this service registry (e.g. org.geotools.referencing.ReferencingFactoryFinder ).
since:
   2.1
version:
   $Id: FactoryRegistry.java 29058 2008-02-03 17:47:07Z desruisseaux $
author:
   Martin Desruisseaux
author:
   Richard Gould
author:
   Jody Garnett
See Also:   org.geotools.referencing.FactoryFinder
See Also:   org.geotools.coverage.FactoryFinder



Field Summary
final protected static  LoggerLOGGER
     The logger for all events related to factory registry.

Constructor Summary
public  FactoryRegistry(Class category)
     Constructs a new registry for the specified category.
public  FactoryRegistry(Class[] categories)
     Constructs a new registry for the specified categories.
public  FactoryRegistry(Collection categories)
     Constructs a new registry for the specified categories.

Method Summary
 ListgetCachedProviders(Class category)
     Returns the providers available in the cache, or null if none.
final public  SetgetClassLoaders()
     Returns all class loaders to be used for scanning plugins.
public  ObjectgetServiceProvider(Class category, Filter filter, Hints hints, Hints.Key key)
     Returns the first provider in the registry for the specified category, using the specified map of hints (if any).
public  IteratorgetServiceProviders(Class category)
     Returns the providers in the registry for the specified category.
public  IteratorgetServiceProviders(Class category, Filter filter, Hints hints)
     Returns the providers in the registry for the specified category, filter and hints. Providers that are not will be ignored.
final  IteratorgetUnfilteredProviders(Class category)
     Implementation of FactoryRegistry.getServiceProviders(Class,Filter,Hints) without the filtering applied by the FactoryRegistry.isAcceptable(Object,Class,Hints,Filter) method.
final  booleanisAcceptable(Object candidate, Class category, Hints hints, Filter filter)
     Returns true is the specified factory meets the requirements specified by a map of hints and the filter.
protected  booleanisAcceptable(Object provider, Class category, Hints hints)
     Returns true if the specified provider meets the requirements specified by a map of hints .
public  voidscanForPlugins()
     Scans for factory plug-ins on the application class path.
public  booleansetOrdering(Class category, Comparator comparator)
     Set pairwise ordering between all factories according a comparator.
public  booleansetOrdering(Class base, boolean set, Filter service1, Filter service2)
     Sets or unsets a pairwise ordering between all factories meeting a criterion.

Field Detail
LOGGER
final protected static Logger LOGGER(Code)
The logger for all events related to factory registry.




Constructor Detail
FactoryRegistry
public FactoryRegistry(Class category)(Code)
Constructs a new registry for the specified category.
Parameters:
  category - The single category.
since:
   2.4



FactoryRegistry
public FactoryRegistry(Class[] categories)(Code)
Constructs a new registry for the specified categories.
Parameters:
  categories - The categories.
since:
   2.4



FactoryRegistry
public FactoryRegistry(Collection categories)(Code)
Constructs a new registry for the specified categories.
Parameters:
  categories - The categories.




Method Detail
getCachedProviders
List getCachedProviders(Class category)(Code)
Returns the providers available in the cache, or null if none. To be overridden by FactoryCreator only.



getClassLoaders
final public Set getClassLoaders()(Code)
Returns all class loaders to be used for scanning plugins. Current implementation returns the following class loaders:

The actual number of class loaders may be smaller if redundancies was found. If some more classloaders should be scanned, they shall be added into the code of this method.



getServiceProvider
public Object getServiceProvider(Class category, Filter filter, Hints hints, Hints.Key key) throws FactoryRegistryException(Code)
Returns the first provider in the registry for the specified category, using the specified map of hints (if any). This method may the first time it is invoked. Except as a result of this scan, no new provider instance is created by the default implementation of this method. The FactoryCreator class change this behavior however.
Parameters:
  category - The category to look for. Must be one of the categories declared to theconstructor. Usually an interface class (not the actual implementationclass).
Parameters:
  filter - An optional filter, or null if none.This is used for example in order to select the first factory for some.
Parameters:
  hints - A , or null if none.
Parameters:
  key - The key to use for looking for a user-provided instance in the hints, or null if none. A factory for use for thespecified category and hints. The returns type is Object instead ofFactory because the factory implementation doesn't need to be a Geotools one.
throws:
  FactoryNotFoundException - if no factory was found for the specified category, filterand hints.
throws:
  FactoryRegistryException - if a factory can't be returned for some other reason.
See Also:   FactoryRegistry.getServiceProviders(Class,Filter,Hints)
See Also:   FactoryCreator.getServiceProvider



getServiceProviders
public Iterator getServiceProviders(Class category)(Code)
Returns the providers in the registry for the specified category. Providers that are not will be ignored. This method will the first time it is invoked for the given category.
Parameters:
  category - The category to look for. Usually an interface class(not the actual implementation class). Factories ready to use for the specified category.FactoryRegistry.getServiceProviders(Class,Filter,Hints)



getServiceProviders
public Iterator getServiceProviders(Class category, Filter filter, Hints hints)(Code)
Returns the providers in the registry for the specified category, filter and hints. Providers that are not will be ignored. This method will the first time it is invoked for the given category.
Parameters:
  category - The category to look for. Usually an interface class(not the actual implementation class).
Parameters:
  filter - The optional filter, or null .
Parameters:
  hints - The optional user requirements, or null . Factories ready to use for the specified category, filter and hints.
since:
   2.3



getUnfilteredProviders
final Iterator getUnfilteredProviders(Class category)(Code)
Implementation of FactoryRegistry.getServiceProviders(Class,Filter,Hints) without the filtering applied by the FactoryRegistry.isAcceptable(Object,Class,Hints,Filter) method. If this filtering is not already presents in the filter given to this method, then it must be applied on the elements returned by the iterator. The later is preferrable when:

  • There is some cheaper tests to perform before isAcceptable .
  • We don't want a restrictive filter in order to avoid trigging a classpath scan if this method doesn't found any element to iterate.

Note: FactoryRegistry.synchronizeIteratorProviders should also be invoked once before this method.




isAcceptable
final boolean isAcceptable(Object candidate, Class category, Hints hints, Filter filter)(Code)
Returns true is the specified factory meets the requirements specified by a map of hints and the filter. This method is the entry point for the following public methods:
  • Singleton #getServiceProvider (Class category, Filter, Hints, Hints.Key)
  • Iterator #getServiceProviders(Class category, Filter, Hints)

Parameters:
  candidate - The factory to checks.
Parameters:
  category - The factory category. Usually an interface.
Parameters:
  hints - The optional user requirements, or null .
Parameters:
  filter - The optional filter, or null . true if the factory meets the user requirements.



isAcceptable
protected boolean isAcceptable(Object provider, Class category, Hints hints)(Code)
Returns true if the specified provider meets the requirements specified by a map of hints . The default implementation always returns true . There is no need to override this method for AbstractFactory implementations, since their hints are automatically checked. Override this method for non-Geotools implementations. For example a JTS geometry factory finder may overrides this method in order to check if a com.vividsolutions.jts.geom.GeometryFactory uses the required com.vividsolutions.jts.geom.CoordinateSequenceFactory . Such method should be implemented as below, since this method may be invoked for various kind of objects:
 if (provider instanceof GeometryFactory) {
 // ... Check the GeometryFactory state here.
 }
 

Parameters:
  provider - The provider to checks.
Parameters:
  category - The factory category. Usually an interface.
Parameters:
  hints - The user requirements, or null if none. true if the provider meets the user requirements.



scanForPlugins
public void scanForPlugins()(Code)
Scans for factory plug-ins on the application class path. This method is needed because the application class path can theoretically change, or additional plug-ins may become available. Rather than re-scanning the classpath on every invocation of the API, the class path is scanned automatically only on the first invocation. Clients can call this method to prompt a re-scan. Thus this method need only be invoked by sophisticated applications which dynamically make new plug-ins available at runtime.



setOrdering
public boolean setOrdering(Class category, Comparator comparator)(Code)
Set pairwise ordering between all factories according a comparator. Calls to (factory1, factory2) should returns:
  • -1 if factory1 is preferred to factory2
  • +1 if factory2 is preferred to factory1
  • 0 if there is no preferred order between factory1 and factory2

Parameters:
  category - The category to set ordering.
Parameters:
  comparator - The comparator to use for ordering. true if at least one ordering setting has been modified as a consequenceof this call.



setOrdering
public boolean setOrdering(Class base, boolean set, Filter service1, Filter service2)(Code)
Sets or unsets a pairwise ordering between all factories meeting a criterion. For example in the CRS framework ( org.geotools.referencing.FactoryFinder ), this is used for setting ordering between all factories provided by two vendors, or for two authorities. If one or both factories are not currently registered, or if the desired ordering is already set/unset, nothing happens and false is returned.
Parameters:
  base - The base category. Only categories to base will be processed.
Parameters:
  set - true for setting the ordering, or false for unsetting.
Parameters:
  service1 - Filter for the preferred factory.
Parameters:
  service2 - Filter for the factory to which service1 is preferred.



Methods inherited from javax.imageio.spi.ServiceRegistry
public boolean contains(Object provider)(Code)(Java Doc)
public void deregisterAll(Class category)(Code)(Java Doc)
public void deregisterAll()(Code)(Java Doc)
public boolean deregisterServiceProvider(T provider, Class<T> category)(Code)(Java Doc)
public void deregisterServiceProvider(Object provider)(Code)(Java Doc)
public void finalize() throws Throwable(Code)(Java Doc)
public Iterator<Class<?>> getCategories()(Code)(Java Doc)
public T getServiceProviderByClass(Class<T> providerClass)(Code)(Java Doc)
public Iterator<T> getServiceProviders(Class<T> category, boolean useOrdering)(Code)(Java Doc)
public Iterator<T> getServiceProviders(Class<T> category, Filter filter, boolean useOrdering)(Code)(Java Doc)
public static Iterator<T> lookupProviders(Class<T> providerClass, ClassLoader loader)(Code)(Java Doc)
public static Iterator<T> lookupProviders(Class<T> providerClass)(Code)(Java Doc)
public boolean registerServiceProvider(T provider, Class<T> category)(Code)(Java Doc)
public void registerServiceProvider(Object provider)(Code)(Java Doc)
public void registerServiceProviders(Iterator providers)(Code)(Java Doc)
public boolean setOrdering(Class<T> category, T firstProvider, T secondProvider)(Code)(Java Doc)
public boolean unsetOrdering(Class<T> category, T firstProvider, T secondProvider)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.