]>
git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.repo/src/main/java/org/argeo/slc/repo/osgi/ArgeoOsgiDistribution.java
f0ab4e2e487d5e6a87f17d5d7dd66ef4ab9d19c8
1 package org
.argeo
.slc
.repo
.osgi
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Iterator
;
7 import org
.apache
.commons
.logging
.Log
;
8 import org
.apache
.commons
.logging
.LogFactory
;
9 import org
.argeo
.slc
.CategorizedNameVersion
;
10 import org
.argeo
.slc
.ModuleSet
;
11 import org
.argeo
.slc
.NameVersion
;
12 import org
.argeo
.slc
.build
.Distribution
;
13 import org
.argeo
.slc
.build
.ModularDistribution
;
14 import org
.argeo
.slc
.execution
.ExecutionFlow
;
15 import org
.argeo
.slc
.repo
.ArtifactDistribution
;
16 import org
.sonatype
.aether
.artifact
.Artifact
;
17 import org
.sonatype
.aether
.util
.artifact
.DefaultArtifact
;
19 /** A consistent and versioned OSGi distribution, which can be built and tested. */
20 public class ArgeoOsgiDistribution
extends ArtifactDistribution
implements
22 private final static Log log
= LogFactory
23 .getLog(ArgeoOsgiDistribution
.class);
25 private List
<Object
> modules
= new ArrayList
<Object
>();
27 public ArgeoOsgiDistribution(String coords
) {
32 if (log
.isDebugEnabled()) {
33 Iterator
<?
extends NameVersion
> nvIt
= nameVersions();
34 while (nvIt
.hasNext()) {
35 log
.debug(nvIt
.next());
41 // private static void print(ModuleSet moduleSet, Integer depth) {
42 // StringBuilder prefix = new StringBuilder();
43 // for (int i = 0; i < depth; i++) {
44 // prefix.append(' ');
46 // String p = prefix.toString();
47 // prefix.setLength(0);
48 // log.debug(p + "## " + moduleSet.toString());
49 // Iterator<? extends NameVersion> nvIt = moduleSet.nameVersions();
50 // while (nvIt.hasNext()) {
51 // NameVersion nv = nvIt.next();
52 // if (nv instanceof ModuleSet)
53 // print((ModuleSet) nv, depth + 1);
60 public void destroy() {
64 public Distribution
getModuleDistribution(String moduleName
,
65 String moduleVersion
) {
66 // NameVersion searched = new DefaultNameVersion(moduleName,
68 // for (Distribution ad : modules) {
69 // if (ad.equals(searched))
75 public Iterator
<NameVersion
> nameVersions() {
76 List
<NameVersion
> nameVersions
= new ArrayList
<NameVersion
>();
77 for (Object module
: modules
) {
78 // extract runnable from execution flow
79 if (module
instanceof ExecutionFlow
)
80 module
= ((ExecutionFlow
) module
).getRunnable();
82 if (module
instanceof ModuleSet
)
83 addNameVersions(nameVersions
, (ModuleSet
) module
);
84 else if (module
instanceof NameVersion
) {
85 NameVersion nv
= (NameVersion
) module
;
86 if (!nameVersions
.contains(nv
))
89 log
.warn("Ignored " + module
);
91 return nameVersions
.iterator();
94 private void addNameVersions(List
<NameVersion
> nameVersions
,
95 ModuleSet moduleSet
) {
96 Iterator
<?
extends NameVersion
> it
= moduleSet
.nameVersions();
97 while (it
.hasNext()) {
98 NameVersion nv
= it
.next();
99 if (!nameVersions
.contains(nv
))
100 nameVersions
.add(nv
);
104 public Object
getModulesDescriptor(String descriptorType
) {
105 // TODO Auto-generated method stub
109 public void setModules(List
<Object
> modules
) {
110 this.modules
= modules
;