Package org.strecks.exceptions

Examples of org.strecks.exceptions.ApplicationRuntimeException


  public static void checkParameterTypeLength(Method m, int parameterCount)
  {
    Class<?>[] parameterTypes = m.getParameterTypes();
    if (parameterTypes.length != parameterCount)
    {
      throw new ApplicationRuntimeException("Method " + m.getName() + " in class " + m.getDeclaringClass()
          + " must have " + parameterCount + " parameter(s)");
    }
  }
View Full Code Here


    {
      method = clazz.getMethod(methodName);
    }
    catch (IllegalArgumentException e)
    {
      throw new ApplicationRuntimeException("Unable to retrieve method " + methodName + "() of class "
          + clazz.getName(), e);
    }
    catch (SecurityException e)
    {
      throw new ApplicationRuntimeException(
          "Security violation " + methodName + "() of class " + clazz.getName(), e);
    }
    catch (NoSuchMethodException e)
    {
      throw new ApplicationRuntimeException("No method " + methodName + "() of class " + clazz.getName(), e);
    }
    return method;
  }
View Full Code Here

    {
      Object invoke = method.invoke(o);

      if (returnType != null && invoke != null && !invoke.getClass().isAssignableFrom(returnType))
      {
        throw new ApplicationRuntimeException("Unable to cast result " + invoke + " of method "
            + method.getName() + "() of class " + o.getClass().getName() + " to return type " + returnType);
      }

      return (T) invoke;
    }
    catch (IllegalArgumentException e)
    {
      throw new ApplicationRuntimeException("Unable to invoke method " + method.getName() + " of class "
          + o.getClass(), e);
    }
    catch (SecurityException e)
    {
      throw new ApplicationRuntimeException("Security violation " + method.getName() + " of class "
          + o.getClass(), e);
    }
    catch (IllegalAccessException e)
    {
      throw new ApplicationRuntimeException("Security violation " + method.getName() + " of class "
          + o.getClass(), e);
    }
    catch (InvocationTargetException e)
    {

      Throwable targetException = e.getTargetException();
      Throwable nested = null;

      if (targetException instanceof Exception)
        nested = targetException;
      else
        nested = e;

      throw new ApplicationRuntimeException("Invocation target exception for " + method.getName() + " of class "
          + o.getClass(), nested);

    }
  }
View Full Code Here

    {
      c = Class.forName(className, true, ReflectHelper.class.getClassLoader());
    }
    catch (ClassNotFoundException e)
    {
      throw new ApplicationRuntimeException("Unable to create new instance of " + className
          + " as class cannot be located", e);
    }

    return createInstance(c, type);
  }
View Full Code Here

      Object newInstance = clazz.newInstance();

      if (!(type.isAssignableFrom(newInstance.getClass())))
      {
        throw new ApplicationRuntimeException("Class " + clazz.getName()
            + " was instantiated but was not an instance of the type " + type);
      }

      return (T) newInstance;
    }
    catch (InstantiationException e)
    {
      throw new ApplicationRuntimeException("Unable to create new instance of " + clazz
          + " as class cannot be instantiated", e);
    }
    catch (IllegalAccessException e)
    {
      throw new ApplicationRuntimeException("Illegal access in attempting to create instance of " + clazz, e);
    }
  }
View Full Code Here

      propertyType = propertyDescriptor.getPropertyType();

    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Unable to read property descriptor for bean "
          + containingBean.getClass().getName() + ", property " + beanPropertyName, e);
    }
    return propertyType;
  }
View Full Code Here

        // CollectionUtils.getMap(collection);
      }
      else
        if (property != null)
        {
          throw new ApplicationRuntimeException("Property " + getBeanLookupExpression()
              + " should evaluate to a java.util.Map or java.util.Collection, not a "
              + property.getClass().getName());
        }
    }
    return map;
View Full Code Here

      // properties with bind annotation must be Strings
      propertyValue = PropertyUtils.getProperty(containingBean, propertyName);
    }
    catch (IllegalAccessException e)
    {
      throw new ApplicationRuntimeException("Illegal getter method access attempted from "
          + containingBean.getClass() + " using property expression " + propertyName, e);
    }
    catch (NoSuchMethodException e)
    {
      throw new ApplicationRuntimeException("Required getter methods not found from " + containingBean.getClass()
          + " using property expression " + propertyName, e);
    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Unable to read property for bean "
          + containingBean.getClass().getName() + ", property " + propertyName, e);
    }
    return propertyValue;

  }
View Full Code Here

      // properties with bind annotation must be Strings
      descriptor = PropertyUtils.getPropertyDescriptor(containingBean, propertyName);
    }
    catch (Exception e)
    {
      throw new ApplicationRuntimeException("Unable to read property descriptor for bean "
          + containingBean.getClass().getName() + ", property " + propertyName, e);
    }
    return descriptor;

  }
View Full Code Here

        // property does not exist or is null
        targetBean = null;
      }
      catch (IllegalAccessException e)
      {
        throw new ApplicationRuntimeException("Illegal getter method access attempted from "
            + target.getClass() + " using expression " + beanLocatingExpression, e);
      }
      catch (NoSuchMethodException e)
      {
        throw new ApplicationRuntimeException("Required getter methods not found from " + target.getClass()
            + " using expression " + beanLocatingExpression, e);
      }
      catch (Exception e)
      {
        throw new ApplicationRuntimeException("Unable to obtain bean from " + target.getClass()
            + " using expression " + beanLocatingExpression, e);
      }
    }
    else
    {
View Full Code Here

TOP

Related Classes of org.strecks.exceptions.ApplicationRuntimeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.