001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wms;
006:
007: import org.geotools.factory.Factory;
008: import org.vfny.geoserver.config.WMSConfig;
009: import org.vfny.geoserver.global.WMS;
010: import java.util.Set;
011:
012: /**
013: * Constructs a live GetMapProducer.
014: *
015: * <p>
016: * An instance of this interface should exist for all map producers which want
017: * to take advantage of the dynamic plugin system. In addition to implementing
018: * this interface GetMap producers should have a services file:
019: * </p>
020: *
021: * <p>
022: * <code>org.vfny.geoserver.responses.wms.GetMapProducerFactorySpi</code>
023: * </p>
024: *
025: * <p>
026: * The file should contain a single line which gives the full name of the
027: * implementing class.
028: * </p>
029: *
030: * <p>
031: * example:<br/><code>e.g.
032: * org.vfny.geoserver.wms.GIFLegendGraphicProducerSpi</code>
033: * </p>
034: *
035: * <p>
036: * The factories are never called directly by client code, instead the
037: * GeoTools' FactoryFinder class is used.
038: * </p>
039: *
040: * <p>
041: * The following example shows how a user might obtain GetMapProducer capable
042: * of generating a map image in GIF format and send the generated legend to a
043: * file:
044: * </p>
045: *
046: * <p>
047: * <pre><code>
048: * WMSConfig config = getServletContext().getAttribute(WMSConfig.CONFIG_KEY);
049: *
050: * GetMapProducerSpi gmpf = null;
051: * Iterator it = FactoryFinder.factories(GeMapProducerFactorySpi.class);
052: * while (it.hasNext()) {
053: * GeMapProducerFactorySpi tmpGmpf = (GeMapProducerFactorySpi) it.next();
054: * if (tmpGmpf.canProduce("image/gif")) {
055: * gmpf = tmpGmpf;
056: * break;
057: * }
058: * }
059: * ...
060: * GetMapProducer producer = gmpf.createMapProducer("image/gif");
061: * WMSMapContext ctx = ...
062: * producer.produceMap(ctx);
063: * OutputStream out = new FileOutputStream("/map.gif");
064: * producer.writeTo(out);
065: * </code></pre>
066: * </p>
067: *
068: * @author Gabriel Roldan, Axios Engineering
069: * @version $Id: GetMapProducerFactorySpi.java 6326 2007-03-15 18:36:40Z jdeolive $
070: */
071: public interface GetMapProducerFactorySpi extends Factory {
072: /**
073: * Returns a descriptive name for the factory instance.
074: *
075: * @return a descriptive name for the factory instance
076: */
077: String getName();
078:
079: /**
080: * Returns a <code>java.util.Set<String></code> of the MIME types the
081: * map producers this factory can create are able to handle.
082: *
083: * @return the Set of supported output image mime types.
084: */
085: Set getSupportedFormats();
086:
087: /**
088: * Checks if the GetMapProducer instances this factory serves will be able
089: * of working properly (e.g., external dependencies are in place). This
090: * method should be used to avoid asking for producer instances if they
091: * are likely to fail.
092: *
093: * @return wether this factory is able to produce producer instances.
094: */
095: boolean isAvailable();
096:
097: /**
098: * Returns wether the legend producers created by this factory can create
099: * map images in the specified output format.
100: *
101: * @param mapFormat a MIME type string to check if this producer is able to
102: * handle.
103: *
104: * @return <code>true</code> if <code>mimeType</code> is an image format
105: * supported by the producers this factory serves.
106: */
107: boolean canProduce(String mapFormat);
108:
109: /**
110: * Creates and instance of a GetMapProducer suitable to create map images
111: * in the specified image format.
112: *
113: * @param mapFormat the MIME type of the desired image
114: * @param wms the WMS module
115: *
116: * @return a GetMapProducer capable of creating maps in <code>format</code>
117: * image format.
118: *
119: * @throws IllegalArgumentException if <code>format</code> is not one of
120: * the MIME types this producer can create images in.
121: */
122: GetMapProducer createMapProducer(String mapFormat, WMS wms)
123: throws IllegalArgumentException;
124: }
|