Repository: karaf Updated Branches: refs/heads/master ef29ffdfe -> 8db31d312
[KARAF-4489] Introduce configCfgStore property in etc/org.apache.karaf.features.cfg to define if the features service automatically creates cfg file for <config/> element Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8db31d31 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8db31d31 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8db31d31 Branch: refs/heads/master Commit: 8db31d312376da262971bb61a1ecbe9279a15905 Parents: ef29ffd Author: Jean-Baptiste Onofré <[email protected]> Authored: Wed Apr 13 13:49:52 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Wed Apr 13 13:52:05 2016 +0200 ---------------------------------------------------------------------- .../resources/etc/org.apache.karaf.features.cfg | 5 ++ .../apache/karaf/features/FeaturesService.java | 1 + .../karaf/features/internal/osgi/Activator.java | 4 +- .../service/FeatureConfigInstaller.java | 10 +++- .../internal/service/FeaturesServiceImpl.java | 48 +++++++++++++++++++- 5 files changed, 64 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/8db31d31/assemblies/features/base/src/main/filtered-resources/resources/etc/org.apache.karaf.features.cfg ---------------------------------------------------------------------- diff --git a/assemblies/features/base/src/main/filtered-resources/resources/etc/org.apache.karaf.features.cfg b/assemblies/features/base/src/main/filtered-resources/resources/etc/org.apache.karaf.features.cfg index 77e7a3b..57b92b4 100644 --- a/assemblies/features/base/src/main/filtered-resources/resources/etc/org.apache.karaf.features.cfg +++ b/assemblies/features/base/src/main/filtered-resources/resources/etc/org.apache.karaf.features.cfg @@ -57,3 +57,8 @@ featuresBootAsynchronous=false # - enforce: service requirements are always verified # #serviceRequirements=default + +# +# Store cfg file for config element in feature +# +#configCfgStore=true http://git-wip-us.apache.org/repos/asf/karaf/blob/8db31d31/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java index cee23c0..ad34ec8 100644 --- a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java +++ b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java @@ -47,6 +47,7 @@ public interface FeaturesService { int DEFAULT_SCHEDULE_MAX_RUN = 9; long DEFAULT_REPOSITORY_EXPIRATION = 60000; // 1 minute + boolean DEFAULT_CONFIG_CFG_STORE = true; enum Option { NoFailOnFeatureNotFound, http://git-wip-us.apache.org/repos/asf/karaf/blob/8db31d31/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java index b38c33f..ea5e783 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java @@ -180,6 +180,7 @@ public class Activator extends BaseActivator { int scheduleMaxRun = getInt("scheduleMaxRun", FeaturesService.DEFAULT_SCHEDULE_MAX_RUN); String blacklisted = getString("blacklisted", new File(System.getProperty("karaf.etc"), "blacklisted.properties").toURI().toString()); String serviceRequirements = getString("serviceRequirements", FeaturesService.SERVICE_REQUIREMENTS_DEFAULT); + boolean configCfgStore = getBoolean("configCfgStore", FeaturesService.DEFAULT_CONFIG_CFG_STORE); StateStorage stateStorage = new StateStorage() { @Override protected InputStream getInputStream() throws IOException { @@ -221,7 +222,8 @@ public class Activator extends BaseActivator { downloadThreads, scheduleDelay, scheduleMaxRun, - blacklisted); + blacklisted, + configCfgStore); register(FeaturesService.class, featuresService); featuresListenerTracker = new ServiceTracker<>( http://git-wip-us.apache.org/repos/asf/karaf/blob/8db31d31/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java index f37e3cb..7487e62 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureConfigInstaller.java @@ -50,10 +50,18 @@ public class FeatureConfigInstaller { private final ConfigurationAdmin configAdmin; private File storage; + private boolean configCfgStore; public FeatureConfigInstaller(ConfigurationAdmin configAdmin) { this.configAdmin = configAdmin; this.storage = new File(System.getProperty("karaf.etc")); + this.configCfgStore = FeaturesServiceImpl.DEFAULT_CONFIG_CFG_STORE; + } + + public FeatureConfigInstaller(ConfigurationAdmin configAdmin, boolean configCfgStore) { + this.configAdmin = configAdmin; + this.storage = new File(System.getProperty("karaf.etc")); + this.configCfgStore = configCfgStore; } private String[] parsePid(String pid) { @@ -237,7 +245,7 @@ public class FeatureConfigInstaller { } protected void updateStorage(String pid, String factoryPid, Dictionary props) throws Exception { - if (storage != null) { + if (storage != null && configCfgStore) { // get the cfg file File cfgFile; if (factoryPid != null) { http://git-wip-us.apache.org/repos/asf/karaf/blob/8db31d31/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java index b85b68c..ed2c6e9 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java @@ -165,6 +165,8 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall private final String blacklisted; + private final boolean configCfgStore; + private final ThreadLocal<String> outputFile = new ThreadLocal<>(); /** @@ -180,7 +182,6 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall private final Map<String, Repository> repositoryCache = new HashMap<>(); private Map<String, Map<String, Feature>> featureCache; - public FeaturesServiceImpl(Bundle bundle, BundleContext systemBundleContext, StateStorage storage, @@ -206,7 +207,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall this.eventAdminListener = eventAdminListener; this.configurationAdmin = configurationAdmin; this.resolver = resolver; - this.configInstaller = configurationAdmin != null ? new FeatureConfigInstaller(configurationAdmin) : null; + this.configInstaller = configurationAdmin != null ? new FeatureConfigInstaller(configurationAdmin, FeaturesService.DEFAULT_CONFIG_CFG_STORE) : null; this.digraph = digraph; this.overrides = overrides; this.featureResolutionRange = featureResolutionRange; @@ -218,9 +219,52 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall this.scheduleDelay = scheduleDelay; this.scheduleMaxRun = scheduleMaxRun; this.blacklisted = blacklisted; + this.configCfgStore = FeaturesService.DEFAULT_CONFIG_CFG_STORE; loadState(); checkResolve(); + } + public FeaturesServiceImpl(Bundle bundle, + BundleContext systemBundleContext, + StateStorage storage, + FeatureFinder featureFinder, + EventAdminListener eventAdminListener, + ConfigurationAdmin configurationAdmin, + Resolver resolver, + RegionDigraph digraph, + String overrides, + String featureResolutionRange, + String bundleUpdateRange, + String updateSnaphots, + String serviceRequirements, + org.osgi.service.repository.Repository globalRepository, + int downloadThreads, + long scheduleDelay, + int scheduleMaxRun, + String blacklisted, + boolean configCfgStore) { + this.bundle = bundle; + this.systemBundleContext = systemBundleContext; + this.storage = storage; + this.featureFinder = featureFinder; + this.eventAdminListener = eventAdminListener; + this.configurationAdmin = configurationAdmin; + this.resolver = resolver; + this.configInstaller = configurationAdmin != null ? new FeatureConfigInstaller(configurationAdmin, configCfgStore) : null; + this.digraph = digraph; + this.overrides = overrides; + this.featureResolutionRange = featureResolutionRange; + this.bundleUpdateRange = bundleUpdateRange; + this.updateSnaphots = updateSnaphots; + this.serviceRequirements = serviceRequirements; + this.globalRepository = globalRepository; + this.downloadThreads = downloadThreads > 0 ? downloadThreads : 1; + this.scheduleDelay = scheduleDelay; + this.scheduleMaxRun = scheduleMaxRun; + this.blacklisted = blacklisted; + this.configCfgStore = configCfgStore; + loadState(); + checkResolve(); } @SuppressWarnings("unchecked")
