added a location accessor
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/Module.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/Module.java
index e850d46..3e8eb6e 100644
--- a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/Module.java
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/Module.java
@@ -1,5 +1,6 @@
package org.eclipse.fx.core.modulesystem;
+import java.nio.file.Path;
import java.util.Optional;
import org.eclipse.fx.core.Version;
@@ -7,4 +8,5 @@
public interface Module {
public String getId();
public Optional<Version> getVersion();
+ public Optional<Path> getLocation();
}
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/NoModuleSystem.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/NoModuleSystem.java
index 82ab0a3..bc8b40f 100644
--- a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/NoModuleSystem.java
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/NoModuleSystem.java
@@ -1,5 +1,6 @@
package org.eclipse.fx.core.modulesystem;
+import java.nio.file.Path;
import java.util.Optional;
import org.eclipse.fx.core.Version;
@@ -16,6 +17,11 @@
public Optional<Version> getVersion() {
return Optional.empty();
}
+
+ @Override
+ public Optional<Path> getLocation() {
+ return Optional.empty();
+ }
}
private static NoModuleSystem INSTANCE;
@@ -38,4 +44,5 @@
public Optional<Module> getModuleById(String moduleId) {
return Optional.of(this.module);
}
+
}
diff --git a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/OSGiModule.java b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/OSGiModule.java
index 56361c3..ccf6a52 100644
--- a/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/OSGiModule.java
+++ b/bundles/runtime/org.eclipse.fx.core/src/org/eclipse/fx/core/modulesystem/OSGiModule.java
@@ -1,7 +1,13 @@
package org.eclipse.fx.core.modulesystem;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.Optional;
+import org.eclipse.fx.core.IOUtils;
import org.eclipse.fx.core.Version;
import org.osgi.framework.Bundle;
@@ -22,6 +28,29 @@
return Optional.of(new BundleVersion(this.bundle.getVersion()));
}
+ @Override
+ public Optional<Path> getLocation() {
+ Optional<URL> optUrl = IOUtils.getLocalURL(this.bundle.getResource("META-INF/MANIFEST.MF")); //$NON-NLS-1$
+ if( optUrl.isPresent() ) {
+ URL url = optUrl.get();
+ if( url.getProtocol().equals("file") ) { //$NON-NLS-1$
+ try {
+ Path path = Paths.get(url.toURI());
+ return Optional.of(path.getParent().getParent());
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if( url.getProtocol().equals("jar") ) {
+ String path = url.getPath();
+ if( path.startsWith("file:") ) {
+ return Optional.of(Paths.get(URI.create(path.substring(0,path.indexOf('!')))));
+ }
+ }
+ }
+ return null;
+ }
+
static class BundleVersion extends Version {
private final org.osgi.framework.Version version;