com.athaydes.osgiaas.javac.internal.compiler.OsgiaasJavaCompilerService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of osgiaas-javac Show documentation
Show all versions of osgiaas-javac Show documentation
OSGiaaS Javac Runtime Compiler
package com.athaydes.osgiaas.javac.internal.compiler;
import com.athaydes.osgiaas.api.env.ClassLoaderContext;
import com.athaydes.osgiaas.javac.JavacService;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class OsgiaasJavaCompilerService implements JavacService {
private final Map compilerByClassLoader = new HashMap<>();
@Override
public Optional> compileJavaClass( ClassLoaderContext classLoaderContext,
String qualifiedName,
String code,
PrintStream writer ) {
OsgiaasJavaCompiler compiler = getOsgiaasJavaCompiler( classLoaderContext );
return compiler.compile( qualifiedName, code, writer );
}
@Override
public ClassLoaderContext getAugmentedClassLoaderContext( ClassLoaderContext classLoaderContext ) {
OsgiaasJavaCompiler compiler = getOsgiaasJavaCompiler( classLoaderContext );
return compiler.getClassLoaderContext();
}
private OsgiaasJavaCompiler getOsgiaasJavaCompiler( ClassLoaderContext classLoaderContext ) {
return compilerByClassLoader
.computeIfAbsent( classLoaderContext.getClassLoader(),
( loader ) -> new OsgiaasJavaCompiler( classLoaderContext ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy