X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.repo%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Frepo%2Fosgi%2FProcessDistribution.java;h=80401d73fd06c57927c05e950feb8cb59a627d5f;hb=dd56d33a4c2a98863709f07218c9af99e1e90bbb;hp=982492c99667da69979aee6ade87ad4d4e9e13b6;hpb=46f89b95f9bfeb224c2a803d91dbd52f5281c0f9;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ProcessDistribution.java b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ProcessDistribution.java index 982492c99..80401d73f 100644 --- a/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ProcessDistribution.java +++ b/runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ProcessDistribution.java @@ -11,11 +11,14 @@ import org.argeo.jcr.JcrUtils; import org.argeo.slc.CategorizedNameVersion; import org.argeo.slc.NameVersion; import org.argeo.slc.SlcException; +import org.argeo.slc.repo.ArgeoOsgiDistribution; +import org.argeo.slc.repo.ModularDistributionFactory; import org.argeo.slc.repo.OsgiFactory; import org.argeo.slc.repo.maven.MavenConventionsUtils; import org.sonatype.aether.artifact.Artifact; import org.sonatype.aether.util.artifact.DefaultArtifact; +/** Executes the processes required so that all managed bundles are available. */ public class ProcessDistribution implements Runnable { private final static Log log = LogFactory.getLog(ProcessDistribution.class); @@ -27,35 +30,21 @@ public class ProcessDistribution implements Runnable { try { javaSession = osgiFactory.openJavaSession(); - Iterator it = osgiDistribution.nameVersions(); - while (it.hasNext()) { - NameVersion t = it.next(); - if (log.isTraceEnabled()) - log.trace("Check " + t + "..."); - if (!(t instanceof CategorizedNameVersion)) - throw new SlcException("Unsupported type " + t.getClass()); - CategorizedNameVersion nv = (CategorizedNameVersion) t; - Artifact artifact = new DefaultArtifact(nv.getCategory(), - nv.getName(), "jar", nv.getVersion()); - String path = MavenConventionsUtils.artifactPath("/", artifact); - if (!javaSession.itemExists(path)) { - // if (nv instanceof Runnable) { - // if (log.isDebugEnabled()) - // log.debug("Run " + nv + "..."); - // ((Runnable) nv).run(); - // } else - if (nv instanceof BndWrapper) { - if (log.isDebugEnabled()) - log.debug("Run factory for : " + nv + "..."); - ((BndWrapper) nv).getFactory().run(); - } else { - log.warn("Skip unsupported : " + nv); - } - } else { - if (log.isDebugEnabled()) - log.debug("Already available : " + nv); - } - } + for (Iterator it = osgiDistribution + .nameVersions(); it.hasNext();) + processNameVersion(javaSession, it.next()); + + ModularDistributionFactory mdf = new ModularDistributionFactory( + javaSession, osgiDistribution); + mdf.run(); + + // TODO why is the created distribution not automatically indexed? + // osgiFactory.indexNode(node); + // javaSession.save(); + + // Node artifact = createDistributionArtifact(javaSession, + // osgiDistribution); + } catch (RepositoryException e) { throw new SlcException("Cannot process distribution " + osgiDistribution, e); @@ -64,6 +53,33 @@ public class ProcessDistribution implements Runnable { } } + protected void processNameVersion(Session javaSession, + NameVersion nameVersion) throws RepositoryException { + if (log.isTraceEnabled()) + log.trace("Check " + nameVersion + "..."); + if (!(nameVersion instanceof CategorizedNameVersion)) + throw new SlcException("Unsupported type " + nameVersion.getClass()); + CategorizedNameVersion nv = (CategorizedNameVersion) nameVersion; + Artifact artifact = new DefaultArtifact(nv.getCategory(), nv.getName(), + "jar", nv.getVersion()); + String path = MavenConventionsUtils.artifactPath("/", artifact); + if (!javaSession.itemExists(path)) { + if (nv instanceof BndWrapper) { + if (log.isDebugEnabled()) + log.debug("Run factory for : " + nv + "..."); + ((BndWrapper) nv).getFactory().run(); + } else if (nv instanceof Runnable) { + ((Runnable) nv).run(); + } else { + log.warn("Skip unsupported : " + nv); + } + } else { + if (log.isTraceEnabled()) + log.trace("Already available : " + nv); + } + } + + /* DEPENDENCY INJECTION */ public void setOsgiDistribution(ArgeoOsgiDistribution osgiDistribution) { this.osgiDistribution = osgiDistribution; } @@ -71,5 +87,4 @@ public class ProcessDistribution implements Runnable { public void setOsgiFactory(OsgiFactory osgiFactory) { this.osgiFactory = osgiFactory; } - -} +} \ No newline at end of file