Class DefaultExecutionContext
- java.lang.Object
-
- org.smooks.engine.DefaultExecutionContext
-
- All Implemented Interfaces:
ExecutionContext
,TypedMap
public class DefaultExecutionContext extends Object implements ExecutionContext
Standalone Container Request implementation.- Author:
- tfennelly
-
-
Field Summary
-
Fields inherited from interface org.smooks.api.ExecutionContext
DOCUMENT_URI
-
-
Constructor Summary
Constructors Constructor Description DefaultExecutionContext(String targetProfile, ApplicationContext applicationContext, String contentEncoding, List<ContentHandlerBinding<Visitor>> extendedContentHandlerBindings)
Public Constructor.DefaultExecutionContext(String targetProfile, ApplicationContext applicationContext, List<ContentHandlerBinding<Visitor>> extendedContentHandlerBindings)
Public Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
get(TypedKey<T> key)
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.Map<TypedKey<Object>,Object>
getAll()
Returns all the key-value pairs as aMap
.ApplicationContext
getApplicationContext()
Gets theApplicationContext
of thisExecutionContext
.BeanContext
getBeanContext()
Gets theBeanContext
for thisExecutionContext
.String
getConfigParameter(String name)
Get a global configuration parameter associated with this execution context.String
getConfigParameter(String name, String defaultVal)
Get a global configuration parameter associated with this execution context.ContentDeliveryRuntime
getContentDeliveryRuntime()
Get the content delivery configuration for the profile set at which this context is targeted.String
getContentEncoding()
Get the content encoding to be used when parsing content on this standalone request instance.URI
getDocumentSource()
Gets the document source URI of thisExecutionContext
.MementoCaretaker
getMementoCaretaker()
<T> T
getOrDefault(TypedKey<T> key, T value)
Returns the value to which the specified key is mapped, ordefaultValue
if this map contains no mapping for the key.ProfileSet
getTargetProfiles()
Gets the set of profiles at which this execution context is targeted.Throwable
getTerminationError()
Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.<T> void
put(TypedKey<T> key, T value)
Associates the specified value with the specified key in this map.<T> void
remove(TypedKey<T> key)
Removes the mapping for a key from this map if it is present (optional operation).void
setBeanContext(BeanContext beanContext)
Sets theBeanContext
for thisExecutionContext
.void
setContentEncoding(String contentEncoding)
Set the content encoding to be used when parsing content on this standalone request instance.void
setDocumentSource(URI docSource)
Sets the document source URI of thisExecutionContext
.void
setTerminationError(Throwable terminationError)
Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.String
toString()
-
-
-
Constructor Detail
-
DefaultExecutionContext
public DefaultExecutionContext(String targetProfile, ApplicationContext applicationContext, List<ContentHandlerBinding<Visitor>> extendedContentHandlerBindings) throws UnknownProfileMemberException
Public Constructor. The execution context is constructed within the context of a target profile and application context.- Parameters:
targetProfile
- The target base profile for the execution context. These parameters are not appended to the supplied requestURI. This arg must be supplied, even if it's empty.applicationContext
- The application context.extendedContentHandlerBindings
- Preconfigured/extended Visitor Configuration Map.- Throws:
UnknownProfileMemberException
- Unknown target profile.
-
DefaultExecutionContext
public DefaultExecutionContext(String targetProfile, ApplicationContext applicationContext, String contentEncoding, List<ContentHandlerBinding<Visitor>> extendedContentHandlerBindings) throws UnknownProfileMemberException
Public Constructor. The execution context is constructed within the context of a target profile and application context.- Parameters:
targetProfile
- The target profile (base profile) for this context. These parameters are not appended to the supplied requestURI. This arg must be supplied, even if it's empty.applicationContext
- The application context.contentEncoding
- Character encoding to be used when parsing content. Null defaults to "UTF-8".extendedContentHandlerBindings
- Preconfigured/extended Visitor Configuration Map.- Throws:
UnknownProfileMemberException
- Unknown target profile.
-
-
Method Detail
-
setDocumentSource
public void setDocumentSource(URI docSource)
Description copied from interface:ExecutionContext
Sets the document source URI of thisExecutionContext
.- Specified by:
setDocumentSource
in interfaceExecutionContext
- Parameters:
docSource
- the document URI
-
getDocumentSource
public URI getDocumentSource()
Description copied from interface:ExecutionContext
Gets the document source URI of thisExecutionContext
. If the document source URI is not set for the context, implementations should return theExecutionContext.DOCUMENT_URI
constant.- Specified by:
getDocumentSource
in interfaceExecutionContext
- Returns:
- the document URI.
-
getApplicationContext
public ApplicationContext getApplicationContext()
Description copied from interface:ExecutionContext
Gets theApplicationContext
of thisExecutionContext
.- Specified by:
getApplicationContext
in interfaceExecutionContext
- Returns:
- the
ApplicationContext
instance.
-
getTargetProfiles
public ProfileSet getTargetProfiles()
Description copied from interface:ExecutionContext
Gets the set of profiles at which this execution context is targeted. Basically, the set of profiles for which this execution context is to perform transformation/analysis.- Specified by:
getTargetProfiles
in interfaceExecutionContext
- Returns:
- the target
ProfileSet
.
-
getContentDeliveryRuntime
public ContentDeliveryRuntime getContentDeliveryRuntime()
Description copied from interface:ExecutionContext
Get the content delivery configuration for the profile set at which this context is targeted.- Specified by:
getContentDeliveryRuntime
in interfaceExecutionContext
- Returns:
- ContentDeliveryConfig instance.
-
setContentEncoding
public void setContentEncoding(String contentEncoding) throws IllegalArgumentException
Set the content encoding to be used when parsing content on this standalone request instance.- Specified by:
setContentEncoding
in interfaceExecutionContext
- Parameters:
contentEncoding
- Character encoding to be used when parsing content. Null defaults to "UTF-8".- Throws:
IllegalArgumentException
- Invalid encoding.
-
getContentEncoding
public String getContentEncoding()
Get the content encoding to be used when parsing content on this standalone request instance.- Specified by:
getContentEncoding
in interfaceExecutionContext
- Returns:
- Character encoding to be used when parsing content. Defaults to "UTF-8".
-
setTerminationError
public void setTerminationError(Throwable terminationError)
Description copied from interface:ExecutionContext
Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.- Specified by:
setTerminationError
in interfaceExecutionContext
- Parameters:
terminationError
- The termination Error/Exception.
-
getTerminationError
public Throwable getTerminationError()
Description copied from interface:ExecutionContext
Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.- Specified by:
getTerminationError
in interfaceExecutionContext
- Returns:
- The Error/Exception that caused the associated filter operation to terminate (if it did terminate), otherwise null.
-
getConfigParameter
public String getConfigParameter(String name)
Description copied from interface:ExecutionContext
Get a global configuration parameter associated with this execution context. For more fine grained control, see theParameterAccessor
class.- Specified by:
getConfigParameter
in interfaceExecutionContext
- Parameters:
name
- The name of the parameter.- Returns:
- The parameter value, or null if the parameter is not configured.
-
getConfigParameter
public String getConfigParameter(String name, String defaultVal)
Description copied from interface:ExecutionContext
Get a global configuration parameter associated with this execution context. For more fine grained control, see theParameterAccessor
class.- Specified by:
getConfigParameter
in interfaceExecutionContext
- Parameters:
name
- The name of the parameter.defaultVal
- The default value to be returned if the configuration parameter is not set.- Returns:
- The parameter value, or "defaultVal" if the parameter is not configured.
-
put
public <T> void put(TypedKey<T> key, T value)
Description copied from interface:TypedMap
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.
-
get
public <T> T get(TypedKey<T> key)
Description copied from interface:TypedMap
Returns the value to which the specified key is mapped, ornull
if this map contains no mapping for the key.More formally, if this map contains a mapping from a key
k
to a valuev
such that(key==null ? k==null : key.equals(k))
, then this method returnsv
; otherwise it returnsnull
. (There can be at most one such mapping.)A return value of
null
does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull
.
-
getOrDefault
public <T> T getOrDefault(TypedKey<T> key, T value)
Description copied from interface:TypedMap
Returns the value to which the specified key is mapped, ordefaultValue
if this map contains no mapping for the key.- Specified by:
getOrDefault
in interfaceTypedMap
- Type Parameters:
T
- type of key and value- Parameters:
key
- key whose associated value is to be returnedvalue
- default mapping of the key- Returns:
- value to which the specified key is mapped, or
defaultValue
if this map contains no mapping for the key
-
remove
public <T> void remove(TypedKey<T> key)
Description copied from interface:TypedMap
Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that(key==null ? k==null : key.equals(k))
, that mapping is removed. (The map can contain at most one such mapping.)Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
-
getAll
public Map<TypedKey<Object>,Object> getAll()
Description copied from interface:TypedMap
Returns all the key-value pairs as aMap
.
-
getBeanContext
public BeanContext getBeanContext()
Description copied from interface:ExecutionContext
Gets theBeanContext
for thisExecutionContext
.- Specified by:
getBeanContext
in interfaceExecutionContext
- Returns:
- the
BeanContext
-
setBeanContext
public void setBeanContext(BeanContext beanContext)
Description copied from interface:ExecutionContext
Sets theBeanContext
for thisExecutionContext
.- Specified by:
setBeanContext
in interfaceExecutionContext
- Parameters:
beanContext
- theBeanContext
-
getMementoCaretaker
public MementoCaretaker getMementoCaretaker()
- Specified by:
getMementoCaretaker
in interfaceExecutionContext
- Returns:
- the
MementoCaretaker
for thisExecutionContext
-
-