001// Copyright 2009, 2011 Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry5.internal.services;
016
017import java.io.IOException;
018
019import org.apache.tapestry5.beanmodel.services.*;
020import org.apache.tapestry5.services.ComponentEventRequestHandler;
021import org.apache.tapestry5.services.ComponentEventRequestParameters;
022import org.apache.tapestry5.services.ComponentRequestHandler;
023import org.apache.tapestry5.services.PageRenderRequestHandler;
024import org.apache.tapestry5.services.PageRenderRequestParameters;
025import org.apache.tapestry5.services.Traditional;
026
027/**
028 * Terminator for the {@link org.apache.tapestry5.services.ComponentRequestHandler} pipeline, that feeds out into the
029 * {@link org.apache.tapestry5.services.ComponentEventRequestHandler} and {@link org.apache.tapestry5.services.PageRenderRequestHandler}
030 * pipelines.
031 *
032 * @since 5.1.0.0
033 */
034public class ComponentRequestHandlerTerminator implements ComponentRequestHandler
035{
036    private final ComponentEventRequestHandler componentEventRequestHandler;
037
038    private final PageRenderRequestHandler pageRenderRequestHandler;
039
040    public ComponentRequestHandlerTerminator(@Traditional ComponentEventRequestHandler componentEventRequestHandler,
041                                             PageRenderRequestHandler pageRenderRequestHandler)
042    {
043        this.componentEventRequestHandler = componentEventRequestHandler;
044        this.pageRenderRequestHandler = pageRenderRequestHandler;
045    }
046
047    public void handleComponentEvent(ComponentEventRequestParameters parameters) throws IOException
048    {
049        componentEventRequestHandler.handle(parameters);
050    }
051
052    public void handlePageRender(PageRenderRequestParameters parameters) throws IOException
053    {
054        pageRenderRequestHandler.handle(parameters);
055    }
056}