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

public Class ScopedWorkException

extends RuntimeException
Class Inheritance
Annotations
@ProviderType
Imports
java.io.Serializable, org.osgi.annotation.versioning.ProviderType

An Exception that is thrown when a piece of scoped work exits with an Exception.

If the scope was inherited and therefore is still active when this exception is raised then the current TransactionContext will be available from the ongoingContext() method.

Field Summary

Modifier and TypeField and Description
private final transient TransactionContext
context

TransactionContext instances are not required to be Serializable, and the ongoing context is very unlikely to be active post deserialization.

private static final long

Constructor Summary

AccessConstructor and Description
public
ScopedWorkException(String message, Throwable cause, TransactionContext context)

Creates a new TransactionException with the supplied message and cause

Method Summary

Modifier and TypeMethod and Description
public <T extends Throwable> T

Returns:

This method will always throw an exception
as
(Class<T> throwable)

Throws the cause of this Exception as a RuntimeException the supplied Exception type.

public <A extends Throwable, B extends Throwable> RuntimeException

Returns:

This method will always throw an exception
asOneOf
(Class<A> a, Class<B> b)

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

public <A extends Throwable, B extends Throwable, C extends Throwable> RuntimeException

Returns:

This method will always throw an exception
asOneOf
(Class<A> a, Class<B> b, Class<C> c)

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

public <A extends Throwable, B extends Throwable, C extends Throwable, D extends Throwable> RuntimeException

Returns:

This method will always throw an exception
asOneOf
(Class<A> a, Class<B> b, Class<C> c, Class<D> d)

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

public RuntimeException

Returns:

The cause of this Exception as a RuntimeException if it is one, or this otherwise
asRuntimeException
()

public TransactionContext

Returns:

The ongoing transaction context if the current scope was still active when this exception was raised or null otherwise. Note that this property will not be persisted during serialization.
ongoingContext
()

private static <E extends Throwable> RuntimeException

Field Detail

contextback to summary
private final transient TransactionContext context

TransactionContext instances are not required to be Serializable, and the ongoing context is very unlikely to be active post deserialization. As a result this field is transient.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

ScopedWorkExceptionback to summary
public ScopedWorkException(String message, Throwable cause, TransactionContext context)

Creates a new TransactionException with the supplied message and cause

Method Detail

asback to summary
public <T extends Throwable> T as(Class<T> throwable) throws Class-:T

Throws the cause of this Exception as a RuntimeException the supplied Exception type.

Usage is of the form:

public void doStuff() throws IOException {
    try {
        ...
    } catch (ScopedWorkException swe) {
        throw swe.as(IOException.class);
    }
}
Returns:T

This method will always throw an exception

Annotations
@SuppressWarnings:unchecked
asOneOfback to summary
public <A extends Throwable, B extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b) throws Class-:A, Class-:B

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

Usage is of the form:

public void doStuff() throws IOException, ClassNotFoundException {
    try {
        ...
    } catch (ScopedWorkException swe) {
        throw swe.asOneOf(IOException.class, ClassNotFoundException.class);
    }
}
Returns:RuntimeException

This method will always throw an exception

asOneOfback to summary
public <A extends Throwable, B extends Throwable, C extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b, Class<C> c) throws Class-:A, Class-:B, Class-:C

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

Returns:RuntimeException

This method will always throw an exception

Annotations
@SuppressWarnings:unused
See Also
asOneOf(Class, Class)
asOneOfback to summary
public <A extends Throwable, B extends Throwable, C extends Throwable, D extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b, Class<C> c, Class<D> d) throws Class-:A, Class-:B, Class-:C, Class-:D

Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.

Returns:RuntimeException

This method will always throw an exception

See Also
asOneOf(Class, Class)
asRuntimeExceptionback to summary
public RuntimeException asRuntimeException()
Returns:RuntimeException

The cause of this Exception as a RuntimeException if it is one, or this otherwise

ongoingContextback to summary
public TransactionContext ongoingContext()
Returns:TransactionContext

The ongoing transaction context if the current scope was still active when this exception was raised or null otherwise. Note that this property will not be persisted during serialization.

throwCauseback to summary
private static <E extends Throwable> RuntimeException throwCause(Throwable e) throws Throwable-:E
Annotations
@SuppressWarnings:unchecked