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
027 * Action 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 ActionLoader
035    extends GenericLoader<Action>
036{
037    /** The single instance of this class. */
038    private static ActionLoader instance = new ActionLoader();
039
040    /**
041     * These ctor's are private to force clients to use getInstance()
042     * to access this class.
043     */
044    private ActionLoader()
045    {
046        super(Action.class,
047                () -> Turbine.getConfiguration().getInt(Action.CACHE_SIZE_KEY,
048                        Action.CACHE_SIZE_DEFAULT));
049    }
050
051    /**
052     * Attempts to load and execute the external action.
053     *
054     * @param pipelineData Turbine information.
055     * @param name Name of object that will execute the action.
056     * @throws Exception a generic exception.
057     */
058    @Override
059    public void exec(PipelineData pipelineData, String name)
060                throws Exception
061    {
062        getAssembler(name).perform(pipelineData);
063    }
064
065    /**
066     * The method through which this class is accessed.
067     *
068     * @return The single instance of this class.
069     */
070    public static ActionLoader getInstance()
071    {
072        return instance;
073    }
074}