Example usage for org.apache.commons.jci.utils ConversionUtils convertResourceToClassName

List of usage examples for org.apache.commons.jci.utils ConversionUtils convertResourceToClassName

Introduction

In this page you can find the example usage for org.apache.commons.jci.utils ConversionUtils convertResourceToClassName.

Prototype

public static String convertResourceToClassName(final String pResourceName) 

Source Link

Document

Please do not use - internal org/my/Class.xxx -> org.my.Class

Usage

From source file:nl.tue.gale.common.code.JaninoJavaCompiler.java

public CompilationResult compile(final String[] pSourceNames, final ResourceReader pResourceReader,
        final ResourceStore pStore, final ClassLoader pClassLoader, final JavaCompilerSettings pSettings) {

    final Map classFilesByName = new HashMap();

    final CompilingIClassLoader icl = new CompilingIClassLoader(pResourceReader, classFilesByName,
            pClassLoader);// w  w  w  .j a  v a2  s.co  m
    for (int i = 0; i < pSourceNames.length; i++) {
        try {
            icl.loadIClass(
                    Descriptor.fromClassName(ConversionUtils.convertResourceToClassName(pSourceNames[i])));
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("unable to compile code", e);
        }
    }

    // Store all fully compiled classes
    for (Iterator i = classFilesByName.entrySet().iterator(); i.hasNext();) {
        final Map.Entry entry = (Map.Entry) i.next();
        final String clazzName = (String) entry.getKey();
        pStore.write(ConversionUtils.convertClassToResourcePath(clazzName), (byte[]) entry.getValue());
    }

    final Collection problems = icl.getProblems();
    final CompilationProblem[] result = new CompilationProblem[problems.size()];
    problems.toArray(result);
    return new CompilationResult(result);
}