Class ScopedWorkException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- org.osgi.service.transaction.control.ScopedWorkException
-
- All Implemented Interfaces:
java.io.Serializable
@ProviderType public class ScopedWorkException extends java.lang.RuntimeException
An Exception that is thrown when a piece of scoped work exits with anException
.If the scope was inherited and therefore is still active when this exception is raised then the current
TransactionContext
will be available from theongoingContext()
method.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private TransactionContext
context
TransactionContext
instances are not required to beSerializable
, and the ongoing context is very unlikely to be active post deserialization.private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ScopedWorkException(java.lang.String message, java.lang.Throwable cause, TransactionContext context)
Creates a new TransactionException with the supplied message and cause
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.Throwable>
Tas(java.lang.Class<T> throwable)
Throws the cause of this Exception as a RuntimeException the supplied Exception type.<A extends java.lang.Throwable,B extends java.lang.Throwable>
java.lang.RuntimeExceptionasOneOf(java.lang.Class<A> a, java.lang.Class<B> b)
Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.<A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable>
java.lang.RuntimeExceptionasOneOf(java.lang.Class<A> a, java.lang.Class<B> b, java.lang.Class<C> c)
Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.<A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable,D extends java.lang.Throwable>
java.lang.RuntimeExceptionasOneOf(java.lang.Class<A> a, java.lang.Class<B> b, java.lang.Class<C> c, java.lang.Class<D> d)
Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.java.lang.RuntimeException
asRuntimeException()
TransactionContext
ongoingContext()
private static <E extends java.lang.Throwable>
java.lang.RuntimeExceptionthrowCause(java.lang.Throwable e)
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
context
private final transient TransactionContext context
TransactionContext
instances are not required to beSerializable
, and the ongoing context is very unlikely to be active post deserialization. As a result this field is transient.
-
-
Constructor Detail
-
ScopedWorkException
public ScopedWorkException(java.lang.String message, java.lang.Throwable cause, TransactionContext context)
Creates a new TransactionException with the supplied message and cause- Parameters:
message
-cause
-context
-
-
-
Method Detail
-
ongoingContext
public TransactionContext ongoingContext()
- 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.
-
asRuntimeException
public java.lang.RuntimeException asRuntimeException()
- Returns:
- The cause of this Exception as a
RuntimeException
if it is one, or this otherwise
-
as
public <T extends java.lang.Throwable> T as(java.lang.Class<T> throwable) throws T extends java.lang.Throwable
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); } }
- Parameters:
throwable
-- Returns:
- This method will always throw an exception
- Throws:
T
T extends java.lang.Throwable
-
asOneOf
public <A extends java.lang.Throwable,B extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a, java.lang.Class<B> b) throws A extends java.lang.Throwable, B extends java.lang.Throwable
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); } }
- Parameters:
a
-b
-- Returns:
- This method will always throw an exception
- Throws:
A
B
A extends java.lang.Throwable
-
asOneOf
public <A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a, java.lang.Class<B> b, java.lang.Class<C> c) throws A extends java.lang.Throwable, B extends java.lang.Throwable, C extends java.lang.Throwable
Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.- Parameters:
a
-b
-c
-- Returns:
- This method will always throw an exception
- Throws:
A
B
A extends java.lang.Throwable
- See Also:
asOneOf(Class, Class)
-
asOneOf
public <A extends java.lang.Throwable,B extends java.lang.Throwable,C extends java.lang.Throwable,D extends java.lang.Throwable> java.lang.RuntimeException asOneOf(java.lang.Class<A> a, java.lang.Class<B> b, java.lang.Class<C> c, java.lang.Class<D> d) throws A extends java.lang.Throwable, B extends java.lang.Throwable, C extends java.lang.Throwable, D extends java.lang.Throwable
Throws the cause of this Exception as a RuntimeException or one of the supplied Exception types.- Parameters:
a
-b
-c
-d
-- Returns:
- This method will always throw an exception
- Throws:
A
B
C
D
A extends java.lang.Throwable
- See Also:
asOneOf(Class, Class)
-
throwCause
private static <E extends java.lang.Throwable> java.lang.RuntimeException throwCause(java.lang.Throwable e) throws E extends java.lang.Throwable
- Throws:
E extends java.lang.Throwable
-
-