use of com.oracle.svm.core.configure.ResourcesRegistry in project graal by oracle.
the class ResourceConfigurationTest method printJson.
@Test
public void printJson() {
ResourceConfiguration rc = new ResourceConfiguration();
ConfigurationCondition defaultCond = ConfigurationCondition.alwaysTrue();
rc.addResourcePattern(defaultCond, ".*/Resource.*txt$");
rc.ignoreResourcePattern(defaultCond, ".*/Resource2.txt$");
PipedWriter pw = new PipedWriter();
JsonWriter jw = new JsonWriter(pw);
try (PipedReader pr = new PipedReader()) {
pr.connect(pw);
Thread writerThread = new Thread(() -> {
try (JsonWriter w = jw) {
rc.printJson(w);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
});
List<String> addedResources = new LinkedList<>();
List<String> ignoredResources = new LinkedList<>();
ResourcesRegistry registry = new ResourcesRegistry() {
@Override
public void addResources(ConfigurationCondition condition, String pattern) {
addedResources.add(pattern);
}
@Override
public void ignoreResources(ConfigurationCondition condition, String pattern) {
ignoredResources.add(pattern);
}
@Override
public void addResourceBundles(ConfigurationCondition condition, String name) {
}
@Override
public void addResourceBundles(ConfigurationCondition condition, String basename, Collection<Locale> locales) {
}
@Override
public void addClassBasedResourceBundle(ConfigurationCondition condition, String basename, String className) {
}
};
ResourceConfigurationParser rcp = new ResourceConfigurationParser(registry, true);
writerThread.start();
rcp.parseAndRegister(pr);
writerThread.join();
Assert.assertTrue(addedResources.contains(".*/Resource.*txt$"));
Assert.assertTrue(ignoredResources.contains(".*/Resource2.txt$"));
} catch (IOException | InterruptedException e) {
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
use of com.oracle.svm.core.configure.ResourcesRegistry in project graal by oracle.
the class JNIRegistrationAwt method registerDefaultCSS.
private static void registerDefaultCSS(DuringAnalysisAccess duringAnalysisAccess) {
ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class);
resourcesRegistry.addResources(ConfigurationCondition.alwaysTrue(), "javax.swing.text.html.default.css");
}
Aggregations