亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tilesplugin.java

?? structs源碼
?? JAVA
字號:
/*
 * $Id: TilesPlugin.java 471754 2006-11-06 14:55:09Z husted $
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.struts.tiles;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.action.RequestProcessor;
import org.apache.struts.chain.ComposableRequestProcessor;
import org.apache.struts.config.ControllerConfig;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.config.PlugInConfig;
import org.apache.struts.util.RequestUtils;

/**
 * Tiles Plugin used to initialize Tiles.
 * This plugin is to be used with Struts 1.1 in association with
 * {@link TilesRequestProcessor}.
 * <br>
 * This plugin creates one definition factory for each Struts-module. The definition factory
 * configuration is read first from 'web.xml' (backward compatibility), then it is
 * overloaded with values found in the plugin property values.
 * <br>
 * The plugin changes the Struts configuration by specifying a {@link TilesRequestProcessor} as
 * request processor. If you want to use your own RequestProcessor,
 * it should subclass TilesRequestProcessor.
 * <br>
 * This plugin can also be used to create one single factory for all modules.
 * This behavior is enabled by specifying <code>moduleAware=false</code> in each
 * plugin properties. In this case, the definition factory
 * configuration file is read by the first Tiles plugin to be initialized. The order is
 * determined by the order of modules declaration in web.xml. The first module
 * is always the default one if it exists.
 * The plugin should be declared in each struts-config.xml file in order to
 * properly initialize the request processor.
 * @since Struts 1.1
 */
public class TilesPlugin implements PlugIn {

    /**
     * Commons Logging instance.
     */
    protected static Log log = LogFactory.getLog(TilesPlugin.class);

    /**
     * Is the factory module aware?
     */
    protected boolean moduleAware = false;

    /**
     * Tiles util implementation classname. This property can be set
     * by user in the plugin declaration.
     */
    protected String tilesUtilImplClassname = null;

    /**
     * Associated definition factory.
     */
    protected DefinitionsFactory definitionFactory = null;

    /**
     * The plugin config object provided by the ActionServlet initializing
     * this plugin.
     */
    protected PlugInConfig currentPlugInConfigObject=null;

    /**
     * Get the module aware flag.
     * @return <code>true</code>: user wants a single factory instance,
     * <code>false:</code> user wants multiple factory instances (one per module with Struts)
     */
    public boolean isModuleAware() {
        return moduleAware;
    }

    /**
     * Set the module aware flag.
     * This flag is only meaningful if the property <code>tilesUtilImplClassname</code> is not
     * set.
     * @param moduleAware <code>true</code>: user wants a single factory instance,
     * <code>false:</code> user wants multiple factory instances (one per module with Struts)
     */
    public void setModuleAware(boolean moduleAware) {
        this.moduleAware = moduleAware;
    }

    /**
     * <p>Receive notification that the specified module is being
     * started up.</p>
     *
     * @param servlet ActionServlet that is managing all the modules
     *  in this web application.
     * @param moduleConfig ModuleConfig for the module with which
     *  this plugin is associated.
     *
     * @exception ServletException if this <code>PlugIn</code> cannot
     *  be successfully initialized.
     */
    public void init(ActionServlet servlet, ModuleConfig moduleConfig)
        throws ServletException {

        // Create factory config object
        DefinitionsFactoryConfig factoryConfig =
            readFactoryConfig(servlet, moduleConfig);

        // Set the module name in the config. This name will be used to compute
        // the name under which the factory is stored.
        factoryConfig.setFactoryName(moduleConfig.getPrefix());

        // Set RequestProcessor class
        this.initRequestProcessorClass(moduleConfig);

        this.initTilesUtil();

        this.initDefinitionsFactory(servlet.getServletContext(), moduleConfig, factoryConfig);
    }

    /**
     * Set TilesUtil implementation according to properties 'tilesUtilImplClassname'
     * and 'moduleAware'.  These properties are taken into account only once. A
     * side effect is that only the values set in the first initialized plugin are
     * effectively taken into account.
     * @throws ServletException
     */
    private void initTilesUtil() throws ServletException {

        if (TilesUtil.isTilesUtilImplSet()) {
            return;
        }

        // Check if user has specified a TilesUtil implementation classname or not.
        // If no implementation is specified, check if user has specified one
        // shared single factory for all module, or one factory for each module.

        if (this.getTilesUtilImplClassname() == null) {

            if (isModuleAware()) {
                TilesUtil.setTilesUtil(new TilesUtilStrutsModulesImpl());
            } else {
                TilesUtil.setTilesUtil(new TilesUtilStrutsImpl());
            }

        } else { // A classname is specified for the tilesUtilImp, use it.
            try {
                TilesUtilStrutsImpl impl =
                    (TilesUtilStrutsImpl) RequestUtils
                        .applicationClass(getTilesUtilImplClassname())
                        .newInstance();
                TilesUtil.setTilesUtil(impl);

            } catch (ClassCastException ex) {
                throw new ServletException(
                    "Can't set TilesUtil implementation to '"
                        + getTilesUtilImplClassname()
                        + "'. TilesUtil implementation should be a subclass of '"
                        + TilesUtilStrutsImpl.class.getName()
                        + "'");

            } catch (Exception ex) {
                throw new ServletException(
                    "Can't set TilesUtil implementation.",
                    ex);
            }
        }

    }

