org.multiverse.transactional
Interface TransactionalReference<E>

All Known Implementing Classes:
DefaultTransactionalReference, TransactionalAbaReference

public interface TransactionalReference<E>

The TransactionalReference is responsible for storing an object reference transactional (so that it can be used in a Transaction.

Timed versions of the getOrAwait methods will be added in the near future.

Author:
Peter Veentjer

Method Summary
 E clear()
          Clears the ref and returns the old value of the ref (could be null).
 E get()
          Gets the current stored ref, or null if no ref is stored.
 E getOrAwait()
          Gets the current stored ref, or waits until a non null reference becomes available.
 E getOrAwaitInterruptibly()
          Gets the current stored reference, or waits until a non null references becomes available or until it is is Interrupted.
 boolean isNull()
          Checks if the ref is null.
 E set(E ref)
          Sets the current ref.
 

Method Detail

get

E get()
Gets the current stored ref, or null if no ref is stored.

Returns:
the current stored ref, or null if no ref is stored.

getOrAwait

E getOrAwait()
Gets the current stored ref, or waits until a non null reference becomes available. So you will always get a non null ref. This call is not interruptible, unless the enclosing transaction is configured as interruptible.

Returns:
the current stored reference.

getOrAwaitInterruptibly

E getOrAwaitInterruptibly()
                          throws java.lang.InterruptedException
Gets the current stored reference, or waits until a non null references becomes available or until it is is Interrupted. This call is interruptible, unless the enclosing transaction isn't configured as interruptible.

Returns:
the current stored reference.
Throws:
java.lang.InterruptedException - if the thread is interrupted while waiting on a reference to come available.

set

E set(E ref)
Sets the current ref. The ref is allowed to be null.

Parameters:
ref - the ref to set.
Returns:
the previous ref, which could be null.

clear

E clear()
Clears the ref and returns the old value of the ref (could be null).

Returns:
the old value.

isNull

boolean isNull()
Checks if the ref is null.

Returns:
true if the ref is null, false otherwise.


Copyright © 2008-2010 Multiverse. All Rights Reserved.