Class ALcdOGCWMSCommandDispatcherFactory

java.lang.Object
com.luciad.wms.server.ALcdWMSCommandDispatcherFactory
com.luciad.wms.server.ALcdOGCWMSCommandDispatcherFactory
Direct Known Subclasses:
ALcdOGCSLDWMSCommandDispatcherFactory, TLcdOGCWMSCommandDispatcherFactory

public abstract class ALcdOGCWMSCommandDispatcherFactory extends ALcdWMSCommandDispatcherFactory
This factory class creates a command dispatcher following the OGC WMS specification.

Supported OGC WMS operations

The command dispatcher provides support for the OGC WMS operations:
  • GetCapabilities: provides information on what WMS method the servers supports as well as the data that is available.
  • GetMap: returns a rendered image upon request.
  • GetFeatureInfo: returns more details on underlying data for a specified location.
As of 2017 the created command dispatcher also provides automatically support for the GetMap SLD extension such that a request can be executed using StyledLayerDescriptors. The default allows to perform basic SLD requests. This can be extended as outlined below. Before an extension of this factory class was needed.

The following StyledLayerDescriptor operations can be supported.

  • GetMap with extended SLD support: extensions allow to perform custom styling as requested by the client application and/or styling data from a remote WFS or WCS service.
  • DescribeLayer: returns a description of the data within a WMS layer. This is typically needed when you want to perform custom styling defined from within the client application.
  • GetLegend: ability to return a legend for the styling that is applied on WMS layers.

Factory methods to implement

This class provides sensible default settings for data formats supported within the Luciad product suite.

Required implementations are picked up through the TLcdServiceLoader for the following interfaces:

You can replace them by making your own implementation and annotating it with a higher priority than the default ones (see LcdService).
The fact that available implementations for image formats and feature info formats are picked up automatically does not mean they become advertised in the capabilities automatically. The WMS capabilities object created using the ILcdWMSCapabilitiesProvider determines the formats that are advertised to client applications. On creation of the ILcdWMSCapabilitiesProvider the provided TLcdWMSCommandDispatcherContext allows to retrieve the available implementations which then can either all be included or you can opt to filter on the actual supported formats advertised.

The method

  • createWMSCapabilitiesProvider(jakarta.servlet.ServletConfig, com.luciad.wms.server.ILcdModelProvider, com.luciad.wms.server.TLcdWMSCommandDispatcherContext, com.luciad.wms.server.TLcdOGCWMSCommandDispatcher)
have to be implemented!

Note there is also a default factory implementation TLcdOGCWMSCommandDispatcherFactory from which you can start or extend from. It can help you to lower your implementation efforts .

Implement the ILcdWMSCapabilitiesProvider to return the capabilities upon client requests. The capabilities provider allows returning up-to-date versions of the capabilities without need for implementation of other supporting classes. It also allows for more fine grained control on which layers should be available for which user.

Extended Styled Layer Descriptor support.

As of 2017.0 this factory allows creating a command dispatcher factory immediately supporting the Styled Layer Descriptors (SLD). There is no need anymore to extend from the class ALcdOGCSLDWMSCommandDispatcherFactory. The latter class is deprecated. Provide implementations for the following methods to add SLD support:

Performance for client applications using tiled requests

This factory uses a tile cache to improve the performance of subsequent Tiled WMS requests. This tile cache is not used for (regular) WMS requests. It is a two-tier cache that uses an in-memory buffer with a (non-persistent) disk overflow. The cache is configured as part of the servlet context, which means that it can be reused across multiple servlet instances when in the same process. It can be configured by using the following servlet context parameters (context-param in web.xml).

  • memory-cache-size: The memory tile cache size in MB. Default is 10% of the max heap size. Can be 0.
  • disk-cache-size: The disk tile cache size in MB. Default is "memory-cache-size x 100". Can be 0.
  • disk-cache-path: The disk tile cache path. Also supports paths starting with "${java.io.tmpdir}" or "${user.home}". Default is "${java.io.tmpdir}/ogc"

The tile cache can be disabled by setting both the memory-cache-size and disk-cache-size parameters to 0. By default, the tile cache is enabled.

