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> Tget(TypedKey<T> key)Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.Map<TypedKey<Object>,Object>getAll()Returns all the key-value pairs as aMap.ApplicationContextgetApplicationContext()Gets theApplicationContextof thisExecutionContext.BeanContextgetBeanContext()Gets theBeanContextfor thisExecutionContext.StringgetConfigParameter(String name)Get a global configuration parameter associated with this execution context.StringgetConfigParameter(String name, String defaultVal)Get a global configuration parameter associated with this execution context.ContentDeliveryRuntimegetContentDeliveryRuntime()Get the content delivery configuration for the profile set at which this context is targeted.StringgetContentEncoding()Get the content encoding to be used when parsing content on this standalone request instance.URIgetDocumentSource()Gets the document source URI of thisExecutionContext.MementoCaretakergetMementoCaretaker()<T> TgetOrDefault(TypedKey<T> key, T value)Returns the value to which the specified key is mapped, ordefaultValueif this map contains no mapping for the key.ProfileSetgetTargetProfiles()Gets the set of profiles at which this execution context is targeted.ThrowablegetTerminationError()Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.<T> voidput(TypedKey<T> key, T value)Associates the specified value with the specified key in this map.<T> voidremove(TypedKey<T> key)Removes the mapping for a key from this map if it is present (optional operation).voidsetBeanContext(BeanContext beanContext)Sets theBeanContextfor thisExecutionContext.voidsetContentEncoding(String contentEncoding)Set the content encoding to be used when parsing content on this standalone request instance.voidsetDocumentSource(URI docSource)Sets the document source URI of thisExecutionContext.voidsetTerminationError(Throwable terminationError)Set the error/exception that caused the filter operation associated with this ExecutionContext to terminate.StringtoString()
-
-
-
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:ExecutionContextSets the document source URI of thisExecutionContext.- Specified by:
setDocumentSourcein interfaceExecutionContext- Parameters:
docSource- the document URI
-
getDocumentSource
public URI getDocumentSource()
Description copied from interface:ExecutionContextGets the document source URI of thisExecutionContext. If the document source URI is not set for the context, implementations should return theExecutionContext.DOCUMENT_URIconstant.- Specified by:
getDocumentSourcein interfaceExecutionContext- Returns:
- the document URI.
-
getApplicationContext
public ApplicationContext getApplicationContext()
Description copied from interface:ExecutionContextGets theApplicationContextof thisExecutionContext.- Specified by:
getApplicationContextin interfaceExecutionContext- Returns:
- the
ApplicationContextinstance.
-
getTargetProfiles
public ProfileSet getTargetProfiles()
Description copied from interface:ExecutionContextGets 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:
getTargetProfilesin interfaceExecutionContext- Returns:
- the target
ProfileSet.
-
getContentDeliveryRuntime
public ContentDeliveryRuntime getContentDeliveryRuntime()
Description copied from interface:ExecutionContextGet the content delivery configuration for the profile set at which this context is targeted.- Specified by:
getContentDeliveryRuntimein 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:
setContentEncodingin 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:
getContentEncodingin interfaceExecutionContext- Returns:
- Character encoding to be used when parsing content. Defaults to "UTF-8".
-
setTerminationError
public void setTerminationError(Throwable terminationError)
Description copied from interface:ExecutionContextSet the error/exception that caused the filter operation associated with this ExecutionContext to terminate.- Specified by:
setTerminationErrorin interfaceExecutionContext- Parameters:
terminationError- The termination Error/Exception.
-
getTerminationError
public Throwable getTerminationError()
Description copied from interface:ExecutionContextSet the error/exception that caused the filter operation associated with this ExecutionContext to terminate.- Specified by:
getTerminationErrorin 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:ExecutionContextGet a global configuration parameter associated with this execution context. For more fine grained control, see theParameterAccessorclass.- Specified by:
getConfigParameterin 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:ExecutionContextGet a global configuration parameter associated with this execution context. For more fine grained control, see theParameterAccessorclass.- Specified by:
getConfigParameterin 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:TypedMapAssociates 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:TypedMapReturns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.More formally, if this map contains a mapping from a key
kto a valuevsuch 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
nulldoes 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:TypedMapReturns the value to which the specified key is mapped, ordefaultValueif this map contains no mapping for the key.- Specified by:
getOrDefaultin 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
defaultValueif this map contains no mapping for the key
-
remove
public <T> void remove(TypedKey<T> key)
Description copied from interface:TypedMapRemoves 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:TypedMapReturns all the key-value pairs as aMap.
-
getBeanContext
public BeanContext getBeanContext()
Description copied from interface:ExecutionContextGets theBeanContextfor thisExecutionContext.- Specified by:
getBeanContextin interfaceExecutionContext- Returns:
- the
BeanContext
-
setBeanContext
public void setBeanContext(BeanContext beanContext)
Description copied from interface:ExecutionContextSets theBeanContextfor thisExecutionContext.- Specified by:
setBeanContextin interfaceExecutionContext- Parameters:
beanContext- theBeanContext
-
getMementoCaretaker
public MementoCaretaker getMementoCaretaker()
- Specified by:
getMementoCaretakerin interfaceExecutionContext- Returns:
- the
MementoCaretakerfor thisExecutionContext
-
-