svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / gt2 / factory / OptionalFactory.java @ 2943
History | View | Annotate | Download (3.78 KB)
1 |
/*
|
---|---|
2 |
* Geotools 2 - OpenSource mapping toolkit
|
3 |
* (C) 2005, Geotools Project Managment Committee (PMC)
|
4 |
*
|
5 |
* This library is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU Lesser General Public
|
7 |
* License as published by the Free Software Foundation; either
|
8 |
* version 2.1 of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This library is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 |
* Lesser General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU Lesser General Public
|
16 |
* License along with this library; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
*/
|
19 |
package com.iver.cit.gvsig.fmap.core.gt2.factory; |
20 |
|
21 |
// J2SE dependencies
|
22 |
|
23 |
|
24 |
/**
|
25 |
* A factory that may not be available in all configurations.
|
26 |
*
|
27 |
* <p>Such factories often need some resources to download separatly, like a big file or a
|
28 |
* database. Those resources may not be installed in all configurations. The {@link #isReady}
|
29 |
* method tells if this factory has found every resources it needs in order to run.</p>
|
30 |
*
|
31 |
* <p>{@link FactoryRegistry#getServiceProvider} iterates over all registered factories. If an
|
32 |
* {@linkplain ServiceRegistry#setOrdering ordering is set}, it is taken in account. If no suitable
|
33 |
* factory was found before the iterator reachs this optional factory, then {@code FactoryRegistry}
|
34 |
* invokes {@link #isReady}. If the later returns {@code true}, then this optional factory is
|
35 |
* processed like any other factories. Otherwise it is ignored.</p>
|
36 |
*
|
37 |
* <p>Optional factories are useful when the preferred factory requires resources that are not
|
38 |
* guaranteed to be installed on the client machine (e.g. the <A HREF="http://www.epsg.org">EPSG
|
39 |
* database</A>) and some fallback exists (e.g. an EPSG factory based on a WKT file).</p>
|
40 |
*
|
41 |
* <p>Ignored factories are not deregistered; they will be queried again every time
|
42 |
* {@code getServiceProvider(...)} is invoked and the iterator reachs this optional factory.
|
43 |
* This means that if a resource was not available at startup time but become available later,
|
44 |
* it may be selected the next time {@code getServiceProvider(...)} is invoked. It will have no
|
45 |
* impact on previous results of {@code getServiceProvider(...)} however.</p>
|
46 |
*
|
47 |
* <p>{@code OptionalFactory} is not designed for factories with intermittent state (i.e. return
|
48 |
* value of {@link #isReady} varying in an unpredictable way). While {@code FactoryRegistry} can
|
49 |
* provides some deterministic behavior when the {@code isReady()} return value become {@code true}
|
50 |
* as explained in the previous paragraphe, the converse (when the value was {@code true} and become
|
51 |
* {@code false}) is unsafe. This is because factories returned by previous calls to
|
52 |
* {@code getServiceProvider(...)} would stop to work in an unexpected way for clients.</p>
|
53 |
*
|
54 |
* @todo This interface is like a tiny skeleton of external service API. To complete the picture
|
55 |
* we would need a callback mechanism. A listener that that client code can give to the
|
56 |
* factory, that it will call when ready. If it is ready it will be called immeditely.
|
57 |
* The above advice about alternatives could really be managed by such a factory (especially
|
58 |
* if it allowed to notify client code more then once.
|
59 |
*
|
60 |
* @author Martin Desruisseaux
|
61 |
* @version $Id: OptionalFactory.java 2943 2005-09-22 11:27:52Z fjp $
|
62 |
*/
|
63 |
public interface OptionalFactory extends Factory { |
64 |
/**
|
65 |
* Returns {@code true} if this factory is ready for use.
|
66 |
* An optional factory may returns {@code false} for now but returns {@code true} later.
|
67 |
* However, the converse is not recommended.
|
68 |
*/
|
69 |
public boolean isReady(); |
70 |
} |