output.. = bin/
bin.includes = META-INF/,\
.
+additional.bundles = org.argeo.init
--- /dev/null
+package org.argeo.slc.cms.deploy;
+
+import org.argeo.slc.deploy.DeployedSystem;
+
+public interface CmsDeployedSystem extends DeployedSystem {
+
+}
--- /dev/null
+package org.argeo.slc.cms.deploy;
+
+import org.argeo.slc.deploy.DeploymentData;
+
+public interface CmsDeploymentData extends DeploymentData {
+
+}
--- /dev/null
+package org.argeo.slc.cms.deploy;
+
+import java.nio.file.Path;
+
+import org.argeo.slc.deploy.TargetData;
+
+public interface CmsTargetData extends TargetData {
+ Path getInstanceData();
+
+ Integer getHttpPort();
+
+}
import java.nio.file.Path;
-import org.argeo.slc.deploy.TargetData;
-
-public class SimpleCmsTargetData implements TargetData {
- private Integer httpPort;
+public class SimpleCmsTargetData implements CmsTargetData {
private Path instanceData;
+ private Integer httpPort;
+
+ public SimpleCmsTargetData(Path instanceData, Integer httpPort) {
+ this.instanceData = instanceData;
+ this.httpPort = httpPort;
+ }
+
+ public Integer getHttpPort() {
+ return httpPort;
+ }
+
+ public void setHttpPort(Integer httpPort) {
+ this.httpPort = httpPort;
+ }
+
+ public Path getInstanceData() {
+ return instanceData;
+ }
+
+ public void setInstanceData(Path instanceData) {
+ this.instanceData = instanceData;
+ }
+
}
--- /dev/null
+package org.argeo.slc.cms.deploy.osgi;
+
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.ModularDistribution;
+import org.argeo.slc.cms.deploy.CmsDeployedSystem;
+import org.argeo.slc.cms.deploy.CmsDeploymentData;
+import org.argeo.slc.cms.deploy.CmsTargetData;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+import org.osgi.framework.BundleContext;
+
+public class CmsOsgiDeployedSystem implements CmsDeployedSystem {
+ private ModularDistribution distribution;
+ private CmsTargetData targetData;
+ private CmsDeploymentData deploymentData;
+
+ private BundleContext systemBundleContext;
+
+ public CmsOsgiDeployedSystem(BundleContext systemBundleContext, ModularDistribution distribution,
+ CmsTargetData targetData, CmsDeploymentData deploymentData) {
+ this.systemBundleContext = systemBundleContext;
+
+ this.distribution = distribution;
+ this.targetData = targetData;
+ this.deploymentData = deploymentData;
+ }
+
+ @Override
+ public String getDeployedSystemId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Distribution getDistribution() {
+ return distribution;
+ }
+
+ @Override
+ public DeploymentData getDeploymentData() {
+ return deploymentData;
+ }
+
+ @Override
+ public TargetData getTargetData() {
+ return targetData;
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cms.deploy.osgi;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.TreeMap;
+
+import org.argeo.init.a2.A2Source;
+import org.argeo.init.a2.FsA2Source;
+import org.argeo.init.osgi.OsgiBoot;
+import org.argeo.init.osgi.OsgiRuntimeContext;
+import org.argeo.slc.WellKnownConstants;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.cms.deploy.CmsDeployedSystem;
+import org.argeo.slc.cms.deploy.CmsTargetData;
+import org.argeo.slc.cms.deploy.SimpleCmsTargetData;
+import org.argeo.slc.cms.distribution.A2Distribution;
+import org.argeo.slc.deploy.DeployedSystem;
+import org.argeo.slc.deploy.Deployment;
+import org.argeo.slc.deploy.DeploymentData;
+import org.argeo.slc.deploy.TargetData;
+
+public class CmsOsgiDeployment implements Deployment {
+
+ private A2Distribution distribution;
+ private CmsTargetData targetData;
+
+ private CmsDeployedSystem deployedSystem;
+
+ @Override
+ public void run() {
+ try {
+ Map<String, String> config = new TreeMap<>();
+
+ // sources
+ StringJoiner sourcesProperty = new StringJoiner(",");
+ for (A2Source a2Source : distribution.getA2Sources()) {
+ sourcesProperty.add(a2Source.getUri().toString());
+ }
+ config.put(OsgiBoot.PROP_ARGEO_OSGI_SOURCES, sourcesProperty.toString());
+
+ // target
+ config.put(WellKnownConstants.OSGI_INSTANCE_AREA, targetData.getInstanceData().toUri().toString());
+ if (targetData.getHttpPort() != null) {
+ config.put(WellKnownConstants.OSGI_HTTP_PORT, targetData.getHttpPort().toString());
+ }
+
+ Path configurationArea = Files.createTempDirectory("slc-cms-test");
+ config.put(WellKnownConstants.OSGI_CONFIGURATION_AREA, configurationArea.toString());
+
+ // initialise
+ OsgiRuntimeContext runtimeContext = new OsgiRuntimeContext(config);
+ runtimeContext.run();
+
+ deployedSystem = new CmsOsgiDeployedSystem(runtimeContext.getFramework().getBundleContext(), distribution,
+ targetData, null);
+
+ runtimeContext.waitForStop(0);
+ } catch (IOException | InterruptedException e) {
+ throw new IllegalStateException("Cannot run OSGi deployment", e);
+ }
+
+ }
+
+ @Override
+ public DeployedSystem getDeployedSystem() {
+ return deployedSystem;
+ }
+
+ @Override
+ public void setTargetData(TargetData targetData) {
+ this.targetData = (CmsTargetData) targetData;
+ }
+
+ @Override
+ public void setDeploymentData(DeploymentData deploymentData) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setDistribution(Distribution distribution) {
+ this.distribution = (A2Distribution) distribution;
+ }
+
+ public static void main(String[] args) throws IOException {
+ Path userHome = Paths.get(System.getProperty("user.home"));
+
+ // distribution
+ Path a2Base = userHome.resolve("dev/git/unstable/output/a2");
+ A2Distribution distribution = new A2Distribution();
+ distribution.getA2Sources().add(new FsA2Source(a2Base));
+
+ // target data
+ Path instanceData = userHome.resolve("dev/git/unstable/argeo-slc/sdk/exec/cms-deployment/data");
+ Files.createDirectories(instanceData);
+ Integer httpPort = 7070;
+ SimpleCmsTargetData targetData = new SimpleCmsTargetData(instanceData, httpPort);
+
+ CmsOsgiDeployment deployment = new CmsOsgiDeployment();
+ deployment.setDistribution(distribution);
+ deployment.setTargetData(targetData);
+ deployment.run();
+ }
+
+}
--- /dev/null
+package org.argeo.slc.cms.distribution;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.argeo.init.a2.A2Branch;
+import org.argeo.init.a2.A2Component;
+import org.argeo.init.a2.A2Contribution;
+import org.argeo.init.a2.A2Module;
+import org.argeo.init.a2.A2Source;
+import org.argeo.slc.CategoryNameVersion;
+import org.argeo.slc.DefaultCategoryNameVersion;
+import org.argeo.slc.NameVersion;
+import org.argeo.slc.build.Distribution;
+import org.argeo.slc.build.ModularDistribution;
+
+public class A2Distribution implements ModularDistribution {
+ private List<A2Source> a2Sources = new ArrayList<>();
+
+ @Override
+ public String getDistributionId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getVersion() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Iterator<? extends NameVersion> nameVersions() {
+ List<CategoryNameVersion> nameVersions = new ArrayList<>();
+ for (A2Source a2Source : a2Sources) {
+ for (A2Contribution a2Contribution : a2Source.listContributions(null)) {
+ for (A2Component a2Component : a2Contribution.listComponents(null)) {
+ for (A2Branch a2Branch : a2Component.listBranches(null)) {
+ for (A2Module a2Module : a2Branch.listModules(null)) {
+ CategoryNameVersion nameVersion = new DefaultCategoryNameVersion(a2Contribution.getId(),
+ a2Component.getId(), a2Module.getVersion().toString());
+ nameVersions.add(nameVersion);
+ }
+ }
+ }
+ }
+ }
+ return nameVersions.iterator();
+ }
+
+ @Override
+ public Distribution getModuleDistribution(String moduleName, String moduleVersion) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getModulesDescriptor(String descriptorType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<A2Source> getA2Sources() {
+ return a2Sources;
+ }
+
+
+}
--- /dev/null
+package org.argeo.slc.cms.distribution;
+
+import org.argeo.init.a2.A2Module;
+import org.argeo.slc.build.Distribution;
+
+public class A2ModuleDistribution implements Distribution {
+ private A2Module a2Module;
+
+ @Override
+ public String getDistributionId() {
+ return a2Module.getCoordinates();
+ }
+
+}
--- /dev/null
+package org.argeo.slc;
+
+/**
+ * Centralises constant values related to software systems, which are well
+ * defined and not expected to change within a major version cycle of SLC, but
+ * which are not necessarily defined in core Java.
+ */
+public interface WellKnownConstants {
+
+ /*
+ * OSGi
+ */
+ final static String OSGI_INSTANCE_AREA = "osgi.instance.area";
+ final static String OSGI_CONFIGURATION_AREA = "osgi.configuration.area";
+
+ final static String OSGI_HTTP_PORT = "org.osgi.service.http.port";
+}