]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.init/src/org/argeo/init/a2/ClasspathSource.java
Remove unused configurations in build.properties
[lgpl/argeo-commons.git] / org.argeo.init / src / org / argeo / init / a2 / ClasspathSource.java
1 package org.argeo.init.a2;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.nio.file.Path;
6 import java.nio.file.Paths;
7 import java.util.Arrays;
8 import java.util.List;
9
10 import org.argeo.init.osgi.OsgiBootUtils;
11 import org.osgi.framework.Version;
12
13 /**
14 * A provisioning source based on the linear classpath with which the JCM has
15 * been started.
16 */
17 public class ClasspathSource extends AbstractProvisioningSource {
18 void load() throws IOException {
19 A2Contribution classpathContribution = getOrAddContribution( A2Contribution.CLASSPATH);
20 List<String> classpath = Arrays.asList(System.getProperty("java.class.path").split(File.pathSeparator));
21 parts: for (String part : classpath) {
22 Path file = Paths.get(part);
23 Version version;
24 try {
25 version = new Version(readVersionFromModule(file));
26 } catch (Exception e) {
27 // ignore non OSGi
28 continue parts;
29 }
30 String moduleName = readSymbolicNameFromModule(file);
31 A2Component component = classpathContribution.getOrAddComponent(moduleName);
32 A2Module module = component.getOrAddModule(version, file);
33 if (OsgiBootUtils.isDebug())
34 OsgiBootUtils.debug("Registered " + module);
35 }
36
37 }
38 }