Java Doc for AbstractFactory.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
   org.geotools.factory.AbstractFactory

All known Subclasses:   org.geotools.data.geometryless.LocationsXYDataStoreFactory,  org.geotools.data.geometryless.BBOXDataStoreFactory,  org.geotools.coverage.grid.GridCoverageFactory,  org.geotools.factory.FactoryUsingVolatileDependencies,  org.geotools.referencing.factory.ReferencingFactory,  org.geotools.data.geometryless.JDBCDataStoreFactory,
AbstractFactory
public class AbstractFactory implements Factory,RegisterableService(Code)
Skeletal implementation of factories. This base classe provides no createFoo methods, (they must be provided by subclasses), but provides two convenience features:

  • An initially empty to be filled by subclasses constructors. They are the hints to be returned by AbstractFactory.getImplementationHints .
  • An automatic applied on the basis of subclasses-provided rank.

When more than one factory implementation is for the same category (i.e. they implement the same Factory sub-interface), the actual instance to be used is selected according their and user-supplied . Hints have precedence. If more than one factory matches the hints (including the common case where the user doesn't provide any hint at all), then ordering matter.

The ordering is unspecified for every pairs of factories with the same . This implies that the ordering is unspecified between all factories created with the , since they all have the same level.

How hints are set

Hints are used for two purposes. The distinction is important because the set of hints may not be identical in both cases:

  1. Hints are used for creating new factories.
  2. Hints are used in order to check if an existing factory is suitable.

AbstractFactory do not provides any facility for the first case. Factories implementations shall inspect themselves all relevant hints supplied by the user, and pass them to any dependencies. Do not use the AbstractFactory.hints field for that; use the hints provided by the user in the constructor. If all dependencies are created at construction time (constructor injection), there is no need to keep user's hints once the construction is finished.

The AbstractFactory.hints field is for the second case only. Implementations shall copy in this field only the user's hints that are know to be relevant to this factory. If a hint is relevant but the user didn't specified any value, the hint key should be added to the AbstractFactory.hints map anyway with a null value. Only direct dependencies shall be put in the AbstractFactory.hints map. Indirect dependencies (i.e. hints used by other factories used by this factory) will be inspected automatically by FactoryRegistry in a recursive way.

Note: The lack of constructor expecting a Map argument is intentional. This is in order to discourage blind-copy of all user-supplied hints to the AbstractFactory.hints map.

Example: Lets two factories, A and B. Factory A need an instance of Factory B. Factory A can be implemented as below:
CodeObservations
 class FactoryA extends AbstractFactory {
 FactoryB fb;
 FactoryA(Hints userHints) {
 fb = FactoryFinder.getFactoryB(userHints);
 hints.put(Hints.FACTORY_B, fb);
 }
 }
 
  • The user-supplied map ( userHints ) is never modified.
  • All hints relevant to other factories are used in the constructor. Hints relevant to factory B are used when FactoryFinder.getFactoryB(...) is invoked.
  • The FactoryA constructor stores only the hints relevant to FactoryA . Indirect dependencies (e.g. hints relevant to FactoryB ) will be inspected recursively by FactoryRegistry .
  • In the above example, AbstractFactory.hints will never be used for creating new factories.

since:
   2.1
version:
   $Id: AbstractFactory.java 25421 2007-05-05 16:55:18Z desruisseaux $
author:
   Martin Desruisseaux



Field Summary
final public static  intMAXIMUM_PRIORITY
     The maximum priority for a factory, which is .
final public static  intMINIMUM_PRIORITY
     The minimum priority for a factory, which is .
final public static  intNORMAL_PRIORITY
     The default priority, which is .
final protected  Maphints
     The .
final protected  intpriority
     The priority for this factory, as a number between AbstractFactory.MINIMUM_PRIORITY and AbstractFactory.MAXIMUM_PRIORITY inclusive.

Constructor Summary
protected  AbstractFactory()
     Creates a new factory with the .
protected  AbstractFactory(int priority)
     Constructs a factory with the specified priority.

Method Summary
final public  booleanequals(Object object)
     Compares this factory with the specified object for equality.
public  MapgetImplementationHints()
     Returns an view of .
public  intgetPriority()
     Returns the priority for this factory, as a number between AbstractFactory.MINIMUM_PRIORITY and AbstractFactory.MAXIMUM_PRIORITY inclusive.
final public  inthashCode()
     Returns a hash value for this factory.
public  voidonDeregistration(ServiceRegistry registry, Class category)
     Called when this factory is removed from the given category of the given registry .
public  voidonRegistration(ServiceRegistry registry, Class category)
     Called when this factory is added to the given category of the given registry .
public  StringtoString()
     Returns a string representation of this factory.
static  StringtoString(Map hints)
     Returns a string representation of the specified hints.

Field Detail
MAXIMUM_PRIORITY
final public static int MAXIMUM_PRIORITY(Code)
The maximum priority for a factory, which is . Factories with highest priority will be preferred to any other factory in the same .
See Also:   AbstractFactory.priority
See Also:   AbstractFactory.onRegistration



MINIMUM_PRIORITY
final public static int MINIMUM_PRIORITY(Code)
The minimum priority for a factory, which is . Factories with lowest priority will be used only if there is no other factory in the same .
See Also:   AbstractFactory.priority
See Also:   AbstractFactory.onRegistration



NORMAL_PRIORITY
final public static int NORMAL_PRIORITY(Code)
The default priority, which is .
See Also:   AbstractFactory.priority
See Also:   AbstractFactory.onRegistration



hints
final protected Map hints(Code)
The . This map should be filled by subclasses at construction time. If possible, constructors should not copy blindly all user-provided hints. They should select only the relevant hints and resolve them as of contract.

Note: This field is not an instance of Hints because:

  • The primary use of this map is to check if this factory can be reused. It is not for creating new factories.
  • This map needs to allow null values, as of contract.



priority
final protected int priority(Code)
The priority for this factory, as a number between AbstractFactory.MINIMUM_PRIORITY and AbstractFactory.MAXIMUM_PRIORITY inclusive. Priorities are used by FactoryRegistry for selecting a preferred factory when many are found for the same service.
See Also:   AbstractFactory.getPriority




Constructor Detail
AbstractFactory
protected AbstractFactory()(Code)
Creates a new factory with the .



AbstractFactory
protected AbstractFactory(int priority)(Code)
Constructs a factory with the specified priority.
Parameters:
  priority - The priority for this factory, as a number betweenAbstractFactory.MINIMUM_PRIORITY and AbstractFactory.MAXIMUM_PRIORITY inclusive.




Method Detail
equals
final public boolean equals(Object object)(Code)
Compares this factory with the specified object for equality. The default implementation returns true if and only if:

  • Both objects are of the exact same class (a is instance of relationship is not enough).
  • are .

The requirement for the exact same class is needed for consistency with the working, since at most one instance of a given class in a registry.
since:
   2.3




getImplementationHints
public Map getImplementationHints()(Code)
Returns an view of . The map of hints, or an empty map if none.



getPriority
public int getPriority()(Code)
Returns the priority for this factory, as a number between AbstractFactory.MINIMUM_PRIORITY and AbstractFactory.MAXIMUM_PRIORITY inclusive. Priorities are used by FactoryRegistry for selecting a preferred factory when many are found for the same service. The default implementation returns AbstractFactory.priority with no change. Subclasses should override this method if they want to return a higher or lower priority.
since:
   2.3



hashCode
final public int hashCode()(Code)
Returns a hash value for this factory. The default implementation computes the hash value using only immutable properties. This computation do not relies on , since there is no garantee that they will not change.
since:
   2.3



onDeregistration
public void onDeregistration(ServiceRegistry registry, Class category)(Code)
Called when this factory is removed from the given category of the given registry . The object may still be registered under another category or categories.

This method is invoked automatically when this factory is no longer registered as a plugin, and should not be invoked directly by the user.
Parameters:
  registry - A service registry from which this object is being (wholly or partially)deregistered.
Parameters:
  category - The registry category from which this object is being deregistered.




onRegistration
public void onRegistration(ServiceRegistry registry, Class category)(Code)
Called when this factory is added to the given category of the given registry . The factory may already be registered under another category or categories.

This method is invoked automatically when this factory is registered as a plugin, and should not be invoked directly by the user. The default implementation iterates through all services under the same category that extends the AbstractFactory class, and set the ordering according the priority given at construction time.
Parameters:
  registry - A service registry where this factory has been registered.
Parameters:
  category - The registry category under which this object has been registered.
See Also:   AbstractFactory.MINIMUM_PRIORITY
See Also:   AbstractFactory.MAXIMUM_PRIORITY




toString
public String toString()(Code)
Returns a string representation of this factory. This method is mostly for debugging purpose, so the string format may vary across different implementations or versions. The default implementation formats all as a tree. If the implementation hints include some dependencies, then the implementation hints for those dependencies will appears under a tree branch.
since:
   2.3



toString
static String toString(Map hints)(Code)
Returns a string representation of the specified hints. This is used by Hints.toString in order to share the code provided in this class.



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.