BioException.java
// license-header java merge-point
//
/**
* @author Generated by ApplicationException.vsl in andromda-java-cartridge on 08/08/2014 12:21:08-0400 Do not modify by hand!
*
* TEMPLATE: ApplicationException.vsl in andromda-java-cartridge.
* MODEL CLASS: EJB3 Demo::EJB3 Demo::org::andromda::demo::ejb3::bio::BioException
* STEREOTYPE: ApplicationException
*/
package org.andromda.demo.ejb3.bio;
import org.apache.commons.beanutils.PropertyUtils;
/**
* <p>
* TODO: Model Documentation for org.andromda.demo.ejb3.bio.BioException
* </p>
*/
public class BioException
extends Exception
{
/** The serial version UID of this class. Throwable implements Serializable so declaration not needed. */
private static final long serialVersionUID = 4375265848116317283L;
/**
* The default constructor.
*/
public BioException()
{
super();
// Avoid compiler warning from uncommented empty method
}
/**
* Constructs a new instance of BioException
*
* @param throwable the parent Throwable
*/
public BioException(Throwable throwable)
{
super(findRootCause(throwable));
}
/**
* Constructs a new instance of BioException
*
* @param messageIn the throwable message.
*/
public BioException(String messageIn)
{
super(messageIn);
}
/**
* Constructs a new instance of BioException
*
* @param messageIn the throwable message.
* @param throwable the parent of this Throwable.
*/
public BioException(String messageIn, Throwable throwable)
{
super(messageIn, findRootCause(throwable));
}
private Object[] messageArguments;
/**
* Gets the message arguments that can be used by message resources (in
* something like the presentation tier)
*
* @return messageArguments
*/
public Object[] getMessageArguments()
{
return this.messageArguments;
}
/**
* Sets the message arguments that can be used by message resources (in
* something like the presentation tier)
*
* @param messageArgumentsIn
*/
public void setMessageArguments(Object[] messageArgumentsIn)
{
this.messageArguments = messageArgumentsIn;
}
/**
* Finds the root cause of the parent exception
* by traveling up the exception tree. Performs printStackTrace if
* an exception is thrown.
* @param th Throwable to find the cause from
* @return targetException Throwable cause
*/
private static Throwable findRootCause(Throwable th)
{
if (th != null)
{
// Reflectively get any JMX or EJB exception causes.
try
{
Throwable targetException = null;
// java.lang.reflect.InvocationTargetException
// or javax.management.ReflectionException
String exceptionProperty = "targetException";
if (PropertyUtils.isReadable(th, exceptionProperty))
{
targetException = (Throwable)PropertyUtils.getProperty(th, exceptionProperty);
}
else
{
exceptionProperty = "causedByException";
//javax.ejb.EJBException
if (PropertyUtils.isReadable(th, exceptionProperty))
{
targetException = (Throwable)PropertyUtils.getProperty(th, exceptionProperty);
}
}
if (targetException != null)
{
th = targetException;
}
}
catch (Exception ex)
{
// just print the exception and continue
ex.printStackTrace();
}
if (th.getCause() != null)
{
th = th.getCause();
th = findRootCause(th);
}
}
return th;
}
}