You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2019/06/13 06:23:14 UTC
[sling-org-apache-sling-feature-launcher] branch master updated:
SLING-8421: only use the reference: protocol if the artifact is from a file
url.
This is an automated email from the ASF dual-hosted git repository.
pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git
The following commit(s) were added to refs/heads/master by this push:
new d0c3783 SLING-8421: only use the reference: protocol if the artifact is from a file url.
d0c3783 is described below
commit d0c37831393cf4ea2d9b52010dff003d0b7b9fa3
Author: Karl Pauls <ka...@gmail.com>
AuthorDate: Thu Jun 13 08:22:48 2019 +0200
SLING-8421: only use the reference: protocol if the artifact is from a file url.
---
.../launcher/impl/launchers/AbstractRunner.java | 32 ++++++++--------------
.../launcher/impl/launchers/FrameworkLauncher.java | 1 -
2 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
index d4deb1a..4229e49 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
@@ -16,8 +16,6 @@
*/
package org.apache.sling.feature.launcher.impl.launchers;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Array;
@@ -32,7 +30,6 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
@@ -45,8 +42,6 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.startlevel.BundleStartLevel;
@@ -76,8 +71,7 @@ public abstract class AbstractRunner implements Callable<Integer> {
logger = LoggerFactory.getLogger("launcher");
}
- protected void setupFramework(final Framework framework, final Map<Integer, List<URL>> bundlesMap)
- throws BundleException {
+ protected void setupFramework(final Framework framework, final Map<Integer, List<URL>> bundlesMap) throws BundleException {
if ( !configurations.isEmpty() ) {
this.configAdminTracker = new ServiceTracker<>(framework.getBundleContext(),
"org.osgi.service.cm.ConfigurationAdmin",
@@ -141,17 +135,10 @@ public abstract class AbstractRunner implements Callable<Integer> {
this.installerTracker.open();
}
- try {
- this.install(framework, bundlesMap);
- } catch ( final IOException ioe) {
- throw new BundleException("Unable to install bundles.", ioe);
- }
+ this.install(framework, bundlesMap);
}
- protected boolean startFramework(final Framework framework, long timeout, TimeUnit unit) throws BundleException, InterruptedException
- {
- CountDownLatch latch = new CountDownLatch(1);
-
+ protected boolean startFramework(final Framework framework, long timeout, TimeUnit unit) throws BundleException, InterruptedException {
Executor executor = Executors.newSingleThreadExecutor();
Future<Void> result = ((ExecutorService) executor).submit(new Callable<Void>()
{
@@ -227,8 +214,7 @@ public abstract class AbstractRunner implements Callable<Integer> {
* @param bundleMap The map with the bundles indexed by start level
* @throws IOException, BundleException If anything goes wrong.
*/
- private void install(final Framework framework, final Map<Integer, List<URL>> bundleMap)
- throws IOException, BundleException {
+ private void install(final Framework framework, final Map<Integer, List<URL>> bundleMap) throws BundleException {
final BundleContext bc = framework.getBundleContext();
int defaultStartLevel = getProperty(bc, "felix.startlevel.bundle", 1);
for(final Integer startLevel : sortStartLevels(bundleMap.keySet(), defaultStartLevel)) {
@@ -237,9 +223,15 @@ public abstract class AbstractRunner implements Callable<Integer> {
for(final URL file : bundleMap.get(startLevel)) {
logger.debug("- {}", file);
- // use reference protocol. This avoids copying the binary to the cache directory
+ // use reference protocol if possible. This avoids copying the binary to the cache directory
// of the framework
- final Bundle bundle = bc.installBundle("reference:" + file, null);
+ String location = "";
+ if (file.getProtocol().equals("file")) {
+ location = "reference:";
+ }
+ location = location + file.toString();
+
+ final Bundle bundle = bc.installBundle(location, null);
// fragment?
if ( !isSystemBundleFragment(bundle) && getFragmentHostHeader(bundle) == null ) {
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
index eab44be..f5668be 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/FrameworkLauncher.java
@@ -16,7 +16,6 @@
*/
package org.apache.sling.feature.launcher.impl.launchers;
-import java.io.File;
import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.HashMap;