+
+Bundle-Activator: org.argeo.slc.init.osgi.SlcInitActivator
+
Import-Package: \
org.apache.commons.logging,\
org.postgresql;version="[42,43)";resolution:=optional,\
-org.apache.commons.vfs2.*resolution:=optional,\
+org.apache.commons.vfs2.*;resolution:=optional,\
org.osgi.*;version="0.0.0",\
*
\ No newline at end of file
public interface CmsTargetData extends TargetData {
Path getInstanceData();
+ String getHost();
+
Integer getHttpPort();
}
public class SimpleCmsTargetData implements CmsTargetData {
private Path instanceData;
+ private String host;
private Integer httpPort;
- public SimpleCmsTargetData(Path instanceData, Integer httpPort) {
+ public SimpleCmsTargetData(Path instanceData, String host, Integer httpPort) {
this.instanceData = instanceData;
+ this.host = host;
this.httpPort = httpPort;
}
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String hostname) {
+ this.host = hostname;
+ }
+
public Integer getHttpPort() {
return httpPort;
}
private CmsTargetData targetData;
private CmsDeploymentData deploymentData;
- private BundleContext systemBundleContext;
+ // private BundleContext systemBundleContext;
public OsgiCmsDeployedSystem(BundleContext systemBundleContext, ModularDistribution distribution,
CmsTargetData targetData, CmsDeploymentData deploymentData) {
- this.systemBundleContext = systemBundleContext;
+ // this.systemBundleContext = systemBundleContext;
this.distribution = distribution;
this.targetData = targetData;
// target
config.put(WellKnownConstants.OSGI_INSTANCE_AREA,
targetData.getInstanceData().toRealPath().toUri().toString());
+
+ if (targetData.getHost() != null) {
+ config.put(CmsDeployProperty.HOST.getProperty(), targetData.getHost().toString());
+ }
+
if (targetData.getHttpPort() != null) {
config.put(CmsDeployProperty.HTTP_PORT.getProperty(), targetData.getHttpPort().toString());
}
"sun.security.util,sun.security.internal.spec,sun.security.provider,com.sun.net.httpserver,com.sun.jndi.ldap,com.sun.jndi.ldap.sasl,com.sun.jndi.dns,com.sun.security.jgss,com.sun.nio.file,com.sun.nio.sctp");
config.put("eclipse.ignoreApp", "true");
config.put("osgi.noShutdown", "true");
-
+ config.put("osgi.clean", "true");
+ config.put("osgi.framework.useSystemProperties", "false");
+
config.put("argeo.directory", "dc=example,dc=com.ldif");
- if (targetData instanceof OsgiCmsTargetData osgiCmsTargetData && osgiCmsTargetData.getTelnetPort() != null)
- config.put("osgi.console", osgiCmsTargetData.getTelnetPort().toString());
+ if (targetData instanceof OsgiCmsTargetData osgiCmsTargetData
+ && osgiCmsTargetData.getTelnetPort() != null) {
+ String hostStr = "";
+ if (targetData.getHost() != null) {
+ hostStr = targetData.getHost().toString() + ":";
+ }
+ config.put("osgi.console", hostStr + osgiCmsTargetData.getTelnetPort().toString());
+ }
// initialise
for (String key : config.keySet()) {
xOr.put("swt", "rap");
xOr.put("log", "syslogger");
xOr.put("crypto", "fips");
- distribution.getA2Sources().add(new FsA2Source(a2Base, xOr, true));
+ distribution.getA2Sources().add(new FsA2Source(a2Base, xOr, true, null, null));
// target data
Path instanceData = userHome.resolve("dev/git/unstable/argeo-slc/sdk/exec/cms-deployment/data");
Files.createDirectories(instanceData);
- OsgiCmsTargetData targetData = new OsgiCmsTargetData(instanceData, 7070, 2323);
+ OsgiCmsTargetData targetData = new OsgiCmsTargetData(instanceData, "host1", 7070, 2323);
// deployment data
SimpleCmsDeploymentData deploymentData = new SimpleCmsDeploymentData();
Path instanceData2 = userHome.resolve("dev/git/unstable/argeo-slc/sdk/exec/cms-deployment2/data");
Files.createDirectories(instanceData2);
- OsgiCmsTargetData targetData2 = new OsgiCmsTargetData(instanceData2, 7071, 2324);
+ OsgiCmsTargetData targetData2 = new OsgiCmsTargetData(instanceData2, "host2", 7070, 2323);
OsgiCmsDeployment deployment2 = new OsgiCmsDeployment();
deployment2.setDistribution(distribution);
public class OsgiCmsTargetData extends SimpleCmsTargetData {
private Integer telnetPort;
- public OsgiCmsTargetData(Path instanceData, Integer httpPort, Integer telnetPort) {
- super(instanceData, httpPort);
+ public OsgiCmsTargetData(Path instanceData, String host, Integer httpPort, Integer telnetPort) {
+ super(instanceData, host, httpPort);
this.telnetPort = telnetPort;
}
--- /dev/null
+package org.argeo.slc.init.osgi;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.argeo.api.cms.CmsLog;
+import org.argeo.cms.CmsDeployProperty;
+import org.argeo.init.RuntimeManager;
+import org.argeo.init.osgi.OsgiBoot;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class SlcInitActivator implements BundleActivator {
+ private final static CmsLog log = CmsLog.getLog(SlcInitActivator.class);
+
+ private ServiceTracker<RuntimeManager, RuntimeManager> runtimeManagerSt;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ Path userHome = Paths.get(System.getProperty("user.home"));
+// OsgiCmsDeployment.main(new String[0]);
+ runtimeManagerSt = new ServiceTracker<>(context, RuntimeManager.class, null) {
+
+ @Override
+ public RuntimeManager addingService(ServiceReference<RuntimeManager> reference) {
+ RuntimeManager runtimeManager = super.addingService(reference);
+ log.debug("Found runtime manager " + runtimeManager);
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ return;
+ }
+
+ runtimeManager.startRuntime("cms/test", (config) -> {
+ config.put("osgi.clean", "true");
+ // config.put("argeo.osgi.sources", "a2+reference:///?osgi=equinox");
+ config.put("osgi.console", "2024");
+ config.put(CmsDeployProperty.SSHD_PORT.getProperty(), "2222");
+// config.put(CmsDeployProperty.HTTP_PORT.getProperty(), "7070");
+// config.put(CmsDeployProperty.HOST.getProperty(),
+// "localhost");
+ Path instanceData = userHome
+ .resolve("dev/git/unstable/argeo-slc/sdk/exec/cms-deployment/data");
+ config.put(OsgiBoot.PROP_OSGI_INSTANCE_AREA, instanceData.toUri().toString());
+ config.put("argeo.directory", "dc=example,dc=com.ldif");
+
+// for (String key : config.keySet()) {
+// System.out.println(key + "=" + config.get(key));
+//// log.debug(() -> key + "=" + config.get(key));
+// }
+ });
+ }
+ }.start();
+
+ return runtimeManager;
+ }
+
+ };
+ runtimeManagerSt.open(true);
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ }
+
+}