01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.factory;
17:
18: /**
19: * A factory that can not determines all its dependencies at construction time.
20: * Because this factory may creates new factories at any time, it must keep all
21: * user-supplied hints. The general contract of {@link #hints} said that we can't
22: * use this field for creating new factories. But instances of this classe are special cases
23: * where we can, because this class retains all user-supplied hints.
24: *
25: * <p>Extends this class only if you really need to keep all user-supplied hints, because
26: * doing so has a cost:</p>
27: * <ul>
28: * <li><p>{@link FactoryRegistry} is less likely to reuse existing factory instances, because
29: * any value found in {@link #hints} that do not agree with a user-supplied hint will cause
30: * {@code FactoryRegistry} to discarts this instance, even if the hint was actually
31: * irrelevant to this factory.</p></li>
32: * <li><p>The user-supplied hints may contain references to big objects (for example a coordinate
33: * transform backed by a grid), and some of them may not be relevant to this factory.
34: * Retaining all hints will prevents their garbage collection.<p></li>
35: * </ul>
36: *
37: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/factory/FactoryUsingVolatileDependencies.java $
38: * @version $Id: FactoryUsingVolatileDependencies.java 22443 2006-10-27 20:47:22Z desruisseaux $
39: * @author Martin Desruisseaux
40: *
41: * @deprecated This class should be a marker interface instead of an {@code AbstractFactory}
42: * subclass. We will make this change in a future version. When this change is
43: * done, {@link org.geotools.referencing.factory.AllAuthoritiesFactory} should
44: * implement this interface.
45: */
46: public class FactoryUsingVolatileDependencies extends AbstractFactory {
47: /**
48: * Constructs a factory with a default priority.
49: *
50: * @param hints The user-supplied hints.
51: */
52: public FactoryUsingVolatileDependencies(final Hints hints) {
53: super ();
54: this .hints.putAll(hints);
55: }
56:
57: /**
58: * Constructs a factory with the specified priority.
59: *
60: * @param hints The user-supplied hints.
61: * @param priority The priority for this factory, as a number between
62: * {@link #MINIMUM_PRIORITY} and {@link #MAXIMUM_PRIORITY} inclusive.
63: */
64: public FactoryUsingVolatileDependencies(final Hints hints,
65: final int priority) {
66: super(priority);
67: this.hints.putAll(hints);
68: }
69: }
|