Class ScopedWorkException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.osgi.service.transaction.control.ScopedWorkException
- All Implemented Interfaces:
- Serializable
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.
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionScopedWorkException(String message, Throwable cause, TransactionContext context) Creates a new TransactionException with the supplied message and cause
- 
Method SummaryModifier and TypeMethodDescription<T extends Throwable>
 TThrows the cause of this Exception as a RuntimeException the supplied Exception type.<A extends Throwable,B extends Throwable> 
 RuntimeExceptionThrows the cause of this Exception as a RuntimeException or one of the supplied Exception types.<A extends Throwable,B extends Throwable, C extends Throwable> 
 RuntimeExceptionThrows the cause of this Exception as a RuntimeException or one of the supplied Exception types.<A extends Throwable,B extends Throwable, C extends Throwable, D extends Throwable> 
 RuntimeExceptionThrows the cause of this Exception as a RuntimeException or one of the supplied Exception types.Methods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
ScopedWorkExceptionCreates a new TransactionException with the supplied message and cause- Parameters:
- message-
- cause-
- context-
 
 
- 
- 
Method Details- 
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- Returns:
- The cause of this Exception as a RuntimeExceptionif it is one, or this otherwise
 
- 
asThrows 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
 
- 
asOneOfpublic <A extends Throwable,B extends Throwable> RuntimeException asOneOf(Class<A> a, Class<B> b) throws A, 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); } }- Parameters:
- a-
- b-
- Returns:
- This method will always throw an exception
- Throws:
- A
- B
 
- 
asOneOfpublic <A extends Throwable,B extends Throwable, RuntimeException asOneOfC extends Throwable> (Class<A> a, Class<B> b, Class<C> c) throws A, B, C 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
- C extends Throwable
- See Also:
 
- 
asOneOfpublic <A extends Throwable,B extends Throwable, RuntimeException asOneOfC extends Throwable, D extends Throwable> (Class<A> a, Class<B> b, Class<C> c, Class<D> d) throws A, B, C, D 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
- See Also:
 
 
-