Class TLcdWMSModelProvider
- All Implemented Interfaces:
ILcdOGCModelProvider
,ILcdDisposable
,ILcdModelProvider
,AutoCloseable
Default model provider implementation that delegates to the given ILcdModelDecoderFactory
.
This implementation
- supports multi-dimensions
- adds a model cache
The getModelUpdateSequence
method implementation is based on the use of
System.currentTimeMillis()
. When a model gets decoded, it is assigned an update sequence, based on the
current time. When invalidate(String)
or invalidateAll()
is called, it will trigger the model
to be re-decoded, and the model update sequence will be updated. When the model changes in-memory (detected
using a model listener), the update sequence will be updated as well.
- Since:
- 2017.0
-
Constructor Summary
ConstructorDescriptionTLcdWMSModelProvider
(ILcdOGCModelDecoderFactory aModelDecoderFactory) Creates a model provider using the givenILcdOGCModelDecoderFactory
.TLcdWMSModelProvider
(ILcdOGCModelDecoderFactory[] aModelDecoderFactories) Creates a new model provider based on the givenILcdOGCModelDecoderFactory
array. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Disposes of this object and allows it to release any system resources that it is holding.getModel
(String aSourceName, ALcdRequestContext aRequestContext) Returns theILcdModel
corresponding to a source name.getModelUpdateSequence
(String aSourceName, ALcdRequestContext aRequestContext) Returns the update sequence value associated with the mode identified by the given source name.void
invalidate
(String aSourceName) Clears the model cache for the given source.void
Clears the entire model cache.Methods inherited from class com.luciad.wms.server.ALcdMultiDimensionalModelProvider
getDimensionExtent, getModel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
-
Constructor Details
-
TLcdWMSModelProvider
Creates a model provider using the givenILcdOGCModelDecoderFactory
.- Parameters:
aModelDecoderFactory
- a model decoder factory.
-
TLcdWMSModelProvider
Creates a new model provider based on the givenILcdOGCModelDecoderFactory
array.- Parameters:
aModelDecoderFactories
- a list model decoder factories.
-
-
Method Details
-
getModel
public ILcdModel getModel(String aSourceName, ALcdRequestContext aRequestContext) throws IOException Description copied from class:ALcdMultiDimensionalModelProvider
Returns theILcdModel
corresponding to a source name. This method is used for allALcdWMSLayer
objects that don't have any dimensions defined. By default, anILcdModelProvider
implementation is used 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.- Specified by:
getModel
in interfaceILcdModelProvider
- Specified by:
getModel
in interfaceILcdOGCModelProvider
- Overrides:
getModel
in classALcdMultiDimensionalModelProvider
- Parameters:
aSourceName
- the source name of the model.aRequestContext
- the request context, which is an instance of typeTLcdWMSRequestContext
. This can be null if the method is called by a process which is not handling a request.- Returns:
- the
ILcdModel
corresponding to a source name. - Throws:
IOException
- if the model can not be returned (because decoding fails).
-
getModelUpdateSequence
public String getModelUpdateSequence(String aSourceName, ALcdRequestContext aRequestContext) throws IOException Description copied from interface:ILcdModelProvider
Returns the update sequence value associated with the mode identified by the given source name. The update sequence identifies the state of the model.
The update sequence should comply with a number of conditions:
- The sequence number should be different from all previous update sequences for this model (if the model has changed).
- If the model is different, the sequence number should be different as well. Failing to do so will cause malfunctions in combination with caching.
- If the model doesn't change, the sequence number should also remain the same. Failing to do so lowers the effect of caching, and will result in worse performance.
- The sequence number should be unique across sessions. Failing to do so may cause malfunctions in combination with caching. An easy mistake to make would for example be to use a counter that is reset when the server is restarted.
By default, this method always returns
"0"
. This means that the default implementation assumes that models never change. If models change, this method should be implemented differently.One way to generate update sequences would be to use a (persistent) counter that gets incremented on every (file system) change. Another way would be to use
System.currentTimeMillis()
from a correct clock.This method must be used by model provider implementations that contain a model cache. The result of this method must be used to invalidate this cache if needed.
Because of caching on the request/view level, it is possible that the
getModel
method is called infrequently. This method will need to be called at least once for each request though. This means that for performance reasons, this method needs to have a fast implementation, ideally avoiding any I/O.The
ALcdWMSLayer
class has an update sequence concept as well. SeeALcdWMSLayer.getUpdateSequence()
for more information.- Parameters:
aSourceName
- the source name of the model.aRequestContext
- the request context, which is an instance of typeTLcdWMSRequestContext
. This can be null if the method is called by a process which is not handling a request.- Returns:
- the update sequence value associated with the mode identified by the given source name.
- Throws:
IOException
- if the update sequence can not be determined
-
invalidate
Clears the model cache for the given source. Note that this will causegetModelUpdateSequence
to return a different value for new calls for the given source name.- Parameters:
aSourceName
- the source name.
-
invalidateAll
public void invalidateAll()Clears the entire model cache. Note that this will causegetModelUpdateSequence
to return a different value for new calls for all models. -
dispose
public void dispose()Description copied from interface:ILcdDisposable
Disposes of this object and allows it to release any system resources that it is holding.
The result of calling any other method (other than
finalize
) on this object subsequent to a call to this method is undefined.- Specified by:
dispose
in interfaceILcdDisposable
- Specified by:
dispose
in interfaceILcdOGCModelProvider
- Overrides:
dispose
in classALcdMultiDimensionalModelProvider
-