swt/rcp/org.argeo.tp.swt \
lib/linux/x86_64/swt/rcp/org.argeo.tp.swt \
swt/rcp/org.argeo.tp.swt.workbench \
-org.argeo.tp.jcr
clean:
Import-Package: \
+javax.transaction.xa,\
javax.security.*,\
org.osgi.service.useradmin,\
public abstract class AbstractProvisioningSource implements ProvisioningSource {
protected final Map<String, A2Contribution> 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<A2Contribution> listContributions(Object filter) {
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;
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);
}
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)) {
}
- 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());
- }
- }
}
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
+import java.util.StringJoiner;
import java.util.TreeMap;
import org.argeo.init.osgi.OsgiBootUtils;
/** A file system {@link AbstractProvisioningSource} in A2 format. */
public class FsA2Source extends AbstractProvisioningSource implements A2Source {
private final Path base;
- private final Map<String, String> xOr;
+ private final Map<String, String> variantsXOr;
// public FsA2Source(Path base) {
// this(base, new HashMap<>());
// }
- public FsA2Source(Path base, Map<String, String> xOr, boolean useReference) {
- super(useReference);
+ public FsA2Source(Path base, Map<String, String> variantsXOr, boolean usingReference) {
+ super(usingReference);
this.base = base;
- this.xOr = new HashMap<>(xOr);
+ this.variantsXOr = new HashMap<>(variantsXOr);
}
void load() throws IOException {
} else {// variants
Path variantPath = null;
// is it an explicit variant?
- String variant = xOr.get(contributionPath.getFileName().toString());
+ String variant = variantsXOr.get(contributionPath.getFileName().toString());
if (variant != null) {
variantPath = contributionPath.resolve(variant);
}
URI baseUri = base.toUri();
try {
if (baseUri.getScheme().equals("file")) {
- return new URI(SCHEME_A2, null, base.toString(), null);
+ String queryPart = "";
+ if (!getVariantsXOr().isEmpty()) {
+ StringJoiner sj = new StringJoiner("&");
+ for (String key : getVariantsXOr().keySet()) {
+ sj.add(key + "=" + getVariantsXOr().get(key));
+ }
+ queryPart = sj.toString();
+ }
+ return new URI(isUsingReference() ? SCHEME_A2_REFERENCE : SCHEME_A2, null, base.toString(), queryPart,
+ null);
} else {
throw new UnsupportedOperationException("Unsupported scheme " + baseUri.getScheme());
}
}
}
+ protected Map<String, String> getVariantsXOr() {
+ return variantsXOr;
+ }
+
// public static void main(String[] args) {
// if (args.length == 0)
// throw new IllegalArgumentException("Usage: <path to A2 base>");