Author: pbenedict Date: Wed Aug 15 20:14:28 2007 New Revision: 566476 URL: http://svn.apache.org/viewvc?view=rev&rev=566476 Log: STR-3085: Module post-processing
Added: struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java (with props) Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java Modified: struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java?view=diff&rev=566476&r1=566475&r2=566476 ============================================================================== --- struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java (original) +++ struts/struts1/trunk/core/src/main/java/org/apache/struts/action/ActionServlet.java Wed Aug 15 20:14:28 2007 @@ -50,6 +50,7 @@ import org.apache.struts.config.MessageResourcesConfig; import org.apache.struts.config.ModuleConfig; import org.apache.struts.config.ModuleConfigFactory; +import org.apache.struts.config.ModuleConfigPostProcessor; import org.apache.struts.config.PlugInConfig; import org.apache.struts.util.MessageResources; import org.apache.struts.util.MessageResourcesFactory; @@ -364,6 +365,7 @@ initModuleForwards(moduleConfig); initModuleExceptionConfigs(moduleConfig); initModuleActions(moduleConfig); + postProcessModule(moduleConfig); moduleConfig.freeze(); Enumeration names = getServletConfig().getInitParameterNames(); @@ -386,6 +388,7 @@ initModuleForwards(moduleConfig); initModuleExceptionConfigs(moduleConfig); initModuleActions(moduleConfig); + postProcessModule(moduleConfig); moduleConfig.freeze(); } @@ -890,6 +893,21 @@ log(errMsg, e); throw new UnavailableException(errMsg); + } + } + } + + protected void postProcessModule(ModuleConfig moduleConfig) { + String plugInKey = Globals.PLUG_INS_KEY + moduleConfig.getPrefix(); + PlugIn[] plugIns = (PlugIn[]) getServletContext().getAttribute(plugInKey); + if ((plugIns == null) || (plugIns.length == 0)) { + log.debug("No plugins to attempt post processing"); + } + + for (int i = 0; i < plugIns.length; i++) { + PlugIn plugIn = plugIns[i]; + if (plugIn instanceof ModuleConfigPostProcessor) { + ((ModuleConfigPostProcessor) plugIn).postProcessModule(moduleConfig); } } } Added: struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java URL: http://svn.apache.org/viewvc/struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java?view=auto&rev=566476 ============================================================================== --- struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java (added) +++ struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java Wed Aug 15 20:14:28 2007 @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * 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.config; + +/** + * This interface is to be implemented by any plugin for custom modification of + * a module after it is been configured but before it is frozen. This allows for + * overriding or adding properties after standard initialization. + * + * @see ModuleConfig + * @see ModuleConfig#freeze() + * @since Struts 1.4 + * @version $Rev$ + */ +public interface ModuleConfigPostProcessor { + + /** + * Modify the specified module after its standard initialization. + * + * @param config the module + */ + void postProcessModule(ModuleConfig config); + +} Propchange: struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: struts/struts1/trunk/core/src/main/java/org/apache/struts/config/ModuleConfigPostProcessor.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL