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: // J2SE dependencies
19: import javax.imageio.spi.ServiceRegistry; // For javadoc
20:
21: /**
22: * An optional factory that may not be available in all configurations.
23: * <p>
24: * Such factories often need some external resources. For example the default
25: * {@linkplain org.geotools.referencing.factory.epsg.AccessDialectEpsgFactory EPSG factory}
26: * need a MS-Access database installed on the client machine. This database is not bundle in
27: * Geotools distribution; if the user have not installed it, the factory can't work.
28: * <p>
29: * This interface is <strong>not</strong> a manager for automatic download of external resources.
30: * It is just a way to tell to {@link FactoryFinder} that this factory exists, but can't do its
31: * job for whatever reasons (usually a missing resource that the user shall download and install
32: * himself), so {@code FactoryFinder} has to choose an other factory. In other words, the
33: * {@code OptionalFactory} interface is used as a filter, nothing else. The process is as follows:
34: * <p>
35: * <ul>
36: * <li>When {@link FactoryRegistry#getServiceProvider} is invoked, it starts to iterate over all
37: * registered factories. If an {@linkplain ServiceRegistry#setOrdering ordering is set}, it
38: * is taken in account for the iteration order.</li>
39: * <li>If no suitable factory was found before the iterator reachs this optional factory, then
40: * {@link #isAvailable} is invoked. If it returns {@code true}, then this optional factory
41: * is processed like any other factories. Otherwise it is ignored.</li>
42: * </ul>
43: * <p>
44: * <strong>NOTE:</strong> {@code OptionalFactory} is not designed for factories with intermittent
45: * state (i.e. return value of {@link #isAvailable} varying in an unpredictable way). The behavior
46: * is undetermined if the {@code isAvailable()} state changes with time.
47: *
48: * @since 2.0
49: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/metadata/src/main/java/org/geotools/factory/OptionalFactory.java $
50: * @version $Id: OptionalFactory.java 25972 2007-06-21 13:38:35Z desruisseaux $
51: * @author Martin Desruisseaux
52: *
53: * @see org.geotools.data.DataStoreFactorySpi#isAvailable
54: */
55: public interface OptionalFactory extends Factory {
56: /**
57: * Returns {@code true} if this factory is ready for use.
58: * An optional factory may returns {@code false} for now but returns {@code true} later.
59: * However, the converse is not recommended.
60: */
61: boolean isAvailable();
62: }
|