Examples of SquirrelRuntimeException


Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        // check parameter type
        if (params.length > 0) {
            if (params.length == 1 && params[0].isAssignableFrom(eventType)) {
                hasParameter = true;
            } else {
                throw new SquirrelRuntimeException(ErrorCodes.METHOD_UNEXPECTED_PARAMETERS);
            }
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

            field = clazz.getDeclaredField(fieldName);
            if (logger.isTraceEnabled()) {
                logger.trace("found field "+fieldName+" in "+getClassNameSafe(clazz));
            }
        } catch (SecurityException e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.NOT_ALLOW_ACCESS_FIELD, getClassNameSafe(clazz), fieldName);
        } catch (NoSuchFieldException e) {
            if (clazz.getSuperclass()!=null) {
                return getField(clazz.getSuperclass(), fieldName, original);
            } else {
                throw new SquirrelRuntimeException(e, ErrorCodes.FIELD_NOT_FOUND, original.getName(), fieldName);
            }
        }
        return field;
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

            method = clazz.getDeclaredMethod(methodName, parameterTypes);
            if (logger.isTraceEnabled()) {
                logger.trace("found method "+getClassNameSafe(clazz)+"."+methodName+"("+Arrays.toString(parameterTypes)+")");
            }
        } catch (SecurityException e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.NOT_ALLOW_ACCESS_METHOD, getClassNameSafe(clazz), methodName, getParameterTypesText(parameterTypes));
        } catch (NoSuchMethodException e) {
            if (clazz.getSuperclass()!=null) {
                return getMethod(clazz.getSuperclass(), methodName, parameterTypes, original);
            } else {
                throw new SquirrelRuntimeException(e, ErrorCodes.METHOD_NOT_FOUND, original.getName(), methodName, getParameterTypesText(parameterTypes));
            }
        }
        return method;
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

    public static <T> Constructor<T> getConstructor(Class<T> type, Class<?>[] parameterTypes) {
        try {
            Constructor<T> constructor = type.getDeclaredConstructor(parameterTypes);
            return constructor;
        } catch (NoSuchMethodException e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.CONSTRUCTOR_NOT_FOUND,
                    type.getName(), Arrays.toString(parameterTypes));
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

            }
            return constructor.newInstance(args);

        } catch (Throwable t) {
            Throwable cause = (t instanceof InvocationTargetException) ? ((InvocationTargetException)t).getTargetException() : t;
            throw new SquirrelRuntimeException(cause, ErrorCodes.CONSTRUCT_NEW_INSTANCE_ERROR, getClassNameSafe(clazz), Arrays.toString(args));
        } finally {
            constructor.setAccessible(oldAccessible);
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        return get(field, null);
    }

    public static Object get(Field field, Object object) {
        if (field==null) {
            throw new SquirrelRuntimeException(ErrorCodes.FIELD_NULL);
        }
        boolean oldAccessible = field.isAccessible();
        try {
            field.setAccessible(true);
            Object value = field.get(object);
            if (logger.isTraceEnabled()) {
                logger.trace("got value '"+value+"' from field '"+field.getName()+"'");
            }
            return value;
        } catch (Exception e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.CANNOT_GET_FIELD_VALUE, field.getName());
        } finally {
            field.setAccessible(oldAccessible);
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        set(field, null, value);
    }

    public static void set(Field field, Object object, Object value) {
        if (field==null) {
            throw new SquirrelRuntimeException(ErrorCodes.FIELD_NULL);
        }
        boolean oldAccessible = field.isAccessible();
        try {
            if (logger.isTraceEnabled()) {
                logger.trace("setting field '"+field.getName()+"' to value '"+value+"'");
            }
            if (!oldAccessible) {
                if (logger.isTraceEnabled()) logger.trace("making field accessible");
                field.setAccessible(true);
            }
            field.set(object, value);
        } catch (Exception e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.CANNOT_SET_FIELD_VALUE, field.getName(), value);
        } finally {
            field.setAccessible(oldAccessible);
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        return invoke(method, target, new Object[0]);
    }

    public static Object invoke(Method method, Object target, Object[] args) {
        if (method==null) {
            throw new SquirrelRuntimeException(ErrorCodes.METHOD_NULL);
        }
        boolean oldAccessible = method.isAccessible();
        try {
            if (logger.isTraceEnabled()) {
                logger.trace("invoking '"+method.getName()+"' on '"+target+"' with "+Arrays.toString(args));
            }
            if (!method.isAccessible()) {
                logger.trace("making method accessible");
                method.setAccessible(true);
            }
            return method.invoke(target, args);
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            throw new SquirrelRuntimeException(targetException, ErrorCodes.METHOD_INVOKE_ERROR,
                    method, Arrays.toString(args), target, targetException.getCause());
        } catch (Exception e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.METHOD_INVOKE_ERROR,
                    method, Arrays.toString(args), target, e.getMessage());
        } finally {
            method.setAccessible(oldAccessible);
        }
    }
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        return false;
    }

    public static String getPackageName(final String className) {
        if (className==null || className.length() == 0)
            throw new SquirrelRuntimeException(ErrorCodes.ILLEGAL_CLASS_NAME);

        int index = className.lastIndexOf('.');
        if (index != -1)
            return className.substring(0, index);
        return "";
View Full Code Here

Examples of org.squirrelframework.foundation.exception.SquirrelRuntimeException

        return "";
    }

    public static Class<?> getClass(final String className) {
        if (className==null || className.length() == 0)
            throw new SquirrelRuntimeException(ErrorCodes.ILLEGAL_CLASS_NAME);
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException e) {
            throw new SquirrelRuntimeException(e, ErrorCodes.CLASS_NOT_FOUND, className);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.