[Lutinutil-commits] r1023 - in trunk/lutinutil/src/main/java/org/codelutin: i18n/bundle util
Author: tchemit Date: 2008-08-15 13:23:40 +0000 (Fri, 15 Aug 2008) New Revision: 1023 Modified: trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleEntry.java trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleManager.java trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java Log: permettre d'ajouter une url a nimporte quel classloader meilleur log dans I18nBundleEntry possibilite de recuperer les urls scannees par I18nBundleManager pom ameliore (suite a modifs dans lutinproject) Modified: trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleEntry.java =================================================================== --- trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleEntry.java 2008-08-15 13:21:23 UTC (rev 1022) +++ trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleEntry.java 2008-08-15 13:23:40 UTC (rev 1023) @@ -121,22 +121,32 @@ */ public void load(Language language, Properties resource) throws IOException { InputStream inputStream = null; + StringBuilder sb = new StringBuilder(); try { I18nFileReader fileReader = new I18nFileReader(); inputStream = getPath().openStream(); String encoding = language.getEncoding(); + if (I18nBundle.log.isDebugEnabled()) { + sb.append(getPath()).append("\n"); + } fileReader.load(inputStream, encoding); + if (I18nBundle.log.isDebugEnabled()) { - for (Entry<Object, Object> entry : resource.entrySet()) { - I18nBundle.log.debug(encoding + " : " + entry); + for (Entry<Object, Object> entry : fileReader.entrySet()) { + sb.append(encoding).append(" : ").append(entry).append("\n"); } } resource.putAll(fileReader); + if (I18nBundle.log.isDebugEnabled()) { + sb.append("nbSentences : ").append(fileReader.size()).append("\n"); + sb.append("====================================="); + } fileReader.clear(); + + } finally { if (I18nBundle.log.isDebugEnabled()) { - I18nBundle.log.debug(getPath()); + I18nBundle.log.debug(sb.toString()); } - } finally { if (inputStream != null) { inputStream.close(); } Modified: trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleManager.java =================================================================== --- trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleManager.java 2008-08-15 13:21:23 UTC (rev 1022) +++ trunk/lutinutil/src/main/java/org/codelutin/i18n/bundle/I18nBundleManager.java 2008-08-15 13:23:40 UTC (rev 1023) @@ -158,6 +158,10 @@ return result.toArray(new I18nBundleEntry[result.size()]); } + public URL[] getUrls() { + return urls; + } + public void load(Language language, Properties resource) throws IOException { long t0 = System.nanoTime(); I18nBundleEntry[] entries = getBundleEntries(language.getLocale()); Modified: trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java =================================================================== --- trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java 2008-08-15 13:21:23 UTC (rev 1022) +++ trunk/lutinutil/src/main/java/org/codelutin/util/Resource.java 2008-08-15 13:23:40 UTC (rev 1023) @@ -75,15 +75,25 @@ * @param url l'url a ajouter */ static public void addDefaultClassLoader(URL url) { + ClassLoader classLoader = ClassLoader.getSystemClassLoader(); + addClassLoader(classLoader,url); + } + + /** + * Permet d'ajouter dans un classloader une nouvelle URL dans + * lequel il faut rechercher les fichiers. + * + * @param classLoader le classloader a modifier + * @param url l'url a ajouter + */ + static public void addClassLoader(ClassLoader classLoader ,URL url) { try { - ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class}); method.setAccessible(true); method.invoke(classLoader, url); } catch (Exception eee) { - throw new RuntimeException("Can't add url in default classloader", + throw new RuntimeException("Can't add url in classloader "+classLoader, eee); } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org