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=9ea467d773d9d5a507ad6e60b835d9cc6c49b7fa;hb=399702cec859f48ec171c30d268c55eb632d472a;hp=26f063991b936f049cdf7ee12f754d3cf1d430ab;hpb=fa099b50351a61638bdb1e3becc45ace640c15f2;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 26f063991..9ea467d77 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); @@ -26,28 +29,16 @@ public class ProcessDistribution implements Runnable { Session javaSession = null; try { javaSession = osgiFactory.openJavaSession(); + for (Iterator it = osgiDistribution + .nameVersions(); it.hasNext();) + processNameVersion(javaSession, it.next()); + + // explicitly create the corresponding modular distribution as we + // have here all necessary info. + ModularDistributionFactory mdf = new ModularDistributionFactory( + osgiFactory, osgiDistribution); + mdf.run(); - Iterator it = osgiDistribution.nameVersions(); - while (it.hasNext()) { - NameVersion t = it.next(); - if (log.isDebugEnabled()) - log.debug("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 { - log.warn("Skipped unsupported " + nv); - } - } - } } catch (RepositoryException e) { throw new SlcException("Cannot process distribution " + osgiDistribution, e); @@ -56,6 +47,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; } @@ -63,5 +81,4 @@ public class ProcessDistribution implements Runnable { public void setOsgiFactory(OsgiFactory osgiFactory) { this.osgiFactory = osgiFactory; } - -} +} \ No newline at end of file