final class WorkContextMapImpl extends java.lang.Object implements WorkContextMap, weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextMap
. This instance holds
a thread-local reference to the actual WorkContextMap
implementation that does most of the work.WorkContextMap
Modifier and Type | Field and Description |
---|---|
private static weblogic.kernel.AuditableThreadLocal |
localContextMap |
Constructor and Description |
---|
WorkContextMapImpl() |
Modifier and Type | Method and Description |
---|---|
weblogic.workarea.spi.WorkContextMapInterceptor |
copyThreadContexts(int mode)
Return the thread-local contexts that should be propagated to new
threads.
|
WorkContext |
get(java.lang.String key)
Get the current WorkContextMap's context data for key.
|
weblogic.workarea.spi.WorkContextMapInterceptor |
getInterceptor() |
private WorkContextMap |
getMap() |
private WorkContextMap |
getMapMaybe() |
int |
getPropagationMode(java.lang.String key)
Get the current
WorkContextMap 's
PropagationMode value for key. |
boolean |
isEmpty()
Tests to see whether there are any
WorkContext s in
existance in the map. |
boolean |
isPropagationModePresent(int propMode)
Given a PropagationMode
PropagationMode , this method will iterate
over the map and return true if the propagation mode is present. |
java.util.Iterator |
iterator()
Return a iterator for all of the current
WorkContext
entries. |
java.util.Iterator |
keys()
Return a iterator for all of the current
WorkContext
keys. |
WorkContext |
put(java.lang.String key,
WorkContext workContext)
Adds context data with key
key to the current
WorkContextMap and associates it with the current thread. |
WorkContext |
put(java.lang.String key,
WorkContext workContext,
int propagationMode)
Adds context data with key
key to the current
WorkContextMap and associates it with the current thread. |
void |
receiveRequest(WorkContextInput in)
Transfer the protocol-specific
WorkContextInput data
to thread-local storage after receiving a request. |
void |
receiveResponse(WorkContextInput in)
Transfer the protocol-specific
WorkContextInput data
to thread-local storage after receiving a response. |
WorkContext |
remove(java.lang.String key)
Remove the context data for key from the current WorkContextMap.
|
private void |
reset() |
void |
restoreThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor contexts)
Restore thread-local contexts from
contexts that
should be propagated to new threads. |
void |
resumeThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor contexts)
Resume thread-local contexts from
contexts . |
void |
sendRequest(WorkContextOutput out,
int propagationMode)
Transfer
WorkContext s from thread-local storage to
the protocol-specific WorkContextOutput before
making an outbound request. |
void |
sendResponse(WorkContextOutput out,
int propagationMode)
Transfer
WorkContext s from thread-local storage to
the protocol-specific WorkContextOutput before
sending a response. |
void |
setInterceptor(weblogic.workarea.spi.WorkContextMapInterceptor interceptor) |
weblogic.workarea.spi.WorkContextMapInterceptor |
suspendThreadContexts()
Remove and return all the thread-local contexts from the current
thread.
|
int |
version()
Return a version indicator for the current
WorkContextMap . |
private static final weblogic.kernel.AuditableThreadLocal localContextMap
public WorkContext put(java.lang.String key, WorkContext workContext, int propagationMode) throws PropertyReadOnlyException
WorkContextMap
key
to the current
WorkContextMap and associates it with the current thread. This context
data is propagated according to the provided mode
propagationMode
. Any existing value for key will be
changed as per the property mode
propertyModeType
. It is legal for multiple context
data items to be propagated as long as their keys differ.
Properties that are set in the WorkContextMap are propagated
based on propagation policies assigned to the property. By
default a property is not propagated out of the current
thread. Applying PropagationMode.WORK
allows a
property to be propagated to Work instances. Applying
PropagationMode.RMI
allows a property to be
propagated in RMI calls. Applying
PropagationMode.TRANSACTION
allows a property to be
propagated between different global transactions. Applying
PropagationMode.JMS_QUEUE
allows a property to be
propagated to JMS consumers. Applying
PropagationMode.JMS_TOPIC
allows a property to be
propagated from JMS producers. Applying
PropagationMode.SOAP
allows a property to be
propagated across SOAP messages. Applying
PropagationMode.MIME_HEADER
allows a property to be
propagated from mail messages or cookies.
PropagationMode
s are additive and can be used
together. PropagationMode.GLOBAL
is an alias for
PropagationMode.RMI, PropagationMode.SOAP,
PropagationMode.JMS_QUEUE
and
PropagationMode.MIME_HEADERS
put
in interface WorkContextMap
key
- a unique String
that is used to obtain a
reference to a particular WorkContext
. Keys are
encoded as DataOutput.writeUTF(java.lang.String)
. In order to protect
the key namespace a good convention is to use package names as a
prefix. For example com.you.SomeKey
.workContext
- The WorkContext
to put in the map.
specifies how the WorkContext
entry can be modified.propagationMode
- a bitwise-OR of
PropagationMode
values prescribing how the
WorkContext
entry should be propagated.PropertyReadOnlyException
- if the property already
exists and is read-only.PropagationMode
public WorkContext put(java.lang.String key, WorkContext workContext) throws PropertyReadOnlyException
WorkContextMap
key
to the current
WorkContextMap and associates it with the current thread. The context
data is propagated according to the default
PropagationMode
. The
defaults are PropagationMode.DEFAULT
.put
in interface WorkContextMap
key
- a unique String
that is used to obtain a
reference to a particular WorkContext
. Keys are
encoded as DataOutput.writeUTF(java.lang.String)
. In order to protect
the key namespace a good convention is to use package names as a
prefix. For example com.you.SomeKey}.
workContext
- The WorkContext
to put in the map.PropertyReadOnlyException
- if the property already
exists and is read-only.public WorkContext get(java.lang.String key)
WorkContextMap
get
in interface WorkContextMap
key
- a unique String
that is used to obtain a
reference to a particular WorkContext
WorkContext
value or null if there is
none.public WorkContext remove(java.lang.String key) throws NoWorkContextException, PropertyReadOnlyException
WorkContextMap
PropertyReadOnlyException
if the
permissions on the key do not allow deletion.remove
in interface WorkContextMap
key
- a unique String
that is used to obtain a
reference to a particular WorkContext
NoWorkContextException
- if there is no mapping for
key
PropertyReadOnlyException
- if a mapping exists but is
read-only.public int getPropagationMode(java.lang.String key)
WorkContextMap
WorkContextMap
's
PropagationMode
value for key. If the current
WorkContextMap
has no value for key then
PropagationMode.LOCAL is returned.getPropagationMode
in interface WorkContextMap
key
- a unique String
that is used to obtain a
reference to a particular WorkContext
PropagationMode
values
prescribing how the WorkContext
entry should be
propagated.public boolean isPropagationModePresent(int propMode)
WorkContextMap
PropagationMode
, this method will iterate
over the map and return true if the propagation mode is present. The method
should return true if there exists at least one entry in the map which has
at least one propagation mode specified by propModeisPropagationModePresent
in interface WorkContextMap
propMode
- PropagationMode
valuepublic boolean isEmpty()
WorkContextMap
WorkContext
s in
existance in the map. Returns true if there are no elements in
the map, false otherwise.isEmpty
in interface WorkContextMap
boolean
valueprivate void reset()
public java.util.Iterator iterator()
WorkContextMap
WorkContext
entries. If there are no entries then null is returned.iterator
in interface WorkContextMap
Iterator
representing the current entries.public java.util.Iterator keys()
WorkContextMap
WorkContext
keys. If there are no entries then null is returned.keys
in interface WorkContextMap
Iterator
representing the current keys.public int version()
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextMap
.
The version will change when
properties in the map are added, removed or changed.version
in interface weblogic.workarea.spi.WorkContextMapInterceptor
private final WorkContextMap getMapMaybe()
private final WorkContextMap getMap()
public weblogic.workarea.spi.WorkContextMapInterceptor getInterceptor()
public void setInterceptor(weblogic.workarea.spi.WorkContextMapInterceptor interceptor)
public void sendRequest(WorkContextOutput out, int propagationMode) throws java.io.IOException
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContext
s from thread-local storage to
the protocol-specific WorkContextOutput
before
making an outbound request. This must be called at the
appropriate time before any thread context-switches. This call
does not affect the contents of thread-local storage in any way.sendRequest
in interface weblogic.workarea.spi.WorkContextMapInterceptor
out
- TheWorkContextOutput
implementation to
marshal the WorkContextMap
data to.propagationMode
- The PropagationMode
being
utilized in this call. This is a hint to the runtime system.java.io.IOException
- if the data cannot be serialized.public void sendResponse(WorkContextOutput out, int propagationMode) throws java.io.IOException
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContext
s from thread-local storage to
the protocol-specific WorkContextOutput
before
sending a response. This must be called at the appropriate time
before any thread context-switches. This call does not affect
the contents of thread-local storage in any way.sendResponse
in interface weblogic.workarea.spi.WorkContextMapInterceptor
out
- TheWorkContextOutput
implementation to
marshal the WorkContextMap
data to.propagationMode
- The PropagationMode
being
utilized in this call. This is a hint to the runtime system.java.io.IOException
- if the data cannot be serialized.public void receiveRequest(WorkContextInput in) throws java.io.IOException
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextInput
data
to thread-local storage after receiving a request. This must be
called at the appropriate time after any thread context-switches.
All existing thread-local contexts are overwritten, athough in
general the thread execution model should ensure that there are
no existing thread-local contexts.receiveRequest
in interface weblogic.workarea.spi.WorkContextMapInterceptor
in
- The WorkContextInput
implementation to
read WorkContextMap
data from.java.io.IOException
- if the data cannot be read.public void receiveResponse(WorkContextInput in) throws java.io.IOException
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextInput
data
to thread-local storage after receiving a response. This must be
called at the appropriate time after any thread context-switches.
The data is merged with any existing thread-local contexts.
in
may be null which means that the callee removed
all of the WorkContext
s.receiveResponse
in interface weblogic.workarea.spi.WorkContextMapInterceptor
in
- The WorkContextInput
implementation to
read WorkContextMap
data from.java.io.IOException
- if the data cannot be read.public weblogic.workarea.spi.WorkContextMapInterceptor copyThreadContexts(int mode)
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextMapInterceptor.restoreThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor)
or one of the interceptor functions.
The existing thread-local contexts are not modified in any way. While
the returned WorkContextMap
is a new instance,
the contained values are not, so developers should not attempt to update the
contents of the values.copyThreadContexts
in interface weblogic.workarea.spi.WorkContextMapInterceptor
mode
- only contexts with this PropagationMode
will be copied. mode can
be a bit-wise OR of PropagationMode
sWorkContextMapInterceptor
that contains the
WorkContextMap
data to be propagated.public void restoreThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor contexts)
weblogic.workarea.spi.WorkContextMapInterceptor
contexts
that
should be propagated to new threads. contexts
must
have been obtained as a result of calling WorkContextMapInterceptor.copyThreadContexts(int)
. Existing thread-local contexts are
overwritten, although in general there should be none.restoreThreadContexts
in interface weblogic.workarea.spi.WorkContextMapInterceptor
contexts
- an WorkContextMapInterceptor
obtained via
WorkContextMapInterceptor.copyThreadContexts(int)
.public weblogic.workarea.spi.WorkContextMapInterceptor suspendThreadContexts()
weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextMapInterceptor.resumeThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor)
or another interceptor function.
The intention of this call is that a service provider will have already called
WorkContextMapInterceptor.sendRequest(weblogic.workarea.WorkContextOutput, int)
or WorkContextMapInterceptor.sendResponse(weblogic.workarea.WorkContextOutput, int)
to
transfer thread-local contexts to a remote message and this call
is used to prevent other RMI mechnisms being involved.suspendThreadContexts
in interface weblogic.workarea.spi.WorkContextMapInterceptor
WorkContextMapInterceptor
that contains the
WorkContextMap
data to be saved.public void resumeThreadContexts(weblogic.workarea.spi.WorkContextMapInterceptor contexts)
weblogic.workarea.spi.WorkContextMapInterceptor
contexts
. contexts
must have been
obtained as a result of calling
WorkContextMapInterceptor.suspendThreadContexts()
. All existing thread-local
contexts are overwritten, although in general there should be
none.resumeThreadContexts
in interface weblogic.workarea.spi.WorkContextMapInterceptor
contexts
- a WorkContextMapInterceptor
obtained via
WorkContextMapInterceptor.suspendThreadContexts()
.