X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.cms%2Fsrc%2Forg%2Fargeo%2Fslc%2Fcms%2Fdeploy%2Fosgi%2FOsgiCmsDeployment.java;h=1c472e70fd8491c5e95a2a24e79c986369843712;hb=82fcb6324dc57a36a8c9c4f4b0e564a1f4ef97de;hp=91aba29459a8b7cd652f0f1bed05d966fb624ab0;hpb=753604c3ba7481e4bdf1e87f1ffc5e0eec9b18ba;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.cms/src/org/argeo/slc/cms/deploy/osgi/OsgiCmsDeployment.java b/org.argeo.slc.cms/src/org/argeo/slc/cms/deploy/osgi/OsgiCmsDeployment.java index 91aba2945..1c472e70f 100644 --- a/org.argeo.slc.cms/src/org/argeo/slc/cms/deploy/osgi/OsgiCmsDeployment.java +++ b/org.argeo.slc.cms/src/org/argeo/slc/cms/deploy/osgi/OsgiCmsDeployment.java @@ -12,10 +12,11 @@ import java.util.Map; import java.util.StringJoiner; import java.util.TreeMap; +import org.argeo.api.a2.A2Source; +import org.argeo.api.a2.FsA2Source; +import org.argeo.api.init.InitConstants; +import org.argeo.api.init.RuntimeContext; import org.argeo.cms.CmsDeployProperty; -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; @@ -51,11 +52,16 @@ public class OsgiCmsDeployment implements Deployment { for (A2Source a2Source : distribution.getA2Sources()) { sourcesProperty.add(a2Source.getUri().toString()); } - config.put(OsgiBoot.PROP_ARGEO_OSGI_SOURCES, sourcesProperty.toString()); + config.put(InitConstants.PROP_ARGEO_OSGI_SOURCES, sourcesProperty.toString()); // 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()); } @@ -68,7 +74,7 @@ public class OsgiCmsDeployment implements Deployment { List modules = deploymentData.getModulesToActivate(startLevel); if (modules.size() != 0) { String startProperty = String.join(",", modules); - config.put(OsgiBoot.PROP_ARGEO_OSGI_START + "." + startLevel, startProperty); + config.put(InitConstants.PROP_ARGEO_OSGI_START + "." + startLevel, startProperty); } } @@ -77,11 +83,19 @@ public class OsgiCmsDeployment implements Deployment { "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()) { @@ -89,11 +103,12 @@ public class OsgiCmsDeployment implements Deployment { logger.log(Level.TRACE, () -> key + "=" + config.get(key)); } + // FIXME use runtime manager runtimeContext = new OsgiRuntimeContext(config); runtimeContext.run(); - deployedSystem = new OsgiCmsDeployedSystem(runtimeContext.getFramework().getBundleContext(), distribution, - targetData, deploymentData); +// deployedSystem = new OsgiCmsDeployedSystem(runtimeContext.getFramework().getBundleContext(), distribution, +// targetData, deploymentData); } catch (Exception e) { throw new IllegalStateException("Cannot run OSGi deployment", e); @@ -126,6 +141,15 @@ public class OsgiCmsDeployment implements Deployment { } public static void main(String[] args) { + RuntimeContext runtimeContext = test(); + try { + runtimeContext.waitForStop(0); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public static RuntimeContext test() { try { Path userHome = Paths.get(System.getProperty("user.home")); @@ -137,12 +161,12 @@ public class OsgiCmsDeployment implements Deployment { 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(); @@ -180,11 +204,11 @@ public class OsgiCmsDeployment implements Deployment { boolean multiple = true; if (multiple) { // wait a bit - Thread.sleep(5000); +// Thread.sleep(5000); 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); @@ -193,11 +217,11 @@ public class OsgiCmsDeployment implements Deployment { deployment2.run(); } - // deployment.getRuntimeContext().waitForStop(0); - - } catch (IOException | InterruptedException e) { + return deployment.getRuntimeContext(); + } catch (IOException e) { e.printStackTrace(); System.exit(1); + return null; } }