Author: mrdon Date: Tue Jan 30 19:51:11 2007 New Revision: 501717 URL: http://svn.apache.org/viewvc?view=rev&rev=501717 Log: Fixed custom parent packages not inherited properly with namespace annotation, fixed problem report when single exception WW-1679 WW-1687
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java struts/struts2/trunk/core/src/main/resources/org/apache/struts2/dispatcher/error.ftl struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java?view=diff&rev=501717&r1=501716&r2=501717 ============================================================================== --- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java (original) +++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ClasspathConfigurationProvider.java Tue Jan 30 19:51:11 2007 @@ -289,6 +289,11 @@ PackageConfig pkgConfig = loadPackageConfig(actionNamespace, actionPackage, cls); + // In case the package changed due to namespace annotation processing + if (!actionPackage.equals(pkgConfig.getName())) { + actionPackage = pkgConfig.getName(); + } + Annotation annotation = cls.getAnnotation(ParentPackage.class); if (annotation != null) { String parent = ((ParentPackage)annotation).value(); @@ -323,7 +328,6 @@ actionConfig.setPackageName(actionPackage); actionConfig.setResults(new ResultMap<String,ResultConfig>(cls, actionName, pkgConfig)); - pkgConfig.addActionConfig(actionName, actionConfig); } @@ -475,33 +479,6 @@ } } return map; - } - - /** - * Retrieve ResultConfig from cache. - * - * @param key Name of ResultConfig - * @return ResultConfig correspnding to key - */ - public V get(Object key) { - - V result = super.get(key); - if (result != null) { - return result; - } else { - - // This code should never actually be called, - // due to how the runtime configuration is created. - String actionPath = pkgConfig.getNamespace() + "/" + actionName; - - String fileName = actionPath + "-" + key + defaultPageExtension; - if (pageLocator.locate(defaultPagePrefix + fileName) == null) { - fileName = actionPath + defaultPageExtension; - } - - String location = defaultPagePrefix + fileName; - return (V) createResultConfig(key, null, location, null); - } } /** Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/dispatcher/error.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/dispatcher/error.ftl?view=diff&rev=501717&r1=501716&r2=501717 ============================================================================== --- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/dispatcher/error.ftl (original) +++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/dispatcher/error.ftl Tue Jan 30 19:51:11 2007 @@ -50,7 +50,7 @@ </#list> </ol> <#elseif (msgs?size == 1)> - <#if (msg?is_method)> + <#if (msgs[0]?is_method)> <li>${msgs[0][0]}</li> <#else> <li>${msgs[0]}</li> Modified: struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java?view=diff&rev=501717&r1=501716&r2=501717 ============================================================================== --- struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java (original) +++ struts/struts2/trunk/core/src/test/java/org/apache/struts2/config/ClasspathConfigurationProviderTest.java Tue Jan 30 19:51:11 2007 @@ -59,7 +59,8 @@ Map configs = pkg.getActionConfigs(); assertNotNull(configs); // assertEquals(1, configs.size()); - assertNotNull(configs.get("customParentPackage")); + ActionConfig actionConfig = (ActionConfig) configs.get("customParentPackage"); + assertNotNull(actionConfig); } public void testParentPackage() { @@ -76,9 +77,12 @@ Map configs = pkg.getAllActionConfigs(); // assertEquals(2, configs.size()); ActionConfig config = (ActionConfig) configs.get("customNamespace"); + assertEquals(config.getPackageName(), pkg.getName()); + assertEquals(1, pkg.getParents().size()); assertNotNull(config); assertEquals("/mynamespace", pkg.getNamespace()); - assertNotNull(configs.get("customParentPackage")); + ActionConfig ac = (ActionConfig) configs.get("customParentPackage"); + assertNotNull(ac); } public void testResultAnnotations() { @@ -95,14 +99,4 @@ ActionConfig acfg = pkg.getActionConfigs().get("actionImpl"); assertNotNull(acfg); } - - public void testDynamicResults() { - PackageConfig pkg = config.getPackageConfig("org.apache.struts2.config.cltest"); - ActionConfig config = pkg.getActionConfigs().get("twoResult"); - ResultConfig result = config.getResults().get("foobar"); - assertNotNull(result); - assertEquals("/cltest/twoResult.jsp", result.getParams().get("location")); - assertEquals(ServletDispatcherResult.class.getName(), result.getClassName()); - } - }