JBoss EJB client 1.0.11.Final-redhat-1

org.jboss.ejb.client
Class Attachable

java.lang.Object
  extended by org.jboss.ejb.client.Attachable
Direct Known Subclasses:
EJBClientContext, EJBClientInvocationContext, EJBClientTransactionContext, EJBReceiver, EJBReceiverContext

public abstract class Attachable
extends Object

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
<T> T
getAttachment(AttachmentKey<T> key)
          Get an attachment from this object.
 Map getAttachments()
          Returns the attachments applicable for this Attachable.
<T> T
putAttachment(AttachmentKey<T> key, T value)
          Set an attachment on this object.
<T> T
putAttachmentIfAbsent(AttachmentKey<T> key, T value)
          Set an attachment on this object if an existing attachment does not already exist.
<T> T
removeAttachment(AttachmentKey<T> key)
          Remove and return an attachment value.
<T> boolean
removeAttachment(AttachmentKey<T> key, T value)
          Remove an attachment if it has a certain value.
<T> T
replaceAttachment(AttachmentKey<T> key, T value)
          Replace an attachment on this object if an existing attachment exists.
<T> boolean
replaceAttachment(AttachmentKey<T> key, T oldValue, T newValue)
          Replace an attachment on this object if an existing attachment exists with a certain value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAttachment

public <T> T getAttachment(AttachmentKey<T> key)
Get an attachment from this object.

Type Parameters:
T - the attachment type
Parameters:
key - the attachment key
Returns:
the attachment value

getAttachments

public Map getAttachments()
Returns the attachments applicable for this Attachable. The returned Map is an unmodifiable Map. If there are no attachments for this Attachable then this method returns an empty Map

Returns:

putAttachment

public <T> T putAttachment(AttachmentKey<T> key,
                           T value)
Set an attachment on this object.

Type Parameters:
T - the attachment type
Parameters:
key - the attachment key
value - the attachment's new value (may not be null)
Returns:
the previous attachment value, or null if there was none

putAttachmentIfAbsent

public <T> T putAttachmentIfAbsent(AttachmentKey<T> key,
                                   T value)
Set an attachment on this object if an existing attachment does not already exist.

Type Parameters:
T - the attachment type
Parameters:
key - the attachment key
value - the attachment's new value (may not be null)
Returns:
the previous attachment value, or null if there was none

replaceAttachment

public <T> T replaceAttachment(AttachmentKey<T> key,
                               T value)
Replace an attachment on this object if an existing attachment exists.

Type Parameters:
T - the attachment type
Parameters:
key - the attachment key
value - the attachment's new value (may not be null)
Returns:
the previous attachment value, or null if there was none

replaceAttachment

public <T> boolean replaceAttachment(AttachmentKey<T> key,
                                     T oldValue,
                                     T newValue)
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 key
oldValue - the attachment's expected value (may not be null)
newValue - the attachment's new value (may not be null)
Returns:
true if the old value matched and the value was replaced; false otherwise

removeAttachment

public <T> T removeAttachment(AttachmentKey<T> key)
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 null if there was none

removeAttachment

public <T> boolean removeAttachment(AttachmentKey<T> key,
                                    T value)
Remove an attachment if it has a certain value.

Type Parameters:
T - the attachment type
Parameters:
key - the attachment key
value - the attachment's expected value (may not be null)
Returns:
true if the value was removed, false if there was no attachment

JBoss EJB client 1.0.11.Final-redhat-1

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.