Package org.mojavemvc.views

Examples of org.mojavemvc.views.View


    public void plainTextEntityMarshallerHandlesMarshallAnnotation() {
       
        PlainTextEntityMarshaller m = new PlainTextEntityMarshaller();
        SimplePojo entity = new SimplePojo("test");
        AnnotatedPojo marshallable = new AnnotatedPojo(entity);
        View v = m.marshall(marshallable);
        assertTrue(v instanceof PlainText);
        assertEquals(new PlainText(entity).toString(), ((PlainText)v).toString());
    }
View Full Code Here


    public void xmlEntityMarshallerHandlesMarshallAnnotation() {
       
        XMLEntityMarshaller m = new XMLEntityMarshaller();
        SimplePojo entity = new SimplePojo("test");
        AnnotatedPojo marshallable = new AnnotatedPojo(entity);
        View v = m.marshall(marshallable);
        assertTrue(v instanceof XML);
        assertEquals(new XML(entity).toString(), ((XML)v).toString());
    }
View Full Code Here

   
    @Test
    public void handleError_NullException() throws Exception {

        ErrorHandler errorHandler = new DefaultErrorHandler();
        View view = errorHandler.handleError(null, properties);

        assertTrue(view instanceof PlainText);
        PlainText stackTrace = (PlainText) view;
        assertEquals("", stackTrace.toString());
    }
View Full Code Here

    public void handleError_WithException() throws Exception {

        Exception e = new Exception("testing");
       
        ErrorHandler errorHandler = new DefaultErrorHandler();
        View view = errorHandler.handleError(e, properties);

        assertTrue(view instanceof PlainText);
        PlainText stackTrace = (PlainText) view;
        assertTrue(stackTrace.toString().startsWith("java.lang.Exception: testing"));
    }
View Full Code Here

         * which means that Atmosphere annotation processing is done after
         * the resource method is processed--in fact, it must be, as
         * org.mojavemvc.atmosphere.SuspendResponse is a possible return value
         */
       
        View view = null;
        Object entity = ctx.getActionReturnValue();
        View marshalledEntity = ctx.getMarshalledReturnValue();
       
        if (SuspendResponse.class.isAssignableFrom(entity.getClass())) {
            view = doSuspendResponse(entity, req, resp, resource, useResumeAnnotation);
            /* don't process any annotations */
            /*
 
View Full Code Here

   
    private View doSuspendResponse(Object entity, HttpServletRequest req,
            HttpServletResponse res, AtmosphereResource resource,
            boolean useResumeAnnotation) {
       
        View view = null;
        SuspendResponse<?> s = SuspendResponse.class.cast(entity);
        boolean resumeOnBroadcast = resumeOnBroadcast(s.resumeOnBroadcast(), req);

        for (AtmosphereResourceEventListener el : s.listeners()) {
            resource.addEventListener(el);
View Full Code Here

            List<ClusterBroadcastFilter> clusterBroadcastFilters,
            long delay, int waitFor,
            Class<? extends BroadcastFilter>[] filters,
            boolean writeEntity, String topic, boolean resume) {
       
        View view = null;
        AtmosphereResource resource = (AtmosphereResource) req.getAttribute(SUSPENDED_RESOURCE);
       
        Broadcaster broadcaster = resource.getBroadcaster();
        Object msg = entity;
        if (entity instanceof Broadcastable) {
View Full Code Here

        this.errorHandler = errorHandler;
    }

    public View process(String controller, String action, AppProperties properties) {

        View view;

        try {

            resolver.resolve(controller, action);
View Full Code Here

    }

    private View invokeActionMethod(Object actionController, ActionSignature actionSignature,
            Class<?> actionControllerClass) throws Exception {

        View view = null;

        Object[] args = actionSignature.getArgs(parameterMap, request.getInputStream());
        Annotation[] actionAnnotations = actionSignature.getAnnotations();

        List<Object> classInterceptors = createInterceptors(controllerDb.getInterceptorsFor(actionControllerClass));

        List<Object> methodInterceptors = createInterceptorsForAction(actionSignature, actionControllerClass);

        for (Object interceptor : classInterceptors) {

            view = invokeBeforeActionIfRequired(interceptor, actionAnnotations,
                    controllerDb.getBeforeActionMethodForInterceptor(interceptor.getClass()), args);
            if (view != null) {
                return view;
            }
        }

        for (Object interceptor : methodInterceptors) {

            view = invokeBeforeActionIfRequired(interceptor, actionAnnotations,
                    controllerDb.getBeforeActionMethodForInterceptor(interceptor.getClass()), args);
            if (view != null) {
                return view;
            }
        }

        view = invokeBeforeActionIfRequired(actionController, actionAnnotations,
                controllerDb.getBeforeActionMethodFor(actionControllerClass), args);

        if (view != null) {
            return view;
        }

        FastClass actionFastClass = controllerDb.getFastClass(actionControllerClass);
        Object entity = actionFastClass.invoke(actionSignature.fastIndex(), actionController, args);
        View marshalledEntity = actionSignature.marshall(entity);
        view = marshalledEntity;
        logger.debug("invoked " + actionSignature.methodName() + " for " + actionControllerClass.getName());

        View afterActionView = invokeAfterActionIfRequired(actionController, actionAnnotations,
                controllerDb.getAfterActionMethodFor(actionControllerClass),
                args, entity, marshalledEntity);

        if (afterActionView != null) {
            view = afterActionView;
        }

        for (Object interceptor : methodInterceptors) {

            View interceptorView = invokeAfterActionIfRequired(interceptor, actionAnnotations,
                    controllerDb.getAfterActionMethodForInterceptor(interceptor.getClass()),
                    args, entity, marshalledEntity);
            if (interceptorView != null) {
                view = interceptorView;
                break;
            }
        }

        for (Object interceptor : classInterceptors) {

            View interceptorView = invokeAfterActionIfRequired(interceptor, actionAnnotations,
                    controllerDb.getAfterActionMethodForInterceptor(interceptor.getClass()),
                    args, entity, marshalledEntity);
            if (interceptorView != null) {
                view = interceptorView;
                break;
View Full Code Here

    private View invokeBeforeOrAfterActionIfRequired(Object instance, Annotation[] actionAnnotations,
            ActionSignature interceptorMethod, Object[] actionArgs, Object entity, View marshalledEntity,
            String which) throws Exception {

        View view = null;

        if (interceptorMethod != null) {
            /*
             * we've already validated that there are no method parameters when
             * creating the controller database
View Full Code Here

TOP

Related Classes of org.mojavemvc.views.View

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.