See Also:
  • Constructor Details

    • ALcdOGCWMSCommandDispatcherFactory

      public ALcdOGCWMSCommandDispatcherFactory()
  • Method Details

    • createWMSCommandDispatcher

      public ALcdWMSCommandDispatcher createWMSCommandDispatcher(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Description copied from class: ALcdWMSCommandDispatcherFactory
      Creates from the servlet configuration file the ALcdWMSCommandDispatcher.
      Specified by:
      createWMSCommandDispatcher in class ALcdWMSCommandDispatcherFactory
      Parameters:
      aServletConfig - the servlet configuration values.
      Returns:
      a ALcdWMSCommandDispatcher from the servlet configuration.
      Throws:
      jakarta.servlet.ServletException - if the ALcdWMSCommandDispatcher can not be created.
    • createAdditionalParameterListForViewPoolCacheKey

      protected List<String> createAdditionalParameterListForViewPoolCacheKey()
      Allows to provide a list of additional parameter names which must be taken into account when checking the validity of a view for reuse from the view pool. The view pool caches views which have been configured for requests based on the layers, styles, crs, etc. This prevents having to always re-create views and their layers which may be expensive. The default method implementation returns an empty list. If you are using additional request parameters beyond the standardized WMS parameters and if they have an impact on the visualization you need to return them in this method.
      Returns:
      the list of parameter names to be taken into account for the view pool caching.
      Since:
      2020.1.25
    • createAdditionalAttributeListForViewPoolCacheKey

      protected List<String> createAdditionalAttributeListForViewPoolCacheKey()
      Allows to provide a list of additional attribute names which must be taken into account when checking the validity of a view for reuse from the view pool. The view pool caches views which have been configured for requests based on the layers, styles, crs, etc. This prevents having to always re-create views and their layers which may be expensive. The default method implementation returns an empty list. If you are using request attributes that have an impact on the visualization, you need to return them in this method.
      Returns:
      the list of attributes names to be taken into account for the view pool caching.
      Since:
      2023.1
    • createReferenceParsersSFCT

      protected void createReferenceParsersSFCT(jakarta.servlet.ServletConfig aServletConfig, List<ILcdXYWorldReferenceParser> aWorldReferenceParserListSFCT, List<String> aCRSCodeListToPublishSFCT) throws jakarta.servlet.ServletException
      Creates reference parsers. The reference parsers to be registered within the WMS command dispatcher should be added to the list as side effect of the method. Next to this the supported CRS codes should be added as well.

      This method registers by default the following parser implementations:

      The list of CRS codes is populated as follows. If nothing is specified within the web deployment descriptor via the ServletConfig a default list of CRS codes is used. The default list consists of codes that are widely used. If the following parameters are defined within the web deployment descriptor the CRS codes are read from file(s). You can use the following parameters which must point to a file that can be found on the class path.

      • crs.epsg.cfg: A file containing conversions of EPSG codes to Well-Known Text.
      • crs.auto.cfg: A list of supported AUTO projections.
      • crs.auto2.cfg: A list of supported AUTO2 projections.
      Parameters:
      aServletConfig - the servlet configuration parameters.
      aWorldReferenceParserListSFCT - the list of reference parsers to be populated.
      aCRSCodeListToPublishSFCT - the CRS codes that should be published in the WMS capabilities; to be populated.
      Throws:
      jakarta.servlet.ServletException
      Since:
      2017.0
    • createWMSCapabilitiesDecoder

      protected ILcdWMSCapabilitiesDecoder createWMSCapabilitiesDecoder(jakarta.servlet.ServletConfig aServletConfig, ILcdModelProvider aModelProvider)
      Creates a ILcdWMSCapabilitiesDecoder. The default implementation returns a TLcdWMSCapabilitiesXMLDecoder.

      Note: It is highly recommended to make use of a ILcdWMSCapabilitiesProvider iso the ILcdWMSCapabilitiesDecoder. The ILcdWMSCapabilitiesProvider allows to provide updated capabilities much easier. You do not need a ILcdWMSCapabilitiesUpdater anymore to update the capabilities. Within the implementation of the ILcdWMSCapabilitiesProvider you can still make use of a decoder that reads the configuration from file or another source.

      Parameters:
      aServletConfig - the servlet configuration object containing initialization parameters.
      aModelProvider - the model provider. Can be used to obtain bounds for published layers at runtime.
      Returns:
      a decoder for the WMS capabilities configuration file.
      See Also:
    • createWMSCapabilitiesProvider

      protected ILcdWMSCapabilitiesProvider createWMSCapabilitiesProvider(jakarta.servlet.ServletConfig aServletConfig, ILcdModelProvider aModelProvider, TLcdWMSCommandDispatcherContext aEncoderContext) throws jakarta.servlet.ServletException
      Creates a WMS capabilities provider. This is the main method to implement to control the data that is being served by the WMS.

      The default implementation returns null.

      As fall-back, and for backwards compatibility reasons, the command dispatcher factory will still create a ILcdWMSCapabilitiesProvider but based on the ILcdWMSCapabilitiesDecoder.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      aModelProvider - the model provider. Can be used to obtain bounds for published layers at runtime.
      aEncoderContext - context object containing the registered encoders for various WMS requests.
      Returns:
      the WMS capabilities provider.
      Throws:
      jakarta.servlet.ServletException - when the WMS capabilities provider cannot be created.
      Since:
      2017.0
    • createOGCWMSCommandDispatcherInstance

      protected TLcdOGCWMSCommandDispatcher createOGCWMSCommandDispatcherInstance(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Creates a new instance (or an extension) of TLcdOGCWMSCommandDispatcher to be initialized.

      This implementation includes internal data models for specific SLD extensions.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      a new instance (or an extension) of TLcdOGCWMSCommandDispatcher to be initialized.
      Throws:
      jakarta.servlet.ServletException - if the instance can not be created for some reason.
    • createSLDWMSGXYLayerFactories

      protected ALcdSLDWMSGXYLayerFactory[] createSLDWMSGXYLayerFactories(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Deprecated.
      Since 2017.0 Please override createWMSGXYLayerFactories(ServletConfig).

      Creates ALcdSLDWMSGXYLayerFactory objects to create ILcdGXYLayer objects for models corresponding with all types of WMS layers (named and user-defined).

      This method is deprecated. It is recommended to override createWMSGXYLayerFactories as it accepts both ILcdWMSGXYLayerFactory and ALcdSLDWMSGXYLayerFactory instances.

      By default, this method creates an empty array.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      factories to create ILcdGXYLayer objects.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createWMSGXYLayerFactories

      protected ILcdWMSGXYLayerFactory[] createWMSGXYLayerFactories(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException

      Creates ILcdWMSGXYLayerFactory objects to create ILcdGXYLayer objects for models corresponding with all types of WMS layers (named and user-defined). You can include also ALcdSLDWMSGXYLayerFactory instances. They are recognized in the TLcdOGCWMSCommandDispatcher.

      By default, this method:

      • Uses TLcdServiceLoader to find all registered ILcdWMSGXYLayerFactory instances. You can use the LcdService annotation to register additional WMS layer factories. If you do not want to use the TLcdServiceLoader mechanism, you can override this method as well and return your own list of WMS layer factories.
      • Creates a new ILcdWMSGXYLayerFactory instance that is configured with the objects returned by the following methods:
        • createSLDGXYLayerFactories: Used to create a GXY layer, given an SLD style. This can for example be useful to plugin in layer factories using format-specific SLD extensions.
        • createFallbackGXYLayerFactories: Used to create a GXY layer without using the named style that is provided. This can be used to make sure there is always at least one layer factory available for painting, or to plug in format-specific layer factories that define their own styling.

      Note on backward compatibility. This implementation first checks if the call to the method createSLDWMSGXYLayerFactories() return a non-empty array of layer factories. If it does, those are returned immediately to keep behavior as before using v2017.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      factories to create ILcdGXYLayer objects.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createSLDGXYLayerFactories

      protected ILcdSLDGXYLayerFactory[] createSLDGXYLayerFactories(jakarta.servlet.ServletConfig aServletConfig)

      Creates ILcdSLDGXYLayerFactory objects that can be used to create a GXY layer, given an SLD style. This can for example be useful to plugin in layer factories using format-specific SLD extensions.

      This method is used in the default implementation of createSLDWMSGXYLayerFactories(ServletConfig).

      By default, this method uses TLcdServiceLoader to find all registered ILcdSLDGXYLayerFactory instances. You can use the LcdService annotation to register additional layer factories. If you do not want to use the TLcdServiceLoader mechanism, you can override this method as well and return your own list of SLD layer factories.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      ILcdSLDGXYLayerFactory objects. the returned array can be empty, but never null.
      Since:
      2017.0
    • createFallbackGXYLayerFactories

      protected ILcdGXYLayerFactory[] createFallbackGXYLayerFactories(jakarta.servlet.ServletConfig aServletConfig)

      Creates ILcdGXYLayerFactory objects that can be used to create a GXY layer without a specified style. This can be used to make sure there is always at least one layer factory available for painting, or to plug in format-specific layer factories that define their own styling.

      This method is used in the default implementation of createSLDWMSGXYLayerFactories(ServletConfig).

      By default, this method uses TLcdServiceLoader to find all registered ILcdGXYLayerFactory instances. You can use the LcdService annotation to register additional layer factories. If you do not want to use the TLcdServiceLoader mechanism, you can override this method as well and return your own list of layer factories.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      ILcdGXYLayerFactory objects. the returned array can be empty, buy never null.
      Since:
      2017.0
    • configureSettings

      protected void configureSettings(jakarta.servlet.ServletConfig aServletConfig)
      This method applies a few configuration settings. These settings are retrieved from a given settings file specified with the servlet initialization parameter settings.cfg or if not specified from a file with the same name.

      The default parameters that can be specified

      • JAI.tile.cache.size.mb: specifies the size of the cache JAI (Java Advanced Imaging) in MB.

      Overwrite this method for custom behavior.

      Parameters:
      aServletConfig - the servlet configuration parameters.
    • createModelDecoderFactories

      protected ILcdModelDecoderFactory[] createModelDecoderFactories(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException

      Creates ILcdModelDecoderFactory objects to create ILcdModelDecoder objects for models corresponding to an ALcdWMSLayer.

      By default, this method returns an array of size 1 that contains a TLcdModelDecoderFactory instance. This implementation uses TLcdServiceLoader to find ILcdModelDecoder instances.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      factories to create ILcdModelDecoder objects.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createWMSFeatureInfoEncoders

      protected ILcdWMSFeatureInfoRequestEncoder[] createWMSFeatureInfoEncoders(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Overwrite this method to create ILcdWMSFeatureInfoRequestEncoder objects to be used for sending information on a WMS feature info request.

      By default this method returns no feature info encoders.

      Note that there is a similar interface to ILcdWMSFeatureInfoRequestEncoder, namely ILcdWMSGetFeatureInfoRequestEncoder, which is used for the same purpose but offers access to extra information related to the current request. The factory method createWMSGetFeatureInfoEncoders(ServletConfig) can be used to register implementations of this method. Registered objects of the type ILcdWMSGetFeatureInfoRequestEncoder will have precedence above the objects of the type ILcdWMSFeatureInfoRequestEncoder, if they have the same MIME type.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      feature info request encoders.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createWMSGetFeatureInfoEncoders

      protected ILcdWMSGetFeatureInfoRequestEncoder[] createWMSGetFeatureInfoEncoders(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Overwrite this method to create ILcdWMSGetFeatureInfoRequestEncoder objects to be used for sending information on a WMS feature info request.

      By default, this method uses TLcdServiceLoader to find all registered ILcdWMSGetFeatureInfoRequestEncoder instances. You can use the LcdService annotation to register feature info request encoders. If you do not want to use the TLcdServiceLoader mechanism, you can override this method as well and return your own list of feature info request encoders.

      Note that there is a similar interface to ILcdWMSGetFeatureInfoRequestEncoder, namely ILcdWMSFeatureInfoRequestEncoder, which is used for the same purpose but doesn't provide access to information related to the current request. This information can be useful while encoding GetFeatureInfo responses. Registered objects of the type ILcdWMSGetFeatureInfoRequestEncoder will have precedence above the objects of the type ILcdWMSFeatureInfoRequestEncoder, if they have the same MIME type.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      feature info request encoders.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createGXYViewEncoders

      protected ILcdGXYViewEncoder[] createGXYViewEncoders(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Creates ILcdGXYViewEncoder objects to be used for sending information on a WMS map request.

      This implementation uses TLcdServiceLoader to find ILcdGXYViewEncoder instances.

      As a minimum this implementation returns ILcdGXYViewEncoder instances for encoding a view as PNG and as JPEG.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      feature info request encoders.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createWMSCapabilitiesUpdater

      protected ILcdWMSCapabilitiesUpdater createWMSCapabilitiesUpdater(jakarta.servlet.ServletConfig aServletConfig, TLcdOGCWMSCommandDispatcher aCommandDispatcher, ILcdWMSCapabilitiesDecoder aDecoder)
      Deprecated.
      Starting from version 2017.0, the preferred way of working is to use the ILcdWMSCapabilitiesProvider.
      Creates a ILcdWMSCapabilitiesUpdater, which can be used to update the capabilities in the command dispatcher.

      By default this method returns null, indicating that there is no capabilities updater active.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      aCommandDispatcher - the command dispatcher.
      aDecoder - the capabilities decoder.
      Returns:
      a capabilities updater.
    • createModelProvider

      protected ILcdModelProvider createModelProvider(ILcdModelDecoderFactory[] aModelDecoderFactories)

      Creates a ILcdModelProvider, which provides central access to all models. The command dispatcher uses this interface to retrieve a model, instead of directly using the model decoder factories. These model decoder factories should only be used by the ILcdModelProvider to decode the necessary models. This centralized access allows implementations to define additional functionality, like a cache mechanism.

      The default implementation returns a ILcdModelProvider that maintains The default implementation returns a ILcdModelProvider that maintains a cache for all decoded models. To prevent memory problems, it makes use of Soft reference objects, which are cleared at the discretion of the garbage collector in response to memory demand. Soft references are most often used to implement memory-sensitive caches.

      The request context object type supplied to the ILcdOGCModelProvider#getModel(String, ILcdRequestContext) is of the type TLcdWFSRequestContext.

      By default, this method returns an TLcdWMSModelProvider instance

      Parameters:
      aModelDecoderFactories - The model decoder factories that must be used by the model provider to decode models.
      Returns:
      a model provider.
    • createWMSOnlineResourceResolver

      protected ILcdWMSOnlineResourceResolver createWMSOnlineResourceResolver(jakarta.servlet.ServletConfig aServletConfig)
      Creates an ILcdWMSOnlineResourceResolver that is used to retrieve the paths (typically URLs) to online resources defined by the WMS specification. Examples are DTD or XML Schema references in a capabilities document or in a service exception report, or online resource elements in the Capabilities (e.g. MetadataURL).

      The default implementation returns an ILcdWMSOnlineResourceResolver that returns:

      • A local path for DTD/XML Schema references.
      • For online resource elements defined in the capabilities, the path defined in ALcdWMSCapabilities, but resolved against the current servlet address if it is not absolute.
      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      a ILcdWMSOnlineResourceResolver that is used to retrieve the paths to online resources defined by the WMS specification.
    • createWMSGXYViewFactory

      protected TLcdWMSGXYViewFactory createWMSGXYViewFactory(jakarta.servlet.ServletConfig aServletConfig)
      Creates an TLcdWMSGXYViewFactory that is used to create and configure views in the WMS to render requested maps.
      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      an TLcdWMSGXYViewFactory that is used to create and configure views in the WMS to render requested maps.
    • createRemoteOWSModelDecoderFactories

      protected ILcdRemoteOWSModelDecoderFactory[] createRemoteOWSModelDecoderFactories(jakarta.servlet.ServletConfig aServletConfig)
      Creates ILcdRemoteOWSModelDecoderFactory objects to create ILcdRemoteOWSModelDecoder objects for models corresponding to a user-defined layer.

      By default this method returns no decoders.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      factories to create ILcdRemoteOWSModelDecoder objects.
      See Also:
    • createSLDFeatureTypeStyleProvider

      protected ILcdWMSSLDFeatureTypeStyleProvider createSLDFeatureTypeStyleProvider(jakarta.servlet.ServletConfig aServletConfig)
      Creates an ILcdWMSSLDFeatureTypeStyleProvider that can provide a feature type style for a WMS layer.

      This provider is used to determine the desired SLD feature type style for a WMS layer if the request did not include one. By default, null is returned, indicating that the styling of the WMS layers is left to the registered layer factories for requests without an SLD feature type style.

      Since:
      2022.0
      See Also:
    • createWMSGetLegendGraphicEncoders

      protected ILcdWMSGetLegendGraphicRequestEncoder[] createWMSGetLegendGraphicEncoders(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Overwrite this method to create ILcdWMSGetLegendGraphicRequestEncoder objects to be used for sending information on a WMS legend graphic request.

      By default this method returns no legend graphic encoders.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      legend graphic request encoders.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also:
    • createWMSDescribeLayerEncoders

      protected ILcdWMSDescribeLayerRequestEncoder[] createWMSDescribeLayerEncoders(jakarta.servlet.ServletConfig aServletConfig) throws jakarta.servlet.ServletException
      Overwrite this method to create ILcdWMSDescribeLayerRequestEncoder objects to be used for sending information on a WMS describe layer request.

      By default this method returns no describe layer encoders.

      Parameters:
      aServletConfig - the servlet configuration parameters.
      Returns:
      describe layer request encoders.
      Throws:
      jakarta.servlet.ServletException - if the factories can not be created for some reason.
      See Also: