001package org.apache.turbine.modules;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.turbine.Turbine;
023import org.apache.turbine.pipeline.PipelineData;
024
025/**
026 * The purpose of this class is to allow one to load and execute Page
027 * modules.
028 *
029 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
030 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
031 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
032 * @version $Id$
033 */
034public class PageLoader
035    extends GenericLoader<Page>
036{
037    /** The single instance of this class. */
038    private static PageLoader instance = new PageLoader();
039
040    /**
041     * These ctor's are private to force clients to use getInstance()
042     * to access this class.
043     */
044    private PageLoader()
045    {
046        super(Page.class,
047                () -> Turbine.getConfiguration().getInt(Page.CACHE_SIZE_KEY,
048                        Page.CACHE_SIZE_DEFAULT));
049    }
050
051    /**
052     * Attempts to load and execute the external page.
053     *
054     * @param pipelineData Turbine information.
055     * @param name Name of object that will execute the page.
056     * @throws Exception a generic exception.
057     */
058    @Override
059    public void exec(PipelineData pipelineData, String name)
060            throws Exception
061    {
062        // Execute page
063        getAssembler(name).build(pipelineData);
064    }
065
066    /**
067     * The method through which this class is accessed.
068     *
069     * @return The single instance of this class.
070     */
071    public static PageLoader getInstance()
072    {
073        return instance;
074    }
075}