Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.singleton
Class SingletonException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by dk.rode.thesis.singleton.SingletonException
All Implemented Interfaces:
Serializable

public class SingletonException
extends RuntimeException

A singleton exception is thrown in case a given type cannot be determined to be a singleton type when requested from a given registry or in case a singleton instance cannot be acquired from a registry.

Implementation notes:
Declared as a runtime exception because ordinary use of singletons and singleton registries are assumed to be correct by the context using them. The context, for example, should never test for a null return value from a registry, because either the singleton instance exist or it does not; a null value does not make any sense, and would constitute a poor design decision. Hence, in the general case, the context should not have to worry about checked exceptions as they would never be thrown.

The singleton creation could fail, of cause, but that is of no concern to the registry as it will simply re-throw such errors wrapped in this exception type.

Author:
Gunni Rode / rode.dk
See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
          Serial version id.
 
Constructor Summary
SingletonException()
          No-arg constructor.
SingletonException(Class<?> type)
          Constructor.
SingletonException(String message)
          Constructor.
SingletonException(Throwable cause)
          Constructor.
 
Method Summary
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

SingletonException

public SingletonException()
No-arg constructor.


SingletonException

public SingletonException(Class<?> type)
Constructor.

Parameters:
type - The faulting type; can be null.

SingletonException

public SingletonException(String message)
Constructor.

Parameters:
message - The detail message; can be null.

SingletonException

public SingletonException(Throwable cause)
Constructor.

Parameters:
cause - The causing throwable; can be null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.