Package org.jboss.ejb.client
Class Attachable
java.lang.Object
org.jboss.ejb.client.Attachable
- Direct Known Subclasses:
AbstractInvocationContext,EJBClientContext,EJBReceiver
An object which may have attachments. Even if the object is serializable, its
attachment map is not and will always deserialize empty.
- Author:
- David M. Lloyd
-
Method Summary
Modifier and TypeMethodDescription<T> TgetAttachment(AttachmentKey<T> key) Get an attachment from this object.Map<AttachmentKey<?>,?> Returns the attachments applicable for thisAttachable.<T> TputAttachment(AttachmentKey<T> key, T value) Set an attachment on this object.<T> TputAttachmentIfAbsent(AttachmentKey<T> key, T value) Set an attachment on this object if an existing attachment does not already exist.<T> TremoveAttachment(AttachmentKey<T> key) Remove and return an attachment value.<T> booleanremoveAttachment(AttachmentKey<T> key, T value) Remove an attachment if it has a certain value.<T> TreplaceAttachment(AttachmentKey<T> key, T value) Replace an attachment on this object if an existing attachment exists.<T> booleanreplaceAttachment(AttachmentKey<T> key, T oldValue, T newValue) Replace an attachment on this object if an existing attachment exists with a certain value.
-
Method Details
-
getAttachment
Get an attachment from this object.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment key- Returns:
- the attachment value
-
getAttachments
Returns the attachments applicable for thisAttachable. The returnedMapis an unmodifiableMap. If there are no attachments for thisAttachablethen this method returns an emptyMap- Returns:
- a read-only copy of the attachments map
-
putAttachment
Set an attachment on this object.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment keyvalue- the attachment's new value (may not benull)- Returns:
- the previous attachment value, or
nullif there was none
-
putAttachmentIfAbsent
Set an attachment on this object if an existing attachment does not already exist.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment keyvalue- the attachment's new value (may not benull)- Returns:
- the previous attachment value, or
nullif there was none
-
replaceAttachment
Replace an attachment on this object if an existing attachment exists.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment keyvalue- the attachment's new value (may not benull)- Returns:
- the previous attachment value, or
nullif there was none
-
replaceAttachment
Replace an attachment on this object if an existing attachment exists with a certain value.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment keyoldValue- the attachment's expected value (may not benull)newValue- the attachment's new value (may not benull)- Returns:
trueif the old value matched and the value was replaced;falseotherwise
-
removeAttachment
Remove and return an attachment value.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment key- Returns:
- the previous value of the attachment, or
nullif there was none
-
removeAttachment
Remove an attachment if it has a certain value.- Type Parameters:
T- the attachment type- Parameters:
key- the attachment keyvalue- the attachment's expected value (may not benull)- Returns:
trueif the value was removed,falseif there was no attachment
-