org.multiverse.api.programmatic
Interface ProgrammaticReferenceFactory


public interface ProgrammaticReferenceFactory

Using the ProgrammaticReferenceFactory it is possible to get access to the 'manual' instrumented reference: ProgrammaticReference. 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
 ProgrammaticLong atomicCreateLong(long value)
          Atomically creates a new ProgrammaticLong.
<E> ProgrammaticReference<E>
atomicCreateReference()
          Creates a new ProgrammaticReference with a null value atomically.
<E> ProgrammaticReference<E>
atomicCreateReference(E value)
          Creates a new ProgrammaticReference atomically.
 ProgrammaticLong createLong(long value)
          Creates a new ProgrammaticLong.
 ProgrammaticLong createLong(Transaction tx, long value)
          Creates a new ProgrammaticLong that is created in the context of the provided transaction.
<E> ProgrammaticReference<E>
createReference(E value)
          Creates a new ProgrammaticReference with the provided value.
<E> ProgrammaticReference<E>
createReference(Transaction tx, E value)
          Creates a new ProgrammaticReference with the provided value and lifting on the provided transaction.
 

Method Detail

createLong

ProgrammaticLong createLong(long value)
Creates a new ProgrammaticLong.

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

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

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

createLong

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

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

atomicCreateLong

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

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

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

createReference

<E> ProgrammaticReference<E> createReference(E value)
Creates a new ProgrammaticReference 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 ProgrammaticReference 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 ProgrammaticReference.

createReference

<E> ProgrammaticReference<E> createReference(Transaction tx,
                                             E value)
Creates a new ProgrammaticReference 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 ProgrammaticReference 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 ProgrammaticReference.
value - the value stored in the reference (is allowed to be null).
Returns:
the created ProgrammaticReference.
Throws:
NullPointerException - if t is null.
IllegalTransactionStateException - if t is not active.
ControlFlowError

atomicCreateReference

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

This is the cheapest call for making a ProgrammaticReference, 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 ProgrammaticReference.

atomicCreateReference

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

Returns:
the created ProgrammaticReference.


Copyright © 2008-2010 Multiverse. All Rights Reserved.