X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.init%2Fsrc%2Forg%2Fargeo%2Finit%2Fa2%2FAbstractProvisioningSource.java;h=617e7887806f451a9eb89cd874610ccf8bab0344;hb=8e83ad78ea94ce72672b535ab421bb68b6b3bae3;hp=7df851b2452c0d788c5618a9372238459d712021;hpb=c66685995c1bf2c59bdf6d68753470c85828310a;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java b/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java index 7df851b24..617e78878 100644 --- a/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java +++ b/org.argeo.init/src/org/argeo/init/a2/AbstractProvisioningSource.java @@ -28,10 +28,10 @@ import org.osgi.framework.Version; public abstract class AbstractProvisioningSource implements ProvisioningSource { protected final Map contributions = Collections.synchronizedSortedMap(new TreeMap<>()); - private final boolean useReference; + private final boolean usingReference; - public AbstractProvisioningSource(boolean useReference) { - this.useReference = useReference; + public AbstractProvisioningSource(boolean usingReference) { + this.usingReference = usingReference; } public Iterable listContributions(Object filter) { @@ -42,7 +42,7 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { public Bundle install(BundleContext bc, A2Module module) { try { Object locator = module.getLocator(); - if (useReference && locator instanceof Path locatorPath) { + if (usingReference && locator instanceof Path locatorPath) { String referenceUrl = "reference:file:" + locatorPath.toString(); Bundle bundle = bc.installBundle(referenceUrl); return bundle; @@ -69,7 +69,7 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { public void update(Bundle bundle, A2Module module) { try { Object locator = module.getLocator(); - if (useReference && locator instanceof Path) { + if (usingReference && locator instanceof Path) { try (InputStream in = newInputStream(locator)) { bundle.update(in); } @@ -196,6 +196,20 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { return symbolicName; } + protected boolean isUsingReference() { + return usingReference; + } + + private InputStream newInputStream(Object locator) throws IOException { + if (locator instanceof Path) { + return Files.newInputStream((Path) locator); + } else if (locator instanceof URL) { + return ((URL) locator).openStream(); + } else { + throw new IllegalArgumentException("Unsupported module locator type " + locator.getClass()); + } + } + private static Manifest findManifest(Path currentPath) { Path metaInfPath = currentPath.resolve("META-INF"); if (Files.exists(metaInfPath) && Files.isDirectory(metaInfPath)) { @@ -241,13 +255,4 @@ public abstract class AbstractProvisioningSource implements ProvisioningSource { } - private InputStream newInputStream(Object locator) throws IOException { - if (locator instanceof Path) { - return Files.newInputStream((Path) locator); - } else if (locator instanceof URL) { - return ((URL) locator).openStream(); - } else { - throw new IllegalArgumentException("Unsupported module locator type " + locator.getClass()); - } - } }