    /**
     * Initialize the DefinitionsFactory this module will use.
     * @param servletContext
     * @param moduleConfig
     * @param factoryConfig
     * @throws ServletException
     */
    private void initDefinitionsFactory(
        ServletContext servletContext,
        ModuleConfig moduleConfig,
        DefinitionsFactoryConfig factoryConfig)
        throws ServletException {

        // Check if a factory already exist for this module
        definitionFactory =
            ((TilesUtilStrutsImpl) TilesUtil.getTilesUtil()).getDefinitionsFactory(
                servletContext,
                moduleConfig);

        if (definitionFactory != null) {
            log.info(
                "Factory already exists for module '"
                    + moduleConfig.getPrefix()
                    + "'. The factory found is from module '"
                    + definitionFactory.getConfig().getFactoryName()
                    + "'. No new creation.");

            return;
        }

        // Create configurable factory
        try {
            definitionFactory =
                TilesUtil.createDefinitionsFactory(
                    servletContext,
                    factoryConfig);

        } catch (DefinitionsFactoryException ex) {
            log.error(
                "Can't create Tiles definition factory for module '"
                    + moduleConfig.getPrefix()
                    + "'.");

            throw new ServletException(ex);
        }

        log.info(
            "Tiles definition factory loaded for module '"
                + moduleConfig.getPrefix()
                + "'.");
    }

    /**
     * End plugin.
     */
    public void destroy() {
        definitionFactory.destroy();
        definitionFactory = null;
    }

    /**
     * Create FactoryConfig and initialize it from web.xml and struts-config.xml.
     *
     * @param servlet ActionServlet that is managing all the modules
     *  in this web application.
     * @param config ModuleConfig for the module with which
     *  this plugin is associated.
     * @exception ServletException if this <code>PlugIn</code> cannot
     *  be successfully initialized.
     */
    protected DefinitionsFactoryConfig readFactoryConfig(
        ActionServlet servlet,
        ModuleConfig config)
        throws ServletException {

        // Create tiles definitions config object
        DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
        // Get init parameters from web.xml files
        try {
            DefinitionsUtil.populateDefinitionsFactoryConfig(
                factoryConfig,
                servlet.getServletConfig());

        } catch (Exception ex) {
            if (log.isDebugEnabled()){
                log.debug("", ex);
            }
            ex.printStackTrace();
            throw new UnavailableException(
                "Can't populate DefinitionsFactoryConfig class from 'web.xml': "
                    + ex.getMessage());
        }

        // Get init parameters from struts-config.xml
        try {
            Map strutsProperties = findStrutsPlugInConfigProperties(servlet, config);
            factoryConfig.populate(strutsProperties);

        } catch (Exception ex) {
            if (log.isDebugEnabled()) {
                log.debug("", ex);
            }

            throw new UnavailableException(
                "Can't populate DefinitionsFactoryConfig class from '"
                    + config.getPrefix()
                    + "/struts-config.xml':"
                    + ex.getMessage());
        }

        return factoryConfig;
    }

    /**
     * Find original properties set in the Struts PlugInConfig object.
     * First, we need to find the index of this plugin. Then we retrieve the array of configs
     * and then the object for this plugin.
     * @param servlet ActionServlet that is managing all the modules
     *  in this web application.
     * @param config ModuleConfig for the module with which
     *  this plug in is associated.
     *
     * @exception ServletException if this <code>PlugIn</code> cannot
     *  be successfully initialized.
     */
    protected Map findStrutsPlugInConfigProperties(
        ActionServlet servlet,
        ModuleConfig config)
        throws ServletException {

        return currentPlugInConfigObject.getProperties();
    }

