Package org.mojavemvc.exception

Examples of org.mojavemvc.exception.ConfigurationException


     */
    public ActionSignature getActionMethodSignature(Class<?> controllerClass, String action) {

        Map<String, ActionSignature> actionMap = controllerClassToActionMap.get(controllerClass);
        if (actionMap == null) {
            throw new ConfigurationException("no actions defined for " + controllerClass.getName());
        }
        return actionMap.get(action);
    }
View Full Code Here


            if (annot instanceof StatelessController || annot instanceof StatefulController
                    || annot instanceof SingletonController) {

                if (controllerAnnotation != null) {
                    throw new ConfigurationException("controller " + controllerClass.getName()
                            + " is annotated with multiple controller annotations");
                }

                controllerAnnotation = annot;
            }
        }

        if (controllerAnnotation == null) {
            throw new ConfigurationException("controller " + controllerClass.getName()
                    + " not annotated with a controller annotation");
        }

        return controllerAnnotation;
    }
View Full Code Here

         * check if this controller variable already exists; if so raise an
         * exception
         */
        Class<?> existing = controllerClassesMap.get(controllerClass);
        if (existing != null) {
            throw new ConfigurationException("a controller variable with the value " + controllerVariable
                    + " already exists");
        }
        controllerClassesMap.put(controllerVariable, controllerClass);
        checkForInitController(controllerClass);
        boolean isDefaultController = checkForDefaultController(controllerClass);
View Full Code Here

        Annotation annot = controllerClass.getAnnotation(Init.class);
        if (annot != null) {
            /* do some validation */
            annot = controllerClass.getAnnotation(SingletonController.class);
            if (annot == null) {
                throw new ConfigurationException("only a @" + SingletonController.class.getSimpleName()
                        + " can be annotated with @" + Init.class.getSimpleName());
            }
            initControllers.add(controllerClass);
        }
    }
View Full Code Here

    private boolean checkForDefaultController(Class<?> controllerClass) {

        Annotation annot = controllerClass.getAnnotation(DefaultController.class);
        if (annot != null) {
            if (defaultControllerClass != null) {
                throw new ConfigurationException("only one controller class can be annotated with @"
                        + DefaultController.class.getSimpleName());
            }
            defaultControllerClass = controllerClass;
            return true;
        }
View Full Code Here

         */
        if (actionMap.isEmpty() && httpMethodActionMap.isEmpty()
                && controllerClassToDefaultActionMap.get(controllerClass) == null
                && controllerClassToAfterConstructMap.get(controllerClass) == null) {

            throw new ConfigurationException("controller " + controllerClass.getName()
                    + " does not contain any actions or after-construct methods");
        }

        controllerClassToActionMap.put(controllerClass, actionMap);
        controllerClassToActionInterceptorsMap.put(controllerClass, actionInterceptorsMap);
View Full Code Here

        validateActionReturnType(actionMethod, fastClass.getJavaClass().getName());

        ActionSignature existingActionSignature = httpMethodActionMap.get(httpMethod);
        if (existingActionSignature != null) {

            throw new ConfigurationException("mulitple action methods for " + httpMethod + " found; "
                    + "only one action method per HTTP method type is allowed in " +
                    fastClass.getJavaClass().getName());
        }
       
        EntityMarshaller paramMarshaller = getParamEntityMarshaller(actionMethod,
View Full Code Here

            }
        }
        if (!entityAnnotations.isEmpty()) {
           
            if (entityAnnotations.size() > 1) {
                throw new ConfigurationException("action " + method.getName() + " in controller "
                        + className + " has more than one " + Entity.class.getName() + " annotation");
            }
           
            Expects expectsAnn = method.getAnnotation(Expects.class);
            if (expectsAnn == null) {
                throw new ConfigurationException("action " + method.getName() + " in controller "
                        + className + " has an " + Entity.class.getName() + " annotation, but no "
                        + Expects.class.getName() + " exists");
            }
            String contentType = expectsAnn.value();
            EntityMarshaller marshaller = entityMarshallerMap.get(contentType);
View Full Code Here

    private void validateActionReturnType(Method actionMethod, String className) {

        Class<?> returnType = actionMethod.getReturnType();
        if (returnType.equals(Void.TYPE)) {

            throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
                    + className + " must return " + View.class.getName() + " or one of its subtypes, " +
                            "or an object to be marshalled, but not void");
           
        } else if (!View.class.isAssignableFrom(returnType) &&
                actionMethod.getAnnotation(Returns.class) == null) {
           
            throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
                    + className + " does not return a " + View.class.getName() + " or one of its subtypes " +
                            "and does not specify a @" + Returns.class.getName() + " annotation");
           
        } else if (View.class.isAssignableFrom(returnType) &&
                actionMethod.getAnnotation(Returns.class) != null) {
           
            throw new ConfigurationException("action " + actionMethod.getName() + " in controller "
                    + className + " returns a " + View.class.getName() + " or one of its subtypes " +
                            "and specifies a @" + Returns.class.getName() + " annotation");
        }
    }
View Full Code Here

    }
   
    private void validateParamPath(String paramPath, Method method, String controllerName) {
       
        if (paramPath == null || paramPath.trim().length() == 0) {
            throw new ConfigurationException("Param path for method " + method.getName() +
                    " in controller " + controllerName + " is empty");
        }
       
        String[] params = ParamPathHelper.getParamNamesFrom(paramPath);
        String[] methodParams = ParamPathHelper.getParamNamesFrom(method);

        if (params.length > 0) {
            Set<String> paramsSet = new HashSet<String>(Arrays.asList(params));
            Set<String> methodParamsSet = new HashSet<String>(Arrays.asList(methodParams));
            if (!methodParamsSet.containsAll(paramsSet)) {
                throw new ConfigurationException("Param path " + paramPath + " for method " + method.getName() +
                        " in controller " + controllerName + " contains params not found in the method params");
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.mojavemvc.exception.ConfigurationException

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.