Hi Dirk,

this code is mostly all cut&pasted from Stripes'
net.sourceforge.stripes.util.ResolverUtil class:

    /**
     * Finds properties files inside a jar.  If the File is not a JarFile or
does not exist a warning
     * will be logged, but no error will be raised.  In this case an empty
Set will be returned.
     *
     * @param inputStream a regular (non-jar/non-zip) input stream from
which to read the
     *        jar file in question
     * @param location the location of the jar file being examined. Used to
create the input
     *        stream if the input stream is null, and to log appropriate
error messages
     */
    private void loadImplementationsInJar(InputStream inputStream, String
location) {

        try {
            JarEntry entry;
            if (inputStream == null) inputStream = new
FileInputStream(location);
            JarInputStream jarStream = new JarInputStream(inputStream);

            while ( (entry = jarStream.getNextJarEntry() ) != null) {
                String name = entry.getName();
                if (!entry.isDirectory() && name.endsWith(".properties")) {
                    doSomethingWithTheEntry();
                }
            }
        }
        catch (IOException ioe) {
            System.out.println("Could not search jar file '" + location + "'
for properties files "
                      + due to an IOException: ", ioe.getMessage());
        }
    }

the changes are mainly no need of Java5 and looking for properties files
instead of classes. They weren't so much change, so this method *should*
work :-) I haven't tested it here as I'm on notepad + firefox now. If you
wish, I could take a deeper look later on, when arriving home. You could
call this method several times while iterating pageContext.getServletContext
().getResourcePaths("/WEB-INF/lib/"), just to seek for properties files in
custom i18n jars.

cheers,
jp


2008/3/11, Dirk Frederickx <[EMAIL PROTECTED]>:
>
> Janne, Andrew, (or others)
>
> Need help from the java guru's...
>
>
> I'm extending the user-preferences with a language selection drop-down.
> The selection would be populated with the available i18n properties of the
> jspwiki deployment.
>
>
> Recently, the i18n resources were moved into jspwiki.jar.  However, I
> don't
> see an easy way to retrieve the list of available property files anymore.
>
> As long as the resources were located somewhere in WEB-INF, I was using :
>
> Set langSet = pageContext.getServletContext().getResourcePaths(
> I18NRESOURCE_PATH );
>
> after which I could filter the langSet.
>
>
> Can you suggest a way of retrieving the list of i18n resources ?
> Or could we move them back into e.g. WEB-INF/classes ?
>
>
>
>
> dirk
>

Reply via email to