Class ALcdOGCWFSCommandDispatcherFactory

java.lang.Object
com.luciad.ogc.wfs.ALcdOGCWFSCommandDispatcherFactory
All Implemented Interfaces:
ILcdOGCCommandDispatcherFactory

public abstract class ALcdOGCWFSCommandDispatcherFactory extends Object implements ILcdOGCCommandDispatcherFactory
This factory class creates a command dispatcher following the OGC WFS specification. A number of protected 'create' methods of this class can be overridden to customize the behaviour of the WFS server. This makes it possible to support additional\ input and output formats, extend the filtering capabilities, and to plug in custom transaction and lock handling.

A concrete implementation of this class is referenced from the web servlet configuration file, so it can be instantiated when the web server starts up. This will then cause the createCommandDispatcher method to be called, which will in turn call all protected factory methods of this class to construct the instances which are required by the request handlers.

The final server initialization step is to create a request handler for each WFS request using the createRequestHandler method. These handlers can then be registered on the TLcdWFSCommandDispatcher instance that is created by the createWFSCommandDispatcherInstance factory method.

  • Constructor Details

    • ALcdOGCWFSCommandDispatcherFactory

      public ALcdOGCWFSCommandDispatcherFactory()
  • Method Details

    • createCommandDispatcher

      public ALcdOGCCommandDispatcher createCommandDispatcher(ILcdInitializationConfig aConfig) throws TLcdOGCServiceException
      Called during servlet initialization to create a command dispatcher. This method also configures the dispatcher, by registering the necessary request handlers and setting up global objects such as a model decoder factory.
      Specified by:
      createCommandDispatcher in interface ILcdOGCCommandDispatcherFactory
      Parameters:
      aConfig - The servlet configuration parameters loaded from web.xml.
      Returns:
      An ALcdOGCCommandDispatcher
      Throws:
      TLcdOGCServiceException - when the creation process fails
      See Also:
    • createModelDecoderFactory

      protected ILcdOGCModelDecoderFactory createModelDecoderFactory()

      Creates an ILcdOGCModelDecoderFactory. The ILcdOGCModelDecoderFactory is used by the server to load data: it is responsible of creating an ILcdModelDecoder for a given source. This ILcdModelDecoder is then used to decode the data identified by that source.

      By default, this method returns a TLcdOGCModelDecoderFactory instance. This implementation uses TLcdServiceLoader to find ILcdModelDecoder instances.

      Returns:
      an ILcdOGCModelDecoderFactory to read data at the server
    • createClientModelEncoderFactory

      protected ILcdWFSClientModelEncoderFactory createClientModelEncoderFactory()
      Creates an ILcdWFSClientModelEncoderFactory. The ILcdWFSClientModelEncoderFactory is used by the server to create an ILcdModelEncoder for the output format requested by the client. The ILcdModelEncoder is then used to encode the features that were returned by the server.

      This factory is also used to generate encoders for the schemas that describe the data. These schemas can be requested using DescribeFeatureType requests.

      The ILcdWFSClientModelEncoderFactory also specifies the output formats that will be supported by the server, these output formats will be advertised in the capabilities document of the server.

      By default, the TLcdServiceLoader is used to find an ILcdWFSClientModelEncoderFactory instance. If multiple instances are found, the one annotated with the highest priority is used. If no instance is found or if null is returned, TLcdWFSClientModelEncoderFactory is used by default.

      Returns:
      an ILcdWFSClientModelEncoderFactory to send data to the client
    • createServerModelEncoderFactory

      protected ILcdWFSServerModelEncoderFactory createServerModelEncoderFactory()
      Creates an ILcdWFSServerModelEncoderFactory. The ILcdWFSServerModelEncoderFactory is used by the default transaction handler to store modified data at the server.

      A server model encoder factory is required if the default transaction handler is used; otherwise it depends on the implementation of the ALcdWFSTransactionHandler that is created by the ILcdWFSTransactionHandlerFactory.

      To enable transactions, the servlet configuration parameter 'wfs.enableTransactions' should be set to 'true'.

      Returns:
      an ILcdWFSServerModelEncoderFactory to store modified data at the server, returns null by default.
      See Also:
    • createModelProvider

      protected ILcdOGCModelProvider createModelProvider(ILcdOGCModelDecoderFactory aModelDecoderFactory)
      Creates an ILcdOGCModelProvider, which provides central access to all models. The server uses this interface to retrieve a model, instead of directly using the model decoder factory (see createModelDecoderFactory()). The model decoder factory should only be used by the ILcdOGCModelProvider to decode the necessary models. This centralized access allows implementations to define additional functionality, like a cache mechanism.

      The default implementation returns a TLcdOGCModelProvider 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.

      Parameters:
      aModelDecoderFactory - The model decoder factory that must be used by the model provider to read data
      Returns:
      a model provider.
    • createLockFactory

      protected ILcdWFSLockFactory createLockFactory(ILcdWFSFilteredModelFactory aFilteredModelFactory)
      Creates a lock factory which creates locks for locking support. To enable locking the servlet configuration parameter 'wfs.enableLocking' should be set to 'true'.

      The default implementation creates a factory which locks all features 'in memory'. This means that the data in the underlying data store can still be read or written by other processes at all times.

      Parameters:
      aFilteredModelFactory - The filtered model factory which can be used to retrieve features to be locked, this is the factory that is created by createFilteredModelFactory().
      Returns:
      A valid lock factory.
      Since:
      10.0
    • createTransactionHandlerFactory

      protected ILcdWFSTransactionHandlerFactory createTransactionHandlerFactory(ILcdOGCModelProvider aModelProvider, ILcdWFSLockFactory aLockFactory, ILcdWFSFilteredModelFactory aFilteredModelFactory, ILcdWFSServerModelEncoderFactory aServerModelEncoderFactory)
      Creates a transaction handler factory. This is only required in case the WFS server should support transactions.

      The default implementation of this method creates a transaction handler which applies the changes to an ILcdModel, and stores these changes on commit using an ILcdModelEncoder created by the ILcdWFSServerModelEncoderFactory.

      To enable transactions, the servlet configuration parameter 'wfs.enableTransactions' should be set to 'true'.

      Parameters:
      aModelProvider - the model provider created by createModelProvider(com.luciad.ogc.common.ILcdOGCModelDecoderFactory).
      aLockFactory - the lock factory created by createLockFactory(com.luciad.ogc.wfs.ILcdWFSFilteredModelFactory).
      aFilteredModelFactory - the filtered model factory created by createFilteredModelFactory(com.luciad.ogc.wfs.ILcdWFSCapabilitiesProvider, com.luciad.ogc.common.ILcdOGCModelProvider)
      aServerModelEncoderFactory - the server model encoder factory created by createServerModelEncoderFactory()
      Returns:
      a valid transaction handler factory, or null if transactional support is not required.
      Since:
      10.0 f
    • createWFSCommandDispatcherInstance

      protected TLcdWFSCommandDispatcher createWFSCommandDispatcherInstance()
      Called by createWFSCommandDispatcher() to create a command dispatcher.
      Returns:
      a TLcdWFSCommandDispatcher.
    • createWFSFeatureTypeListDecoder

      protected ILcdWFSFeatureTypeListDecoder createWFSFeatureTypeListDecoder(ILcdOGCModelProvider aModelProvider)
      Deprecated.
      Since 2017.0 Please make use of ILcdWFSCapabilitiesProvider.

      Called during servlet initialization to create an ILcdWFSFeatureTypeListDecoder. The feature type list decoder is responsible for creating the list of data offered by the WFS service.

      If access to the data is required to construct the feature type list (e.g., to add more info about the data to the corresponding ILcdWFSFeatureType), the supplied ILcdOGCModelProvider should be used. This instance provides central access to all models that need to be decoded.

      By default, this method will return null. Unless the createWFSCapabilitiesProvider method is implemented directly, this method needs to be implemented as well.

      Parameters:
      aModelProvider - The model provider used to read data
      Returns:
      an ILcdWFSFeatureTypeListDecoder
    • createWFSCapabilitiesProvider

      protected ILcdWFSCapabilitiesProvider createWFSCapabilitiesProvider(ILcdInitializationConfig aConfig, ILcdOGCModelProvider aModelProvider, ILcdModelReferenceFormatter aModelReferenceFormatter, ILcdModelReferenceParser aModelReferenceParser) throws TLcdOGCServiceException

      Creates a WFS capabilities provider.

      By default, this method creates an ILcdWFSCapabilitiesProvider instance based on the results of the following methods:

      This method offers advantages over these separate methods. It in particular eases the implementation of access control, and it allows to return feature types lazily. See ILcdWFSCapabilitiesProvider for more information.

      Parameters:
      aConfig - The servlet configuration parameters.
      aModelProvider - The model provider
      aModelReferenceFormatter - Formatter for model references.
      aModelReferenceParser - Parser for model references.
      Returns:
      a WFS capabilities provider, never null.
      Throws:
      TLcdOGCServiceException - when the capabilities provider can not be created.
      Since:
      2017.0
    • registerModelReferenceFormatters

      protected void registerModelReferenceFormatters()
      This is called during initialization to give users the opportunity to register a number of ILcdModelReferenceFormatters. These reference formatters are used to generate the SRS strings for each feature type, as listed in the WFS capabilities document. To register a new reference formatter, use the addModelReferenceFormatter(ILcdModelReferenceFormatter) method. The formatter that should be called first should be added last.
    • addModelReferenceFormatter

      protected final void addModelReferenceFormatter(ILcdModelReferenceFormatter aFormatter)
      Adds a reference formatter.
      Parameters:
      aFormatter - An ILcdModelReferenceFormatter
    • registerModelReferenceParsers

      protected void registerModelReferenceParsers()
      This is called during initialization to give users the opportunity to register a number of ILcdModelReferenceParsers. These reference parsers are used to parse incoming srs strings. To register a new reference parser, use the addModelReferenceParser(ILcdModelReferenceParser) method. The parser that should be called first should be added last.
      Since:
      10.0
    • addModelReferenceParser

      protected final void addModelReferenceParser(ILcdModelReferenceParser aParser)
      Adds a reference parser.
      Parameters:
      aParser - An ILcdModelReferenceParser
      Since:
      10.0
    • createFilteredModelFactory

      protected ILcdWFSFilteredModelFactory createFilteredModelFactory(ILcdWFSCapabilitiesProvider aCapabilitiesProvider, ILcdOGCModelProvider aModelProvider) throws TLcdOGCServiceException
      Creates an ILcdWFSFilteredModelFactory. This factory is responsible for supporting the use of filters in WFS requests.
      Parameters:
      aCapabilitiesProvider - The list of data offered by the WFS service
      aModelProvider - The model provider used to read data
      Returns:
      an ILcdWFSFilteredModelFactory
      Throws:
      TLcdOGCServiceException - if the creation of the object fails
    • createServiceMetaData

      protected ILcdWFSServiceMetaData createServiceMetaData()
      Deprecated.
      Since 2017.0 Please make use of ILcdWFSCapabilitiesProvider.
      Creates an ILcdWFSServiceMetaData, which provides values to be written to the Service section of the WFS capabilities. If this method returns null, default values will be written to the capabilities.
      Returns:
      an ILcdWFSServiceMetaData
    • createServiceProvider

      public TLcdOWSServiceProvider createServiceProvider()
      Deprecated.
      Since 2017.0 Please make use of ILcdWFSCapabilitiesProvider.
      Returns the general service info/metadata that will appear in the server's capabilities.
      Returns:
      the general service info/metadata that will appear in the server's capabilities.
      Since:
      10.0
    • createTransactionContentDataModels

      protected List<TLcdDataModel> createTransactionContentDataModels(ILcdInitializationConfig aConfig)

      Creates the data models to configure the transaction XML decoder used by the transaction request handler.

      The transaction XML decoder is already configured with the data models required to parse regular WFS transaction requests containing GML data. Through this method, additional data models can be supplied to make the decoder aware of specific formats (for example AIXM 5.1).

      The default implementation of this method picks up all suitable data models available in the Luciad API, including AIXM 5.1.

      Each data model needs to be equipped with annotations of type TLcdXMLSchemaMappingAnnotation that indicate how the XML data needs to be decoded. This is automatically the case for all XML format-based data models available in the Luciad API and for data models created via TLcdXMLDataModelBuilder.

      Parameters:
      aConfig - The servlet configuration parameters
      Returns:
      the data models to configure the transaction XML decoder
      Since:
      2017.0
    • getModelReferenceFormatter

      public ILcdModelReferenceFormatter getModelReferenceFormatter()
      Get the model reference formatter used by the server.
      Returns:
      the model reference formatter
      Since:
      2012.1
    • getModelReferenceParser

      public ILcdModelReferenceParser getModelReferenceParser()
      Get the model reference parser used by the server.
      Returns:
      the model reference parser
      Since:
      2012.1
    • createRequestHandler

      public ILcdRequestHandler createRequestHandler(String aRequest, TLcdWFSCommandDispatcherContext aCommandDispatcherContext) throws TLcdWFSServiceException
      Factory method to create a WFS request handler. This method is called for all requests defined by the WFS specification, and the returned handlers are registered with the WFS command dispatcher.
      Parameters:
      aRequest - the name of a WFS request, e.g. "GetCapabilities"
      aCommandDispatcherContext - global objects that may be used by the request handlers
      Returns:
      an ILcdRequestHandler that can respond to the specified request
      Throws:
      TLcdWFSServiceException - if no handler can be created
      See Also: