Package org.apache.tapestry.internal.services

Examples of org.apache.tapestry.internal.services.HeartbeatImpl


    @Test
    public void trigger_immediate()
    {
        FormSupport support = mockFormSupport();
        ComponentResources resources = mockComponentResources();
        Heartbeat heartbeat = new HeartbeatImpl();
        Request request = mockRequest();

        String elementName = "myname";

        train_getParameter(request, elementName, "login");

        replay();

        heartbeat.begin();

        Submit submit = new Submit(request);

        submit.setup(resources, support, heartbeat);
        submit.setDefer(false);

        submit.processSubmission(support, elementName);

        verify();

        expect(resources.triggerEvent(Submit.SELECTED_EVENT, null, null)).andReturn(false);

        replay();

        heartbeat.end();

        verify();

    }
View Full Code Here


    @Test
    public void trigger_immediate()
    {
        FormSupport support = newFormSupport();
        ComponentResources resources = mockComponentResources();
        Heartbeat heartbeat = new HeartbeatImpl();

        String elementName = "myname";

        train_getParameterValue(support, elementName, "login");

        replay();

        heartbeat.begin();

        Submit submit = new Submit();

        submit.setup(resources, support, heartbeat);
        submit.setDefer(false);

        submit.processSubmission(support, elementName);

        verify();

        expect(resources.triggerEvent(Submit.SELECTED_EVENT, null, null)).andReturn(false);

        replay();

        heartbeat.end();

        verify();

    }
View Full Code Here

    @Test
    public void trigger_immediate()
    {
        FormSupport support = mockFormSupport();
        ComponentResources resources = mockComponentResources();
        Heartbeat heartbeat = new HeartbeatImpl();
        Request request = mockRequest();

        String elementName = "myname";

        train_getParameter(request, elementName, "login");

        replay();

        heartbeat.begin();

        Submit submit = new Submit(request);

        submit.setup(resources, support, heartbeat);
        submit.setDefer(false);

        submit.processSubmission(support, elementName);

        verify();

        expect(resources.triggerEvent(Submit.SELECTED_EVENT, null, null)).andReturn(false);

        replay();

        heartbeat.end();

        verify();
    }
View Full Code Here

                environment.pop(Heartbeat.class).end();
            }

            public void setup(Environment environment)
            {
                HeartbeatImpl heartbeat = new HeartbeatImpl();

                heartbeat.begin();

                environment.push(Heartbeat.class, heartbeat);
            }
        });
View Full Code Here

        _formSupport = new FormSupportImpl(_paramLookup);

        _environment.push(ValidationTracker.class, _tracker);
        _environment.push(FormSupport.class, _formSupport);

        Heartbeat heartbeat = new HeartbeatImpl();

        _environment.push(Heartbeat.class, heartbeat);

        heartbeat.begin();

        try
        {
            final Holder<ActionResponseGenerator> holder = Holder.create();

            ComponentEventHandler handler = new ComponentEventHandler()
            {
                public boolean handleResult(Object result, Component component,
                        String methodDescription)
                {
                    if (result instanceof Boolean) return ((Boolean) result);

                    holder.put(_eventResultProcessor.processComponentEvent(
                            result,
                            component,
                            methodDescription));

                    return true; // Abort other event processing.
                }
            };

            _resources.triggerEvent(PREPARE, context, handler);

            if (holder.hasValue()) return holder.get();

            // TODO: Ajax stuff will eventually mean there are multiple values for this parameter
            // name

            String actionsBase64 = _paramLookup.getParameter(FORM_DATA);

            try
            {
                ObjectInputStream ois = new Base64ObjectInputStream(actionsBase64);

                while (true)
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    Component component = _source.getComponent(componentId);

                    action.execute(component);
                }
            }
            catch (EOFException ex)
            {
                // Expected.
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }

            heartbeat.end();

            ValidationTracker tracker = _environment.peek(ValidationTracker.class);

            // Let the listeners peform any final validations
View Full Code Here

        _formSupport = new FormSupportImpl(_paramLookup);

        _environment.push(ValidationTracker.class, _tracker);
        _environment.push(FormSupport.class, _formSupport);

        Heartbeat heartbeat = new HeartbeatImpl();

        _environment.push(Heartbeat.class, heartbeat);

        heartbeat.begin();

        try
        {
            final Holder<ActionResponseGenerator> holder = Holder.create();

            ComponentEventHandler handler = new ComponentEventHandler()
            {
                public boolean handleResult(Object result, Component component,
                        String methodDescription)
                {
                    if (result instanceof Boolean)
                        return ((Boolean) result);

                    holder.put(_eventResultProcessor.processComponentEvent(
                            result,
                            component,
                            methodDescription));

                    return true; // Abort other event processing.
                }
            };

            _resources.triggerEvent(PREPARE, context, handler);

            if (holder.hasValue())
                return holder.get();

            // TODO: Ajax stuff will eventually mean there are multiple values for this parameter
            // name

            String actionsBase64 = _paramLookup.getParameter(FORM_DATA);

            try
            {
                ObjectInputStream ois = new Base64ObjectInputStream(actionsBase64);

                while (true)
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    Component component = _source.getComponent(componentId);

                    action.execute(component);
                }
            }
            catch (EOFException ex)
            {
                // Expected.
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }

            heartbeat.end();

            ValidationTracker tracker = _environment.peek(ValidationTracker.class);

            // Let the listeners peform any final validations
View Full Code Here

        configuration.add("Heartbeat", new PageRenderCommand()
        {
            public void setup(Environment environment)
            {
                HeartbeatImpl heartbeat = new HeartbeatImpl();

                heartbeat.begin();

                environment.push(Heartbeat.class, heartbeat);
            }

            public void cleanup(Environment environment)
View Full Code Here

        _formSupport = new FormSupportImpl(_paramLookup);

        _environment.push(ValidationTracker.class, _tracker);
        _environment.push(FormSupport.class, _formSupport);

        Heartbeat heartbeat = new HeartbeatImpl();

        _environment.push(Heartbeat.class, heartbeat);

        heartbeat.begin();

        try
        {
            final Holder<ActionResponseGenerator> holder = Holder.create();

            ComponentEventHandler handler = new ComponentEventHandler()
            {
                public boolean handleResult(Object result, Component component,
                        String methodDescription)
                {
                    if (result instanceof Boolean) return ((Boolean) result);

                    holder.put(_eventResultProcessor.processComponentEvent(
                            result,
                            component,
                            methodDescription));

                    return true; // Abort other event processing.
                }
            };

            _resources.triggerEvent(PREPARE, context, handler);

            if (holder.hasValue()) return holder.get();

            // TODO: Ajax stuff will eventually mean there are multiple values for this parameter
            // name

            String actionsBase64 = _paramLookup.getParameter(FORM_DATA);

            try
            {
                ObjectInputStream ois = new Base64ObjectInputStream(actionsBase64);

                while (true)
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    Component component = _source.getComponent(componentId);

                    action.execute(component);
                }
            }
            catch (EOFException ex)
            {
                // Expected.
            }
            catch (Exception ex)
            {
                throw new RuntimeException(ex);
            }

            heartbeat.end();

            ValidationTracker tracker = _environment.peek(ValidationTracker.class);

            // Let the listeners peform any final validations
View Full Code Here

        _formSupport = new FormSupportImpl();

        _environment.push(ValidationTracker.class, _tracker);
        _environment.push(FormSupport.class, _formSupport);

        Heartbeat heartbeat = new HeartbeatImpl();

        _environment.push(Heartbeat.class, heartbeat);

        heartbeat.begin();

        try
        {
            ComponentResultProcessorWrapper callback = new ComponentResultProcessorWrapper(_eventResultProcessor);

            _resources.triggerEvent(PREPARE_FOR_SUBMIT, context, callback);

            if (callback.isAborted()) return true;

            _resources.triggerEvent(PREPARE, context, callback);

            if (callback.isAborted()) return true;

            // TODO: Ajax stuff will eventually mean there are multiple values for this parameter
            // name

            String actionsBase64 = _request.getParameter(FORM_DATA);

            ObjectInputStream ois = null;

            Component component = null;

            try
            {
                ois = new Base64ObjectInputStream(actionsBase64);

                while (true)
                {
                    String componentId = ois.readUTF();
                    ComponentAction action = (ComponentAction) ois.readObject();

                    component = _source.getComponent(componentId);

                    action.execute(component);

                    component = null;
                }
            }
            catch (EOFException ex)
            {
                // Expected
            }
            catch (Exception ex)
            {
                Location location = component == null ? null : component.getComponentResources().getLocation();

                throw new TapestryException(ex.getMessage(), location, ex);
            }
            finally
            {
                TapestryInternalUtils.close(ois);
            }

            heartbeat.end();

            ValidationTracker tracker = _environment.peek(ValidationTracker.class);

            // Let the listeners peform any final validations
View Full Code Here

    @Test
    public void trigger_immediate()
    {
        FormSupport support = mockFormSupport();
        ComponentResources resources = mockComponentResources();
        Heartbeat heartbeat = new HeartbeatImpl();
        Request request = mockRequest();

        String elementName = "myname";

        train_getParameter(request, elementName, "login");

        replay();

        heartbeat.begin();

        Submit submit = new Submit(request);

        submit.setup(resources, support, heartbeat);
        submit.setDefer(false);

        submit.processSubmission(elementName);

        verify();

        expect(resources.triggerEvent(Submit.SELECTED_EVENT, null, null)).andReturn(false);

        replay();

        heartbeat.end();

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.internal.services.HeartbeatImpl

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.