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.RuntimeExceptionAn 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
TransactionContextwill be available from theongoingContext()method.- See Also:
- Serialized Form
-
-
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 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.RuntimeExceptionasRuntimeException()TransactionContextongoingContext()
-
-
-
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
nullotherwise. Note that this property will not be persisted during serialization.
-
asRuntimeException
public java.lang.RuntimeException asRuntimeException()
- Returns:
- The cause of this Exception as a
RuntimeExceptionif 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.ThrowableThrows 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:
TT 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.ThrowableThrows 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:
ABA 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.ThrowableThrows 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:
ABA 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.ThrowableThrows 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:
ABCDA extends java.lang.Throwable- See Also:
asOneOf(Class, Class)
-
-