ApplicationException Class
- public class ApplicationException
extends Exception
implements MessageCatalogException
The ApplicationException class is used to signal checked business
logic exceptions to a caller. It is the base application exception class.
The ApplicationException class is closely tied to the
MessageCatalog. An ApplicationException
contains a log and user message that is constructed using the MessageCatalog.
In fact, each ApplicationException derivative should have at
least one user and log catalog message.
In the case of an EJB, the following guidelines should be followed:
According to the EJB 1.1 specification, an application exception is an exception
defined in the throws clause of the enterprise bean home and remote interfaces,
other than the RemoteException.
A bean provider is responsible for defining application exceptions in bean
remote and home interfaces and is also responsible for throwing an appropriate
application exception from a bean method to report a business logic exception to
the client. If necessary, the bean provider should subclass the
ApplicationException class to create package-specific application exceptions.
However, a bean provider is responsible for using the standard EJB application
exceptions (CreateException, FinderException,
RemoveException, DuplicateKeyException,
ObjectNotFoundException) where appropriate.
Since an application exception does not, and should not, automatically mark the
existing transaction (if any) for rollback, the bean provider must do one of the
following before throwing the exception, in order to insure data integrity:
The second option is only available when the bean is deployed with Container managed
transaction management. Therefore, in order not to tie the bean implementation to
a specific deployment, try to avoid using setRollbackOnly at all costs.
If this is not possible, consider using a FatalApplicationException.
Related Topics
MessageCatalog
FatalApplicationException
MessageCatalogException
-
Hierarchy
-
Object
Throwable
Exception
ApplicationException
-
All Implemented Interfaces
-
MessageCatalogException, Serializable
-
Direct Known Subclasses
-
BMPException, CatalogException, DiscountException, IllegalWorkflowTransitionException, InconsistentStateException, InvalidArgumentException, InvalidCurrencyException, ItemNotInShoppingCartException, OrderInventoryException, OrderInvoicingException, OrderShippingException, PaymentException, PaymentProcessException, PricingException, ProcessingException, ShippingMethodException, TaxException
-
ApplicationException()
- Constructs an
ApplicationException with no associated message.
|
-
ApplicationException(
ApplicationException topException, ApplicationException bottomException)
- Constructs an
ApplicationException from two source ApplicationExceptions
by concatinating the screen and log messages of the two source ApplicationExceptions.
|
-
ApplicationException(
String namespace, String messageKey, Exception exception)
- Class constructor taking the namespace and key of the associated catalog message
and an embedded exception.
|
-
ApplicationException(
String namespace, String messageKey, Object argument, Exception exception)
- Class constructor taking the namespace and key of the associated catalog message,
message parameter substitution argument, and an embedded exception.
|
-
ApplicationException(
String namespace, String messageKey, Object argument)
- Class constructor taking the namespace and key of the associated catalog message
and a message parameter substitution argument.
|
-
ApplicationException(
String namespace, String messageKey, Object arguments, Exception exception)
- Class constructor taking the namespace and key of the associated catalog message,
message parameter substitution arguments, and an embedded exception.
|
-
ApplicationException(
String namespace, String messageKey, Object arguments)
- Class constructor taking the namespace and key of the associated catalog message and
message parameter substitution arguments.
|
-
ApplicationException(
String namespace, String messageKey)
- Class constructor taking the namespace and key of the associated catalog message.
|
public void |
-
addLogMessage(String namespace, String messageKey)
- Adds a new log catalog message to the stack of associated messages.
|
public void |
-
addLogMessage(String namespace, String messageKey, Object argument)
- Adds a new log catalog message to the stack of associated messages.
|
public void |
-
addLogMessage(String namespace, String messageKey, Object[] arguments)
- Adds a new log catalog message to the stack of associated messages.
|
public void |
-
addMessage(String namespace, String messageKey)
- Adds a new user and log catalog message to the stack of associated messages.
|
public void |
-
addMessage(String namespace, String messageKey, Object argument)
- Adds a new user catalog message to the stack of associated messages.
|
public void |
-
addMessage(String namespace, String messageKey, Object[] arguments)
- Adds a new user catalog message to the stack of associated messages.
|
public void |
-
addUserMessage(String namespace, String messageKey)
- Adds a new user catalog message to the stack of associated messages.
|
public void |
-
addUserMessage(String namespace, String messageKey, Object argument)
- Adds a new user catalog message to the stack of associated messages.
|
public void |
-
addUserMessage(String namespace, String messageKey, Object[] arguments)
- Adds a new user catalog message to the stack of associated messages.
|
public Exception |
-
getEmbeddedException()
- Gets the embedded exception associated with this exception.
|
public String |
-
getLocalizedMessage()
- Returns the user message associated with this exception.
|
public String |
-
getLogMessage()
- Returns the first log catalog message associated with this exception.
|
public Iterator |
-
getLogMessages()
- Returns an iterator over all the log catalog messages associated with
this exception.
|
public String |
-
getMessage()
- Returns the user message associated with this exception.
|
public String |
-
getUserMessage()
- Returns the first user catalog message associated with this exception.
|
public Iterator |
-
getUserMessages()
- Returns an iterator over all the user catalog messages associated with
this exception.
|
public String |
-
toString()
- Returns a string representation of this exception.
|
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface com.beasys.commerce.foundation.exception.MessageCatalogException |
addLogMessage, addLogMessage, addLogMessage, addMessage, addMessage, addMessage, addUserMessage, addUserMessage, addUserMessage, getEmbeddedException, getLogMessage, getLogMessages, getUserMessage, getUserMessages |
embeddedException
protected Exception embeddedException
- The embedded exception.
logMessages
protected Stack logMessages
- The log messages.
userMessages
protected Stack userMessages
- The user messages.
ApplicationException
public ApplicationException()
- Constructs an
ApplicationException with no associated message.
ApplicationException
public ApplicationException(ApplicationException topException,
ApplicationException bottomException)
- Constructs an
ApplicationException from two source ApplicationExceptions
by concatinating the screen and log messages of the two source ApplicationExceptions.
The messages of the first ApplicationException will preceed those of the second in the
constructed ApplicationException. Furthermore, the new ApplicationException
will have the embedded exception of the first ApplicationException associated with it.
ApplicationException
public ApplicationException(String namespace,
String messageKey,
Exception exception)
- Class constructor taking the namespace and key of the associated catalog message
and an embedded exception.
ApplicationException
public ApplicationException(String namespace,
String messageKey,
Object argument,
Exception exception)
- Class constructor taking the namespace and key of the associated catalog message,
message parameter substitution argument, and an embedded exception.
ApplicationException
public ApplicationException(String namespace,
String messageKey,
Object argument)
- Class constructor taking the namespace and key of the associated catalog message
and a message parameter substitution argument.
ApplicationException
public ApplicationException(String namespace,
String messageKey,
Object[] arguments,
Exception exception)
- Class constructor taking the namespace and key of the associated catalog message,
message parameter substitution arguments, and an embedded exception.
ApplicationException
public ApplicationException(String namespace,
String messageKey,
Object[] arguments)
- Class constructor taking the namespace and key of the associated catalog message and
message parameter substitution arguments.
ApplicationException
public ApplicationException(String namespace,
String messageKey)
- Class constructor taking the namespace and key of the associated catalog message.
addLogMessage(String, String) Method
public void addLogMessage(String namespace,
String messageKey)
Description copied from MessageCatalogException.addLogMessage(String, String)
Adds a new log catalog message to the stack of associated messages.
Parameters
-
namespace
- Log catalog message namespace.
-
messageKey
- Log catalog message key.
addLogMessage(String, String, Object) Method
public void addLogMessage(String namespace,
String messageKey,
Object argument)
Description copied from MessageCatalogException.addLogMessage(String, String, Object)
Adds a new log catalog message to the stack of associated messages.
Parameters
-
namespace
- Log catalog message namespace.
-
messageKey
- Log catalog message key.
-
argument
- Message parameter substitution argument.
addLogMessage(String, String, Object[]) Method
public void addLogMessage(String namespace,
String messageKey,
Object[] arguments)
Description copied from MessageCatalogException.addLogMessage(String, String, Object[])
Adds a new log catalog message to the stack of associated messages.
Parameters
-
namespace
- Log catalog message namespace.
-
messageKey
- Log catalog message key.
-
arguments
- Message parameter substitution arguments.
addMessage(String, String) Method
public void addMessage(String namespace,
String messageKey)
Description copied from MessageCatalogException.addMessage(String, String)
Adds a new user and log catalog message to the stack of associated messages.
Parameters
-
namespace
- User and log catalog message namespace.
-
messageKey
- User and log catalog message key.
addMessage(String, String, Object) Method
public void addMessage(String namespace,
String messageKey,
Object argument)
Description copied from MessageCatalogException.addMessage(String, String, Object)
Adds a new user catalog message to the stack of associated messages.
Parameters
-
namespace
- User and log catalog message namespace.
-
messageKey
- User and log catalog message key.
-
argument
- Message parameter substitution argument.
addMessage(String, String, Object[]) Method
public void addMessage(String namespace,
String messageKey,
Object[] arguments)
Description copied from MessageCatalogException.addMessage(String, String, Object[])
Adds a new user catalog message to the stack of associated messages.
Parameters
-
namespace
- User and log catalog message namespace.
-
messageKey
- User and log catalog message key.
-
arguments
- Message parameter substitution arguments.
addUserMessage(String, String) Method
public void addUserMessage(String namespace,
String messageKey)
Description copied from MessageCatalogException.addUserMessage(String, String)
Adds a new user catalog message to the stack of associated messages.
Parameters
-
namespace
- User catalog message namespace.
-
messageKey
- User catalog message key.
addUserMessage(String, String, Object) Method
public void addUserMessage(String namespace,
String messageKey,
Object argument)
Description copied from MessageCatalogException.addUserMessage(String, String, Object)
Adds a new user catalog message to the stack of associated messages.
Parameters
-
namespace
- User catalog message namespace.
-
messageKey
- User catalog message key.
-
argument
- Message parameter substitution argument.
addUserMessage(String, String, Object[]) Method
public void addUserMessage(String namespace,
String messageKey,
Object[] arguments)
Description copied from MessageCatalogException.addUserMessage(String, String, Object[])
Adds a new user catalog message to the stack of associated messages.
Parameters
-
namespace
- User catalog message namespace.
-
messageKey
- User catalog message key.
-
arguments
- Message parameter substitution arguments.
getEmbeddedException() Method
public Exception getEmbeddedException()
Description copied from MessageCatalogException.getEmbeddedException()
Gets the embedded exception associated with this exception.
Returns
- The embedded exception.
getLocalizedMessage() Method
public String getLocalizedMessage()
Returns the user message associated with this exception.
-
Overrides
-
Throwable.getLocalizedMessage()
Returns
- The user message associated with this exception.
getLogMessage() Method
public String getLogMessage()
Description copied from MessageCatalogException.getLogMessage()
Returns the first log catalog message associated with this exception.
Returns
- The first log catalog message associated with this exception.
getLogMessages() Method
public Iterator getLogMessages()
Description copied from MessageCatalogException.getLogMessages()
Returns an iterator over all the log catalog messages associated with
this exception.
Returns
- An iterator over all log catalog messages.
getMessage() Method
public String getMessage()
Returns the user message associated with this exception.
-
Overrides
-
Throwable.getMessage()
Returns
- The user message associated with this exception.
getUserMessage() Method
public String getUserMessage()
Description copied from MessageCatalogException.getUserMessage()
Returns the first user catalog message associated with this exception.
Returns
- The user catalog message associated with this exception.
getUserMessages() Method
public Iterator getUserMessages()
Description copied from MessageCatalogException.getUserMessages()
Returns an iterator over all the user catalog messages associated with
this exception.
Returns
- An iterator over all user catalog messages.
toString() Method
public String toString()
Returns a string representation of this exception.
-
Overrides
-
Throwable.toString()
Returns
- A string representation of this exception.