Top Description Methods
org.osgi.service.transaction.control

public Interface TransactionStarter

Known Direct Subinterfaces
org.osgi.service.transaction.control.TransactionControl
Known Direct Implementers
org.osgi.service.transaction.control.TransactionBuilder
Annotations
@ProviderType
Imports
java.util.concurrent.Callable, org.osgi.annotation.versioning.ProviderType

Implementations of this interface are able to run a piece of work within a transaction

Method Summary

Modifier and TypeMethod and Description
public <T> T

Returns:

The value returned by the work
notSupported
(Callable<T> work)

The supplied piece of work must be run outside the context of a transaction.

public <T> T

Returns:

The value returned by the work
required
(Callable<T> work)

A transaction is required to run the supplied piece of work.

public <T> T

Returns:

The value returned by the work
requiresNew
(Callable<T> work)

A new transaction is required to run the supplied piece of work.

public <T> T

Returns:

The value returned by the work
supports
(Callable<T> work)

The supplied piece of work may run inside or outside the context of a transaction.

Method Detail

notSupportedback to summary
public <T> T notSupported(Callable<T> work) throws TransactionException, ScopedWorkException

The supplied piece of work must be run outside the context of a transaction. If an existing transaction is active then it must be suspended and a "no transaction" context associated with the work. After the work has completed any suspended transaction must be resumed.

The "no transaction" context does not support resource enlistment, and will not commit or rollback any changes, however it does provide a post completion callback to any registered functions. This function is suitable for final cleanup, such as closing a connection

Returns:T

The value returned by the work

Exceptions
TransactionException:
if there is an error starting or completing the transaction
ScopedWorkException:
if the supplied work throws an Exception
requiredback to summary
public <T> T required(Callable<T> work) throws TransactionException, TransactionRolledBackException, ScopedWorkException

A transaction is required to run the supplied piece of work. If no transaction is active then it must be started and associated with the work and then completed after the transactional work has finished.

Returns:T

The value returned by the work

Exceptions
TransactionException:
if there is an error starting or completing the transaction
TransactionRolledBackException:
if the transaction rolled back due to a failure in one of the resources or an internal error in the TransactionControl service
ScopedWorkException:
if the supplied work throws an Exception
requiresNewback to summary
public <T> T requiresNew(Callable<T> work) throws TransactionException, TransactionRolledBackException, ScopedWorkException

A new transaction is required to run the supplied piece of work. If an existing transaction is active then it must suspended and a new transaction started and associated with the work. After the work has completed the new transaction must also complete and any suspended transaction be resumed.

Returns:T

The value returned by the work

Exceptions
TransactionException:
if there is an error starting or completing the transaction
TransactionRolledBackException:
if the transaction rolled back due to a failure
ScopedWorkException:
if the supplied work throws an Exception
supportsback to summary
public <T> T supports(Callable<T> work) throws TransactionException, ScopedWorkException

The supplied piece of work may run inside or outside the context of a transaction. If an existing transaction or "no transaction" context is active then it will continue, otherwise a new "no transaction" context is associated with the work. After the work has completed any created transaction context must be completed.

The "no transaction" context does not support resource enlistment, and will not commit or rollback any changes, however it does provide a post completion callback to any registered functions. This function is suitable for final cleanup, such as closing a connection

Returns:T

The value returned by the work

Exceptions
TransactionException:
if there is an error starting or completing the transaction
ScopedWorkException:
if the supplied work throws an Exception