    /**
     * Set RequestProcessor to appropriate Tiles {@link RequestProcessor}.
     * First, check if a RequestProcessor is specified. If yes, check if it extends
     * the appropriate {@link TilesRequestProcessor} class. If not, set processor class to
     * TilesRequestProcessor.
     *
     * @param config ModuleConfig for the module with which
     *  this plugin is associated.
     * @throws ServletException On errors.
     */
    protected void initRequestProcessorClass(ModuleConfig config)
        throws ServletException {

        String tilesProcessorClassname = TilesRequestProcessor.class.getName();
        ControllerConfig ctrlConfig = config.getControllerConfig();
        String configProcessorClassname = ctrlConfig.getProcessorClass();

        // Check if specified classname exist
        Class configProcessorClass;
        try {
            configProcessorClass =
                RequestUtils.applicationClass(configProcessorClassname);

        } catch (ClassNotFoundException ex) {
            log.fatal(
                "Can't set TilesRequestProcessor: bad class name '"
                    + configProcessorClassname
                    + "'.");
            throw new ServletException(ex);
        }

        // Check to see if request processor uses struts-chain.  If so,
        // no need to replace the request processor.
        if (ComposableRequestProcessor.class.isAssignableFrom(configProcessorClass)) {
            return;
        }

        // Check if it is the default request processor or Tiles one.
        // If true, replace by Tiles' one.
        if (configProcessorClassname.equals(RequestProcessor.class.getName())
            || configProcessorClassname.endsWith(tilesProcessorClassname)) {

            ctrlConfig.setProcessorClass(tilesProcessorClassname);
            return;
        }

        // Check if specified request processor is compatible with Tiles.
        Class tilesProcessorClass = TilesRequestProcessor.class;
        if (!tilesProcessorClass.isAssignableFrom(configProcessorClass)) {
            // Not compatible
            String msg =
                "TilesPlugin : Specified RequestProcessor not compatible with TilesRequestProcessor";
            if (log.isFatalEnabled()) {
                log.fatal(msg);
            }
            throw new ServletException(msg);
        }
    }

    /**
     * Set Tiles util implemention classname.
     * If this property is set, the flag <code>moduleAware</code> will not be used anymore.
     * @param tilesUtilImplClassname Classname.
     */
    public void setTilesUtilImplClassname(String tilesUtilImplClassname) {
        this.tilesUtilImplClassname = tilesUtilImplClassname;
    }

    /**
     * Get Tiles util implemention classname.
     * @return The classname or <code>null</code> if none is set.
     */
    public String getTilesUtilImplClassname() {
        return tilesUtilImplClassname;
    }

