org.multiverse.api.programmatic
Interface ProgrammaticRefFactory


public interface ProgrammaticRefFactory

Using the ProgrammaticRefFactory it is possible to get access to the 'manual' instrumented reference: ProgrammaticRef. This reference can safely be used without relying on instrumentation. It also provides access to methods not available in the normal instrumented classes.

This functionality specially is added to integrate Multiverse in environments where you don't want to rely on instrumentation but just want to have a 'managed reference (for example if you want to integrate multiverse in a different language than Java).

Methods are thread safe.

Author:
Peter Veentjer

Method Summary
 ProgrammaticLongRef atomicCreateLongRef(long value)
          Atomically creates a new ProgrammaticLongRef.
<E> ProgrammaticRef<E>
atomicCreateRef()
          Creates a new ProgrammaticRef with a null value atomically.
<E> ProgrammaticRef<E>
atomicCreateRef(E value)
          Creates a new ProgrammaticRef atomically.
 ProgrammaticLongRef createLongRef(long value)
          Creates a new ProgrammaticLongRef.
 ProgrammaticLongRef createLongRef(Transaction tx, long value)
          Creates a new ProgrammaticLongRef that is created in the context of the provided transaction.
<E> ProgrammaticRef<E>
createRef(E value)
          Creates a new ProgrammaticRef with the provided value.
<E> ProgrammaticRef<E>
createRef(Transaction tx, E value)
          Creates a new ProgrammaticRef with the provided value and lifting on the provided transaction.
 

Method Detail

createLongRef

ProgrammaticLongRef createLongRef(long value)
Creates a new ProgrammaticLongRef.

If a Transaction is running in the ThreadLocalTransaction that will be used. If none is running this call is atomic.

If the ProgrammaticLongRef leaves the transaction it was created in before that transaction commits, you will get the UncommittedReadConflict.

Parameters:
value - the initial value of the ProgrammaticLongRef.
Returns:
the created ProgrammaticLongRef.
Throws:
ControlFlowError

createLongRef

ProgrammaticLongRef createLongRef(Transaction tx,
                                  long value)
Creates a new ProgrammaticLongRef that is created in the context of the provided transaction.

Parameters:
tx - the transaction to use for creating this ProgrammaticLongRef.
value - the initial value of the ProgrammaticLongRef.
Returns:
the created ProgrammaticLongRef
Throws:
NullPointerException - if tx is null.
IllegalTransactionStateException - if the transaction is not in the correct state for this operation.

atomicCreateLongRef

ProgrammaticLongRef atomicCreateLongRef(long value)
Atomically creates a new ProgrammaticLongRef. So this call doesn't look at the Transaction stores in the ThreadLocalTransaction.

This is the cheapest call for making a ProgrammaticLongRef, so in most cases this is the one you want to use.

Parameters:
value - the value stored in the ProgrammaticLongRef.
Returns:
the created ProgrammaticLongRef

createRef

<E> ProgrammaticRef<E> createRef(E value)
Creates a new ProgrammaticRef with the provided value. If a transaction already is running in the ThreadLocalTransaction, it will lift on that transaction. If no transaction is running, then this method will be run atomic.

If the ProgrammaticRef leaves the transaction it was created in before that transaction commits, you will get the UncommittedReadConflict.

Type Parameters:
E - the type of the value stored in the reference
Parameters:
value - the value stored in the reference (is allowed to be null).
Returns:
the created ProgrammaticRef.

createRef

<E> ProgrammaticRef<E> createRef(Transaction tx,
                                 E value)
Creates a new ProgrammaticRef with the provided value and lifting on the provided transaction. This method is the one you want to use if you don't want to deal with the TransactionThreadLocal to exchange the Transaction.

If the ProgrammaticRef leaves the transaction it was created in before that transaction commits, you will get the UncommittedReadConflict.

Type Parameters:
E - the type of the value stored in the reference
Parameters:
tx - the Transaction used to createReference the ProgrammaticRef.
value - the value stored in the reference (is allowed to be null).
Returns:
the created ProgrammaticRef.
Throws:
NullPointerException - if t is null.
IllegalTransactionStateException - if t is not active.
ControlFlowError

atomicCreateRef

<E> ProgrammaticRef<E> atomicCreateRef(E value)
Creates a new ProgrammaticRef atomically. So this call doesn't look at the ThreadLocalTransaction.

This is the cheapest call for making a ProgrammaticRef, so in most cases this is the one you want to use.

Type Parameters:
E - type of the value
Parameters:
value - the value stores in the reference (is allowed to be null).
Returns:
the created ProgrammaticRef.

atomicCreateRef

<E> ProgrammaticRef<E> atomicCreateRef()
Creates a new ProgrammaticRef with a null value atomically. So this call doesn't look at the ThreadLocalTransaction. This is the cheapest call for making a ProgrammaticRef, so in most cases this is the one you want to use.

Returns:
the created ProgrammaticRef.


Copyright © 2008-2010 Multiverse. All Rights Reserved.