MCPcopy Create free account
hub / github.com/GateNLP/gate-core / fillInResInfos

Method fillInResInfos

src/main/java/gate/creole/Plugin.java:525–553  ·  view source on GitHub ↗
(List<ResourceInfo> incompleteResInfos,
      List<String> allJars)

Source from the content-addressed store, hash-verified

523 }
524
525 protected void fillInResInfos(List<ResourceInfo> incompleteResInfos,
526 List<String> allJars) throws IOException {
527 // now create a temporary class loader with all the JARs (scanned or
528 // not), so we can look up all the referenced classes in the normal
529 // way and read their CreoleResource annotations (if any).
530 URL[] jarUrls = new URL[allJars.size()];
531 for(int i = 0; i < jarUrls.length; i++) {
532 jarUrls[i] = new URL(getBaseURL(), allJars.get(i));
533 }
534
535 // TODO shouldn't we use a proper temp gate class loader which we
536 // can then throw away?
537 try (URLClassLoader tempClassLoader =
538 new URLClassLoader(jarUrls, Gate.class.getClassLoader());) {
539 for(ResourceInfo ri : incompleteResInfos) {
540 String classFile =
541 ri.getResourceClassName().replace('.', '/') + ".class";
542 InputStream classStream =
543 tempClassLoader.getResourceAsStream(classFile);
544 if(classStream != null) {
545 ClassReader classReader = new ClassReader(classStream);
546 ClassVisitor visitor = new ResourceInfoVisitor(ri);
547 classReader.accept(visitor, ClassReader.SKIP_CODE
548 | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
549 classStream.close();
550 }
551 }
552 }
553 }
554
555 public static class Directory extends Plugin {
556

Callers 1

parseCreoleMethod · 0.95

Calls 8

getBaseURLMethod · 0.95
closeMethod · 0.95
getClassLoaderMethod · 0.80
getResourceClassNameMethod · 0.80
getResourceAsStreamMethod · 0.80
acceptMethod · 0.80
sizeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected