Skip to content

Commit eb863bd

Browse files
committed
Only copy remote JARs to temp dir
1 parent 2f72b55 commit eb863bd

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# JVM Runner Plugin for RDF Connect
1+
# JVM Runner for RDF Connect
22

33
The **JvmRunner** executes processors implemented in the Java Virtual Machine (JVM).
4-
It allows you to integrate custom Java (or Kotlin, Scala, etc.) processors into an RDF Connect streaming pipeline by providing a JAR and a class name.
4+
It allows you to integrate custom Java (or Kotlin, Scala, etc.) processors into an RDF-Connect streaming pipeline by providing a JAR and a class name.
55

66
## Overview
77

@@ -34,6 +34,8 @@ To use your JVM processor in a pipeline:
3434
<myProcessor> a rdfc:TestProcessor.
3535
```
3636

37+
Make sure you also import the processor. Check the documentation of your processor on how to install it.
38+
3739

3840
## Implementing a new processor
3941

@@ -48,7 +50,7 @@ Processors must:
4850

4951
### Processor description file
5052

51-
The processor should be accompanied with a description file, often called `index.ttl`.
53+
The processor should be accompanied by a description file, often called `index.ttl`.
5254

5355
They require the following fields:
5456
* `rdfc:javaImplementationOf` with value `rdfc:Processor`, indicating that this processor is a JavaProcessor,
@@ -57,7 +59,7 @@ They require the following fields:
5759
* A SHACL shape defining the required arguments.
5860

5961
For example, the following description file declares a processor with arguments `{ reader: Reader, writer: Writer, additionalText: string }`.
60-
A matching implementation can be found on [github](https://github.com/rdf-connect/template-processor-jvm/blob/main/src/main/java/org/example/Library.java).
62+
A matching implementation can be found on [GitHub](https://github.com/rdf-connect/template-processor-jvm/blob/main/src/main/java/org/example/Library.java).
6163
```turtle
6264
@prefix rdfc: <https://w3id.org/rdf-connect#>.
6365
@prefix sh: <http://www.w3.org/ns/shacl#>.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ allprojects {
99
}
1010

1111
group = "io.github.rdf-connect"
12-
version = "0.0.3"
12+
version = "0.0.4"
1313
}
1414

1515
subprojects {

runner/src/main/java/io/github/rdfc/Runner.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,22 @@ private static class Config {
292292

293293
Processor<?> loadClass(Runner runner, String arguments, Logger logger) throws Exception {
294294
URL jarUrl = new URI(this.jar).toURL();
295-
// Download JAR to temp dir
296295

297-
logger.info("Start download");
298-
Path jarPath = Files.createTempFile("remote-lib", ".jar");
299-
try (InputStream in = jarUrl.openStream()) {
300-
Files.copy(in, jarPath, StandardCopyOption.REPLACE_EXISTING);
296+
Path jarPath;
297+
if (jarUrl.getProtocol().equalsIgnoreCase("http") || jarUrl.getProtocol().equalsIgnoreCase("https")) {
298+
// Remote JAR, download it
299+
logger.info("Downloading JAR from " + this.jar);
300+
// Download JAR to temp dir
301+
jarPath = Files.createTempFile("remote-lib", ".jar");
302+
try (InputStream in = jarUrl.openStream()) {
303+
Files.copy(in, jarPath, StandardCopyOption.REPLACE_EXISTING);
304+
}
305+
logger.info("End download");
306+
} else {
307+
// Local JAR, use it directly
308+
jarPath = Path.of(jarUrl.toURI());
301309
}
302310

303-
logger.info("End download");
304311
// Use local URLClassLoader
305312
URLClassLoader loader = new URLClassLoader(new URL[] { jarPath.toUri().toURL() });
306313

0 commit comments

Comments
 (0)