All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xins.client.XINSCallException Maven / Gradle / Ivy

There is a newer version: 3.0
Show newest version
/*
 * $Id: XINSCallException.java,v 1.11 2006/08/28 09:12:30 agoubard Exp $
 *
 * Copyright 2003-2006 Orange Nederland Breedband B.V.
 * See the COPYRIGHT file for redistribution and use restrictions.
 */
package org.xins.client;

import org.xins.common.MandatoryArgumentChecker;


import org.xins.common.service.CallException;
import org.xins.common.service.TargetDescriptor;

/**
 * XINS-specific call exception.
 *
 * @version $Revision: 1.11 $ $Date: 2006/08/28 09:12:30 $
 * @author Ernst de Haan
 *
 * @since XINS 1.0.0
 */
public abstract class XINSCallException extends CallException {

   //-------------------------------------------------------------------------
   // Class functions
   //-------------------------------------------------------------------------

   /**
    * Checks the mandatory arguments for the constructor and then returns the
    * short reason.
    *
    * @param shortReason
    *    the short reason, cannot be null.
    *
    * @param result
    *    the call result, cannot be null.
    *
    * @return
    *    the short reason as given in the argument shortReason,
    *    never null.
    *
    * @throws IllegalArgumentException
    *    if shortReason == null || result == null
    */
   private static final String checkArguments(String         shortReason,
                                              XINSCallResult result)
   throws IllegalArgumentException {

      // Check preconditions
      MandatoryArgumentChecker.check("shortReason", shortReason,
                                     "result",      result);

      return shortReason;
   }


   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------
   //-------------------------------------------------------------------------
   // Constructors
   //-------------------------------------------------------------------------

   /**
    * Constructs a new XINSCallException based on a short reason,
    * the original request, target called, call duration, detail message and
    * cause exception.
    *
    * @param shortReason
    *    the short reason, cannot be null.
    *
    * @param request
    *    the original request, cannot be null.
    *
    * @param target
    *    descriptor for the target that was attempted to be called, cannot be
    *    null.
    *
    * @param duration
    *    the call duration in milliseconds, must be >= 0.
    *
    * @param detail
    *    a detailed description of the problem, can be null if
    *    there is no more detail.
    *
    * @param cause
    *    the cause exception, can be null.
    *
    * @throws IllegalArgumentException
    *    if shortReason == null
    *          || request == null
    *          || target == null
    *          || duration < 0.
    */
   XINSCallException(String           shortReason,
                     XINSCallRequest  request,
                     TargetDescriptor target,
                     long             duration,
                     String           detail,
                     Throwable        cause)
   throws IllegalArgumentException {

      // Call superconstructor
      super(shortReason, request, target, duration, detail, cause);
   }

   /**
    * Constructs a new XINSCallException based on a short reason,
    * a XINS call result, detail message and cause exception.
    *
    * @param shortReason
    *    the short reason, cannot be null.
    *
    * @param result
    *    the call result, cannot be null.
    *
    * @param detail
    *    a detailed description of the problem, can be null if
    *    there is no more detail.
    *
    * @param cause
    *    the cause exception, can be null.
    *
    * @throws IllegalArgumentException
    *    if shortReason == null || result == null.
    */
   XINSCallException(String           shortReason,
                     XINSCallResult   result,
                     String           detail,
                     Throwable        cause)
   throws IllegalArgumentException {

      // Call superconstructor
      super(checkArguments(shortReason, result),
            (result == null) ? null : result.getRequest(),
            (result == null) ? null : result.getSucceededTarget(),
            (result == null) ?   0L : result.getDuration(),
            detail,
            cause);
   }


   //-------------------------------------------------------------------------
   // Fields
   //-------------------------------------------------------------------------

   //-------------------------------------------------------------------------
   // Methods

   //-------------------------------------------------------------------------
   // Methods
   //-------------------------------------------------------------------------
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy