psdi.util

Class MXExceptionMediator

  • java.lang.Object
    • psdi.util.MXExceptionMediator


  • public class MXExceptionMediator
    extends java.lang.Object
    This static class allows Maximo extensions to plugin exception handling for exception classes that are not subclasses of MXException. The MXExceptionMediator is supposed to be called from Maximo code to: - get translated/localized exception messages - convert exceptions into MXExceptions To plugin exception handling for a new Exception class: - create a new class that implements the MXExceptionAdapter interface - register an instance of the new class with the MXExceptionMediator by calling the MXExceptionMediator.registerExceptionAdapter() method.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String getMessage(java.lang.Throwable throwable, java.lang.String langCode)
      Retrieves the localized/translated exception message for the specified exception and language code.
      static void registerExceptionAdapter(java.lang.Class exceptionClass, MXExceptionAdapter exceptionAdapter)
      Registers a new MXExceptionAdapter with MXExceptionMediator.
      static MXException toMXException(java.lang.Throwable throwable)
      Converts the specified exception into an MXException.
      static void unregisterExceptionAdapter(java.lang.Class exceptionClass)
      Unregisters an MXExceptionAdapter
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MXExceptionMediator

        public MXExceptionMediator()
    • Method Detail

      • registerExceptionAdapter

        public static void registerExceptionAdapter(java.lang.Class exceptionClass,
                                                    MXExceptionAdapter exceptionAdapter)
                                             throws MXException
        Registers a new MXExceptionAdapter with MXExceptionMediator. The new MXExceptionAdapter must satisfy the following conditions: - handle a subclass of java.lang.Exception - not handle java.lang.Exception or java.lang.RuntimeException If another MXExceptionAdapter is already registered to handle the same exception class, then the registration fails.
        Parameters:
        exceptionClass - The exception class handled by the specified MXExceptionAdapter
        exceptionAdapter - The new MXExceptionAdapter
        Throws:
        MXException
      • unregisterExceptionAdapter

        public static void unregisterExceptionAdapter(java.lang.Class exceptionClass)
                                               throws MXException
        Unregisters an MXExceptionAdapter
        Parameters:
        exceptionClass - The exception class handled by the MXExceptionAdapter to be unregistered
        Throws:
        MXException
      • getMessage

        public static java.lang.String getMessage(java.lang.Throwable throwable,
                                                  java.lang.String langCode)
        Retrieves the localized/translated exception message for the specified exception and language code. If the specified exception is not a subclass of java.lang.Exception or if there is no MXExceptionAdapter that can handle the exception, this method returns throwable.getLocalizedMessage().
        Parameters:
        throwable - The exception for which to retrieve the message.
        langCode - The Maximo language code for which to retrieve the message.
      • toMXException

        public static MXException toMXException(java.lang.Throwable throwable)
        Converts the specified exception into an MXException. This method return null if the specified exception is not a subclass of java.lang.Exception or if there is no MXExceptionAdapter that can handle the exception.
        Parameters:
        throwable - The exception to be converted.