Package nl.nn.adapterframework.core
Class PipeLineSession
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,Object>
-
- nl.nn.adapterframework.core.PipeLineSession
-
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Cloneable
,Map<String,Object>
public class PipeLineSession extends HashMap<String,Object> implements AutoCloseable
Basic implementation ofPipeLineSession
.- Since:
- version 3.2.2
- Author:
- Johan Verrips IOS
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static String
API_PRINCIPAL_KEY
static String
CORRELATION_ID_KEY
static String
EXIT_CODE_CONTEXT_KEY
static String
EXIT_STATE_CONTEXT_KEY
static String
HTTP_REQUEST_KEY
static String
HTTP_RESPONSE_KEY
static String
MESSAGE_ID_KEY
static String
ORIGINAL_MESSAGE_KEY
static String
SECURITY_HANDLER_KEY
static String
SERVLET_CONTEXT_KEY
static String
STORAGE_ID_KEY
static String
SYSTEM_MANAGED_RESOURCE_PREFIX
static String
TS_RECEIVED_KEY
static String
TS_SENT_KEY
-
Constructor Summary
Constructors Constructor Description PipeLineSession()
PipeLineSession(int initialCapacity)
PipeLineSession(int initialCapacity, float loadFactor)
PipeLineSession(Map<String,Object> t)
Create new PipeLineSession from existing map or session.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
boolean
get(String key, boolean defaultValue)
Retrieves aboolean
value from the PipeLineSessiondouble
get(String key, double defaultValue)
Retrieves adouble
value from the PipeLineSessionint
get(String key, int defaultValue)
Retrieves anint
value from the PipeLineSessionlong
get(String key, long defaultValue)
Retrieves along
value from the PipeLineSessionString
get(String key, String defaultValue)
Retrieves aString
value from the PipeLineSessionBoolean
getBoolean(String key)
Retrieves aBoolean
value from the PipeLineSessionMap<AutoCloseable,String>
getCloseables()
String
getCorrelationId()
Integer
getInteger(String key)
Retrieves anInteger
value from the PipeLineSessionMessage
getMessage(String key)
Retrieves the value associated with the specified key and returns it as aMessage
object.String
getMessageId()
Principal
getPrincipal()
ISecurityHandler
getSecurityHandler()
String
getString(String key)
Get value of a PipeLineSession key as String.Instant
getTsReceived()
static Instant
getTsReceived(Map<String,Object> context)
Instant
getTsSent()
static Instant
getTsSent(Map<String,Object> context)
boolean
isScheduledForCloseOnExit(AutoCloseable message)
boolean
isUserInRole(String role)
void
mergeToParentSession(String keysToCopy, Map<String,Object> to)
Object
put(String key, Object value)
void
putAll(Map<? extends String,?> m)
void
scheduleCloseOnSessionExit(AutoCloseable resource, String requester)
void
setSecurityHandler(ISecurityHandler handler)
void
unscheduleCloseOnSessionExit(AutoCloseable message)
static void
updateListenerParameters(Map<String,Object> map, String messageId, String correlationId, Instant tsReceived, Instant tsSent)
Convenience method to set required parameters from listeners.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Field Detail
-
SYSTEM_MANAGED_RESOURCE_PREFIX
public static final String SYSTEM_MANAGED_RESOURCE_PREFIX
- See Also:
- Constant Field Values
-
ORIGINAL_MESSAGE_KEY
public static final String ORIGINAL_MESSAGE_KEY
- See Also:
- Constant Field Values
-
MESSAGE_ID_KEY
public static final String MESSAGE_ID_KEY
- See Also:
- Constant Field Values
-
CORRELATION_ID_KEY
public static final String CORRELATION_ID_KEY
- See Also:
- Constant Field Values
-
STORAGE_ID_KEY
public static final String STORAGE_ID_KEY
- See Also:
- Constant Field Values
-
TS_RECEIVED_KEY
public static final String TS_RECEIVED_KEY
- See Also:
- Constant Field Values
-
TS_SENT_KEY
public static final String TS_SENT_KEY
- See Also:
- Constant Field Values
-
SECURITY_HANDLER_KEY
public static final String SECURITY_HANDLER_KEY
- See Also:
- Constant Field Values
-
HTTP_REQUEST_KEY
public static final String HTTP_REQUEST_KEY
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_KEY
public static final String HTTP_RESPONSE_KEY
- See Also:
- Constant Field Values
-
SERVLET_CONTEXT_KEY
public static final String SERVLET_CONTEXT_KEY
- See Also:
- Constant Field Values
-
API_PRINCIPAL_KEY
public static final String API_PRINCIPAL_KEY
- See Also:
- Constant Field Values
-
EXIT_STATE_CONTEXT_KEY
public static final String EXIT_STATE_CONTEXT_KEY
- See Also:
- Constant Field Values
-
EXIT_CODE_CONTEXT_KEY
public static final String EXIT_CODE_CONTEXT_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
mergeToParentSession
public void mergeToParentSession(String keysToCopy, Map<String,Object> to)
Copy specified keys from thefrom
PipeLineSession
to the parentPipeLineSession
orMap
to
. Any keys present in both parent and child session will be unregistered from closing on the closing of the child session.The keys which will be copied are specified in parameter
keysToCopy
. Keys names are separated by , or ; symbols. If that parameter isnull
then all keys will be copied, if it is an empty string then no keys will be copied.- Parameters:
keysToCopy
- Keys to be copied, separated by {@value ,} or {@value ;}. Ifnull
then all keys will be copied. If an empty string then no keys will be copied.to
- ParentPipeLineSession
orMap
.
-
getMessageId
@Nullable public String getMessageId()
-
getCorrelationId
@Nullable public String getCorrelationId()
-
getMessage
@Nonnull public Message getMessage(String key)
Retrieves the value associated with the specified key and returns it as aMessage
object. If the key does not exist or the value is null, it returns a null message.NB: If the underlying value was a stream, reading the message will read the underlying stream. The value can be preserved in the message, but the underlying stream can not be preserved and reading the same session key again will effectively return an empty value.
- Parameters:
key
- The key for which to retrieve the value.- Returns:
- The value associated with the key encapsulated in a
Message
object. If the key does not exist or the value is null, a null message is returned.
-
getTsReceived
public Instant getTsReceived()
-
getTsSent
public Instant getTsSent()
-
updateListenerParameters
public static void updateListenerParameters(@Nonnull Map<String,Object> map, @Nullable String messageId, @Nullable String correlationId, @Nullable Instant tsReceived, @Nullable Instant tsSent)
Convenience method to set required parameters from listeners. Will not update messageId and correlationId when NULL. Will use current date-time for TS-Received if null.
-
setSecurityHandler
public void setSecurityHandler(ISecurityHandler handler)
-
getSecurityHandler
public ISecurityHandler getSecurityHandler() throws org.apache.commons.lang3.NotImplementedException
- Throws:
org.apache.commons.lang3.NotImplementedException
-
isUserInRole
public boolean isUserInRole(String role) throws org.apache.commons.lang3.NotImplementedException
- Throws:
org.apache.commons.lang3.NotImplementedException
-
getPrincipal
public Principal getPrincipal() throws org.apache.commons.lang3.NotImplementedException
- Throws:
org.apache.commons.lang3.NotImplementedException
-
getString
@Nullable public String getString(@Nonnull String key)
Get value of a PipeLineSession key as String.NB: If the value was a stream, the stream is read and closed. If the value was another kind of
AutoCloseable
, then a side effect of this method may also be the value was closed.- Parameters:
key
- Session key to get.- Returns:
- Value of the session key as String, or NULL of either the key was not present or had a NULL value.
-
get
@Nullable public String get(@Nonnull String key, @Nullable String defaultValue)
Retrieves aString
value from the PipeLineSession- Parameters:
key
- the referenced keydefaultValue
- the value to return when the key cannot be found- Returns:
- String
-
get
public boolean get(String key, boolean defaultValue)
Retrieves aboolean
value from the PipeLineSession- Parameters:
key
- the referenced keydefaultValue
- the value to return when the key cannot be found- Returns:
- boolean
-
getBoolean
@Nullable public Boolean getBoolean(String key)
Retrieves aBoolean
value from the PipeLineSession- Parameters:
key
- the referenced key- Returns:
- Boolean
-
get
public int get(String key, int defaultValue)
Retrieves anint
value from the PipeLineSession- Parameters:
key
- the referenced keydefaultValue
- the value to return when the key cannot be found- Returns:
- int
-
getInteger
@Nullable public Integer getInteger(String key)
Retrieves anInteger
value from the PipeLineSession- Parameters:
key
- the referenced key- Returns:
- Integer
-
get
public long get(String key, long defaultValue)
Retrieves along
value from the PipeLineSession- Parameters:
key
- the referenced keydefaultValue
- the value to return when the key cannot be found- Returns:
- long
-
get
public double get(String key, double defaultValue)
Retrieves adouble
value from the PipeLineSession- Parameters:
key
- the referenced keydefaultValue
- the value to return when the key cannot be found- Returns:
- double
-
scheduleCloseOnSessionExit
public void scheduleCloseOnSessionExit(AutoCloseable resource, String requester)
-
isScheduledForCloseOnExit
public boolean isScheduledForCloseOnExit(AutoCloseable message)
-
unscheduleCloseOnSessionExit
public void unscheduleCloseOnSessionExit(AutoCloseable message)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
getCloseables
public Map<AutoCloseable,String> getCloseables()
-
-