Package org.mojavemvc.marshalling

Examples of org.mojavemvc.marshalling.EntityMarshaller


            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,
                fastClass.getJavaClass().getName());
        EntityMarshaller viewMarshaller = getViewEntityMarshaller(actionMethod,
                fastClass.getJavaClass().getName());

        int fastIndex = fastClass.getIndex(actionMethod.getName(), actionMethod.getParameterTypes());

        ActionSignature sig = new HttpMethodActionSignature(httpMethod, fastIndex, actionMethod.getName(),
View Full Code Here


            Map<String, ActionSignature> actionMap, FastClass fastClass,
            String controllerVariable, boolean isDefaultController) {

        validateActionReturnType(method, fastClass.getJavaClass().getName());
       
        EntityMarshaller paramMarshaller = getParamEntityMarshaller(method, fastClass.getJavaClass().getName());
        EntityMarshaller viewMarshaller = getViewEntityMarshaller(method, fastClass.getJavaClass().getName());

        int fastIndex = fastClass.getIndex(method.getName(), method.getParameterTypes());

        ActionSignature sig = new BaseActionSignature(fastIndex, method.getName(), method.getParameterTypes(),
                method.getParameterAnnotations(), method.getDeclaredAnnotations(),
View Full Code Here

        addRoute(method, fastClass.getJavaClass().getName(), controllerVariable, action, isDefaultController);
    }

    private EntityMarshaller getParamEntityMarshaller(Method method, String className) {
       
        EntityMarshaller paramMarshaller = new DefaultEntityMarshaller();
        Annotation[][] paramAnnotations = method.getParameterAnnotations();
        List<Entity> entityAnnotations = new ArrayList<Entity>();
        for (Annotation[] annotationsForParam : paramAnnotations) {
            for (Annotation annotation : annotationsForParam) {
                if (annotation instanceof Entity) {
                    entityAnnotations.add((Entity)annotation);
                }
            }
        }
        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);
            if (marshaller != null) {
                paramMarshaller = marshaller;
            } else {
                logger.error("could not find parameter entity marshaller for content type "
                        + contentType + " for action " + method.getName() + " in controller "
View Full Code Here

        return paramMarshaller;
    }
   
    private EntityMarshaller getViewEntityMarshaller(Method method, String className) {
       
        EntityMarshaller viewMarshaller = new DefaultEntityMarshaller();
       
        Returns returnsAnnotation = method.getAnnotation(Returns.class);
        if (returnsAnnotation != null) {
            String contentType = returnsAnnotation.value();
            EntityMarshaller marshaller = entityMarshallerMap.get(contentType);
            if (marshaller != null) {
                viewMarshaller = marshaller;
            } else {
                logger.error("could not find view entity marshaller for content type "
                        + contentType + " for action " + method.getName() + " in controller "
View Full Code Here

            String controllerVariable, boolean isDefaultController) {

        validateActionOccursOnlyOnce(map, annotationClass, controllerClass);
        validateActionReturnType(method, controllerClass.getName());
       
        EntityMarshaller paramMarshaller = getParamEntityMarshaller(method, controllerClass.getName());
        EntityMarshaller viewMarshaller = getViewEntityMarshaller(method, controllerClass.getName());

        int fastIndex = fastClass.getIndex(method.getName(), method.getParameterTypes());

        ActionSignature sig = new DefaultActionSignature(fastIndex, method.getName(), method.getParameterTypes(),
                method.getParameterAnnotations(), method.getDeclaredAnnotations(),
View Full Code Here

   
    private void addToEntityMarshallerMap(Class<? extends EntityMarshaller> customMarshaller,
            Map<String, EntityMarshaller> marshallerMap) {
       
        Injector injector = (Injector)context.getAttribute(GuiceInitializer.KEY);
        EntityMarshaller marshaller = null;
        try {
            marshaller = injector.getInstance(customMarshaller);
        } catch (Exception e) {
            logger.error("error contructing entity marshaller " + customMarshaller.getName(), e);
        }
View Full Code Here

TOP

Related Classes of org.mojavemvc.marshalling.EntityMarshaller

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.