-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
polocloud-node/src/main/java/dev/httpmarco/polocloud/node/dependencies/Dependency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
package dev.httpmarco.polocloud.node.dependencies; | ||
|
||
import dev.httpmarco.polocloud.api.Version; | ||
import dev.httpmarco.polocloud.api.Available; | ||
|
||
public class Dependency { | ||
import java.io.File; | ||
|
||
private String groupId; | ||
private String artifactId; | ||
private Version version; | ||
public interface Dependency extends Available { | ||
|
||
File file(); | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
polocloud-node/src/main/java/dev/httpmarco/polocloud/node/dependencies/DependencySlot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
package dev.httpmarco.polocloud.node.dependencies; | ||
|
||
import dev.httpmarco.polocloud.common.ModifiableClassloader; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
@Log4j2 | ||
@RequiredArgsConstructor | ||
public final class DependencySlot { | ||
|
||
private final ModifiableClassloader classloader; | ||
private final List<Dependency> dependencies = new CopyOnWriteArrayList<>(); | ||
|
||
public void bindDependencies(Dependency dependency) { | ||
if(!dependency.available()) { | ||
log.warn("Cannot bind dependencies for {}", dependency); | ||
return; | ||
} | ||
|
||
this.classloader.attach(dependency.file()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...de/src/main/java/dev/httpmarco/polocloud/node/dependencies/impl/RepositoryDependency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.httpmarco.polocloud.node.dependencies.impl; | ||
|
||
import dev.httpmarco.polocloud.api.Version; | ||
import dev.httpmarco.polocloud.node.dependencies.Dependency; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import lombok.experimental.Accessors; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.io.File; | ||
|
||
@Getter | ||
@ToString | ||
@Accessors(fluent = true) | ||
@AllArgsConstructor | ||
public final class RepositoryDependency implements Dependency { | ||
|
||
private final String groupId; | ||
private final String artifactId; | ||
private final Version version; | ||
|
||
private @Nullable File file; | ||
|
||
@Override | ||
public boolean available() { | ||
return file != null && file.exists(); | ||
} | ||
} |