    /**
     * Method used by the ActionServlet initializing this plugin.
     * Set the plugin config object read from module config.
     * @param plugInConfigObject PlugInConfig.
     */
    public void setCurrentPlugInConfigObject(PlugInConfig plugInConfigObject) {
        this.currentPlugInConfigObject = plugInConfigObject;
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩avvvv在线播放| 夜夜亚洲天天久久| 亚洲欧美日韩人成在线播放| 午夜成人免费电影| 国产一区二区三区在线观看免费 | 亚洲视频你懂的| 亚洲一区电影777| 国产精品一色哟哟哟| 欧美丰满少妇xxxxx高潮对白| 国产亚洲精品aa午夜观看| 天天射综合影视| 色婷婷亚洲精品| 国产精品丝袜一区| 国产精品一品二品| 欧美v国产在线一区二区三区| 亚洲图片有声小说| 91女厕偷拍女厕偷拍高清| 国产亚洲欧美激情| 精品无人码麻豆乱码1区2区| 久久国产精品露脸对白| 不卡的av在线| 精品国产一区二区国模嫣然| 婷婷成人激情在线网| 色欲综合视频天天天| 国产精品久久久久久户外露出| 韩国av一区二区三区四区| 91精品免费在线观看| 轻轻草成人在线| 欧美一区在线视频| 日韩精品免费专区| 91精品国产乱| 青青草国产精品97视觉盛宴| 69堂精品视频| 老司机午夜精品| 日韩欧美一卡二卡| 精品一区二区三区在线视频| 欧美tk丨vk视频| 激情综合一区二区三区| 久久久91精品国产一区二区精品 | 国产日产精品一区| 国产精品99久久久久久久女警| 欧美精品一区二区三区在线播放 | 亚洲色图20p| 色婷婷亚洲综合| 视频一区视频二区在线观看| 欧美日韩1234| 男男gaygay亚洲| 亚洲精品在线电影| 成人午夜又粗又硬又大| 中文字幕欧美一区| 日本乱码高清不卡字幕| 亚洲一区成人在线| 精品成人a区在线观看| 国产精品亚洲а∨天堂免在线| 亚洲国产经典视频| 日本电影欧美片| 蜜臀av亚洲一区中文字幕| 精品国产3级a| 97精品久久久午夜一区二区三区| 亚洲综合一二三区| 欧美成人r级一区二区三区| 国产精品2024| 亚洲影院免费观看| 日韩免费观看高清完整版| 床上的激情91.| 午夜精品福利久久久| 欧美激情一区三区| 777xxx欧美| 成人av免费在线观看| 日本欧美一区二区三区乱码| 国产免费久久精品| 欧美精品亚洲一区二区在线播放| 国产一区二区三区不卡在线观看| 亚洲久本草在线中文字幕| 日韩三级视频中文字幕| 99国内精品久久| 精品一区二区三区的国产在线播放| 国产精品色婷婷久久58| 欧美精品丝袜中出| 99久久久精品| 国产一区二区伦理| 午夜视频一区在线观看| 欧美国产亚洲另类动漫| 91精品国产综合久久久蜜臀粉嫩| 大桥未久av一区二区三区中文| 日日夜夜免费精品视频| 中文字幕一区av| 精品国产网站在线观看| 欧美日韩国产片| 99久久综合精品| 久久国内精品视频| 亚洲精品国产一区二区精华液| 91精品啪在线观看国产60岁| 亚洲一区二区不卡免费| 亚洲一区二区精品视频| 国产女人18毛片水真多成人如厕| 91精品欧美综合在线观看最新| 91香蕉国产在线观看软件| 国产精品性做久久久久久| 青青青爽久久午夜综合久久午夜| 夜夜嗨av一区二区三区| 国产精品久久久久精k8| 久久久精品免费免费| 日韩精品一区二区三区四区| 欧美理论片在线| 欧美日韩一二三| 欧美日韩久久一区| 欧美中文字幕一二三区视频| 91在线porny国产在线看| 国产99精品国产| 国产激情视频一区二区三区欧美 | 日韩成人免费电影| 香港成人在线视频| 午夜电影网亚洲视频| 亚洲制服欧美中文字幕中文字幕| 亚洲视频免费看| 亚洲欧美日韩久久| 亚洲综合一区二区三区| 亚洲二区在线视频| 亚洲www啪成人一区二区麻豆| 亚洲一区二区三区四区在线| 亚洲在线视频网站| 五月婷婷综合在线| 天天av天天翘天天综合网色鬼国产| 亚洲大片精品永久免费| 亚洲一级二级三级| 91视频国产观看| 成人av在线资源网站| 日本电影欧美片| 欧美人伦禁忌dvd放荡欲情| 久久人人97超碰com| 国产精品天美传媒沈樵| 亚洲欧洲在线观看av| 亚洲精品高清视频在线观看| 亚洲一级二级三级| 美女视频黄a大片欧美| 国产高清在线精品| 91网站最新网址| 69p69国产精品| 国产欧美一区二区精品性色超碰| 欧美国产精品久久| 亚洲激情网站免费观看| 蜜桃一区二区三区四区| 成人av在线资源| 91.xcao| 国产日韩欧美不卡| 亚洲精品写真福利| 久久国产福利国产秒拍| a在线欧美一区| 欧美一区二区三区四区视频 | 欧美午夜一区二区三区| 欧美成人激情免费网| 中文一区在线播放 | 欧美激情一区二区三区在线| 亚洲一二三级电影| 国产一区二区三区免费| 欧美色国产精品| 久久久久久99久久久精品网站| 亚洲精品国产视频| 国产一区二区在线电影| 欧美色网站导航| 日本一区二区三区视频视频| 五月激情综合婷婷| 成人app网站| 欧美精品一区二区蜜臀亚洲| 亚洲午夜激情网站| 不卡的av中国片| 欧美电视剧在线看免费| 亚洲午夜精品久久久久久久久| 国产乱国产乱300精品| 欧美福利一区二区| 亚洲日本在线a| 粉嫩欧美一区二区三区高清影视| 欧美精品色一区二区三区| 国产精品久久久久桃色tv| 精品在线播放午夜| 欧美日韩免费一区二区三区| 欧美本精品男人aⅴ天堂| 免费在线看成人av| 波多野结衣亚洲| 欧美一二三四在线| 一级做a爱片久久| 国产精品小仙女| 精品国产伦一区二区三区观看体验| 亚洲一区二区中文在线| av亚洲精华国产精华精华| 亚洲国产成人午夜在线一区| 美女视频黄频大全不卡视频在线播放| 欧美亚洲国产怡红院影院| ...中文天堂在线一区| 国产精品1区2区| 久久亚洲一区二区三区明星换脸| 日本中文字幕一区二区视频| 精品视频色一区| 亚洲mv大片欧洲mv大片精品| 色婷婷综合久久久中文一区二区| 国产精品传媒在线| 91在线观看成人| 亚洲一区免费在线观看| 欧美色综合久久|