org.apache.wsrp4j.exception
Class WSRPXHelper

java.lang.Object
  extended byorg.apache.wsrp4j.exception.WSRPXHelper

public class WSRPXHelper
extends java.lang.Object

Handles the throwing of exceptions. Instead of calling throw(new WSRPException("exception text")) simply type ExceptionHelper throwX(1234) So the appropriate messages can be handled in a central place. Also the Exceptions will be logged


Constructor Summary
WSRPXHelper()
           
 
Method Summary
protected static WSRPException getException(int errorCode, java.lang.Throwable t)
          Returns an Exception.
static void handleWSRPException(WSRPException exception)
          This method translates a WSRP exception into an apropriate WSRP fault according to the error code
static void handleWSRPFault(Logger logger, java.rmi.RemoteException wsrpFault)
          This method translates a WSRP fault into a WSRP exception containing a corresponding error code and logs the occurence of the exception
static void throwX(int errorCode)
          Throws a new exception with a specific message identified by an error code without logging
static void throwX(int errorCode, java.lang.Throwable t)
          Throws a new exception with a specific message identified by an error code without logging
static void throwX(Logger logger, int logLevel, java.lang.String method, int errorCode)
          Throws a new exception with a specific message identified by an error code and logs the exception to a logger.
static void throwX(Logger logger, int logLevel, java.lang.String method, int errorCode, java.lang.Throwable t)
          Throws a new exception with a specific message identified by an error code and logs the exception to a logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSRPXHelper

public WSRPXHelper()
Method Detail

throwX

public static void throwX(int errorCode)
                   throws WSRPException
Throws a new exception with a specific message identified by an error code without logging

Parameters:
errorCode - integer specifying an error message
Throws:
WSRPException

throwX

public static void throwX(int errorCode,
                          java.lang.Throwable t)
                   throws WSRPException
Throws a new exception with a specific message identified by an error code without logging

Parameters:
errorCode - integer specifying an error message
t - the nested exception
Throws:
WSRPException

throwX

public static void throwX(Logger logger,
                          int logLevel,
                          java.lang.String method,
                          int errorCode)
                   throws WSRPException
Throws a new exception with a specific message identified by an error code and logs the exception to a logger.

Parameters:
logger - an appropriate logger
logLevel - requested logging level (ERROR,WARN,INFO, TRACE_LOW, TRACE_MEDIUM, TRACE_HIGH)
method - the method in that an Exception is thrown
errorCode - integer specifying an error message
Throws:
WSRPException

throwX

public static void throwX(Logger logger,
                          int logLevel,
                          java.lang.String method,
                          int errorCode,
                          java.lang.Throwable t)
                   throws WSRPException
Throws a new exception with a specific message identified by an error code and logs the exception to a logger.

Parameters:
logger - an appropriate logger
logLevel - requested logging level (ERROR,WARN,INFO, TRACE_LOW, TRACE_MEDIUM, TRACE_HIGH)
method - the method in that an Exception is thrown
errorCode - integer specifying an error message
t - the nested exception
Throws:
WSRPException

handleWSRPException

public static void handleWSRPException(WSRPException exception)
                                throws java.rmi.RemoteException
This method translates a WSRP exception into an apropriate WSRP fault according to the error code

Parameters:
exception - the WSRPException to be translated
Throws:
java.rmi.RemoteException - the translated fault

handleWSRPFault

public static void handleWSRPFault(Logger logger,
                                   java.rmi.RemoteException wsrpFault)
                            throws WSRPException
This method translates a WSRP fault into a WSRP exception containing a corresponding error code and logs the occurence of the exception

Parameters:
logger - the logger to be used
wsrpFault - the fault to be translated
Throws:
WSRPException - this is the translated exception

getException

protected static WSRPException getException(int errorCode,
                                            java.lang.Throwable t)
Returns an Exception. The type of the Exception depends on the error code that is passed to the method.

Parameters:
errorCode - integer specifying an error message
Returns:
Exception. The type depends on the error code