diff --git a/bundles/org.openhab.core.karaf/ESH-INF/config/config.xml b/bundles/org.openhab.core.karaf/ESH-INF/config/config.xml new file mode 100644 index 000000000..35120105b --- /dev/null +++ b/bundles/org.openhab.core.karaf/ESH-INF/config/config.xml @@ -0,0 +1,20 @@ + + + + + + + The runtime package to use for this openHAB instance + + + + + + + + + \ No newline at end of file diff --git a/bundles/org.openhab.core.karaf/OSGI-INF/featureinstaller.xml b/bundles/org.openhab.core.karaf/OSGI-INF/featureinstaller.xml index 5fda86828..01470f735 100644 --- a/bundles/org.openhab.core.karaf/OSGI-INF/featureinstaller.xml +++ b/bundles/org.openhab.core.karaf/OSGI-INF/featureinstaller.xml @@ -9,8 +9,11 @@ http://www.eclipse.org/legal/epl-v10.html --> - + + + + diff --git a/bundles/org.openhab.core.karaf/build.properties b/bundles/org.openhab.core.karaf/build.properties index 1dac35585..55400e00b 100644 --- a/bundles/org.openhab.core.karaf/build.properties +++ b/bundles/org.openhab.core.karaf/build.properties @@ -1,5 +1,6 @@ output.. = target/classes/ bin.includes = META-INF/,\ .,\ - OSGI-INF/ + OSGI-INF/,\ + ESH-INF/ source.. = src/main/java/ diff --git a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java index f3064f937..99f70592e 100644 --- a/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java +++ b/bundles/org.openhab.core.karaf/src/main/java/org/openhab/core/karaf/internal/FeatureInstaller.java @@ -12,12 +12,13 @@ import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.apache.karaf.features.Feature; import org.apache.karaf.features.FeaturesService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * This service reads addons.cfg and installs listed addons (= Karaf features). + * This service reads addons.cfg and installs listed addons (= Karaf features) and the selected package. * * @author Kai Kreuzer */ @@ -25,6 +26,8 @@ public class FeatureInstaller { public static final String PREFIX = "openhab-"; + public static final String PREFIX_PACKAGE = "package-"; + public static final String[] addonTypes = new String[] { "binding", "ui", "persistence", "action", "tts", "transformation", "misc" }; @@ -41,10 +44,17 @@ public class FeatureInstaller { } protected void activate(final Map config) { + modified(config); + } + + protected void modified(final Map config) { ExecutorService scheduler = Executors.newSingleThreadExecutor(); scheduler.execute(new Runnable() { @Override public void run() { + installPackage(config); + + // install addons for (String type : addonTypes) { Object install = config.get(type); if (install instanceof String) { @@ -52,17 +62,46 @@ public class FeatureInstaller { } } } + }); } private void installFeatures(String type, String install) { for (String addon : install.split(",")) { String name = PREFIX + type + "-" + addon.trim(); - try { - featuresService.installFeature(name); - } catch (Exception e) { - logger.error("Failed installing feature '{}'", name); - } + installFeature(name); } } + + private void installFeature(String name) { + try { + featuresService.installFeature(name); + logger.info("Installed '{}'", name); + } catch (Exception e) { + logger.error("Failed installing '{}': {}", name, e.getMessage()); + } + } + + private void installPackage(final Map config) { + Object packageName = config.get("package"); + String name = PREFIX + PREFIX_PACKAGE + ((String) packageName).trim(); + installFeature(name); + + // uninstall all other packages + try { + for (Feature feature : featuresService.listFeatures()) { + if (feature.getName().startsWith(PREFIX + PREFIX_PACKAGE) && !feature.getName().equals(name) + && featuresService.isInstalled(feature)) { + try { + featuresService.uninstallFeature(feature.getName()); + } catch (Exception e) { + logger.error("Failed uninstalling '{}': {}", feature.getName(), e.getMessage()); + } + } + } + } catch (Exception e) { + logger.error("Failed retrieving features: {}", e.getMessage()); + } + } + } diff --git a/features/karaf/src/main/feature/feature.xml b/features/karaf/src/main/feature/feature.xml index e365a6092..0dfe2c9f7 100644 --- a/features/karaf/src/main/feature/feature.xml +++ b/features/karaf/src/main/feature/feature.xml @@ -11,8 +11,9 @@ --> - + shk-esh-base + shk-esh-io-console-karaf mvn:org.openhab.core/org.openhab.core/${project.version} shell mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/${dep.karaf.version} @@ -21,13 +22,20 @@ mvn:org.openhab.core/org.openhab.core.karaf/${project.version} - -
${project.description}
- shk-esh-io-console-karaf + + openhab-runtime-base + openhab-dashboard + openhab-misc-restdocs + + + openhab-runtime-base openhab-dashboard openhab-misc-restdocs openhab-misc-certificate + openhab-ui-paper + openhab-ui-basic + openhab-ui-classic