[ https://issues.apache.org/jira/browse/WW-3452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart updated WW-3452: ------------------------------ Description: <constant name="struts.custom.i18n.resources" value="resources.i18n.messages,com.acme.messages.*" /> following code is my uncompleted patch,I want to know how to scan wildcard resources using xwork/struts2 util class. org.apache.struts2.config.BeanSelectionProvider line:245 {code:java} LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages"); String bundles = props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES); if (bundles != null && bundles.length() > 0) { StringTokenizer customBundles = new StringTokenizer(props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES), ", "); while (customBundles.hasMoreTokens()) { String name = customBundles.nextToken(); // add start if(name.contains("*")){ Collection<String> resources = new HashSet<String>(); //TODO scan resources from classpath for(String res : resources) try { LOG.info("Loading global messages from " + res); LocalizedTextUtil.addDefaultResourceBundle(res); } catch (Exception e) { LOG.error("Could not find messages file " + res + ".properties. Skipping"); } continue; } // add end try { LOG.info("Loading global messages from " + name); LocalizedTextUtil.addDefaultResourceBundle(name); } catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); } } } {code} was: <constant name="struts.custom.i18n.resources" value="resources.i18n.messages,com.acme.messages.*" /> following code is my uncompleted patch,I want to know how to scan wildcard resources using xwork/struts2 util class. org.apache.struts2.config.BeanSelectionProvider line:245 LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages"); String bundles = props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES); if (bundles != null && bundles.length() > 0) { StringTokenizer customBundles = new StringTokenizer(props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES), ", "); while (customBundles.hasMoreTokens()) { String name = customBundles.nextToken(); // add start if(name.contains("*")){ Collection<String> resources = new HashSet<String>(); //TODO scan resources from classpath for(String res : resources) try { LOG.info("Loading global messages from " + res); LocalizedTextUtil.addDefaultResourceBundle(res); } catch (Exception e) { LOG.error("Could not find messages file " + res + ".properties. Skipping"); } continue; } // add end try { LOG.info("Loading global messages from " + name); LocalizedTextUtil.addDefaultResourceBundle(name); } catch (Exception e) { LOG.error("Could not find messages file " + name + ".properties. Skipping"); } } } > let struts.custom.i18n.resources supports wildcard > -------------------------------------------------- > > Key: WW-3452 > URL: https://issues.apache.org/jira/browse/WW-3452 > Project: Struts 2 > Issue Type: Improvement > Reporter: Yanming Zhou > Priority: Major > Labels: message, resource > Fix For: 6.1.0 > > Original Estimate: 4h > Remaining Estimate: 4h > > <constant name="struts.custom.i18n.resources" > value="resources.i18n.messages,com.acme.messages.*" /> > following code is my uncompleted patch,I want to know how to scan wildcard > resources using xwork/struts2 util class. > org.apache.struts2.config.BeanSelectionProvider line:245 > {code:java} > > LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages"); > String bundles = > props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES); > if (bundles != null && bundles.length() > 0) { > StringTokenizer customBundles = new > StringTokenizer(props.getProperty(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES), > ", "); > while (customBundles.hasMoreTokens()) { > String name = customBundles.nextToken(); > // add start > if(name.contains("*")){ > Collection<String> resources = new HashSet<String>(); > //TODO scan resources from classpath > for(String res : resources) > try { > LOG.info("Loading global messages from " + res); > LocalizedTextUtil.addDefaultResourceBundle(res); > } catch (Exception e) { > LOG.error("Could not find messages file " + res + > ".properties. Skipping"); > } > continue; > } > // add end > try { > LOG.info("Loading global messages from " + name); > LocalizedTextUtil.addDefaultResourceBundle(name); > } catch (Exception e) { > LOG.error("Could not find messages file " + name + > ".properties. Skipping"); > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)