Make FeaturesServiceConfig immutable Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/c4a4de24 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/c4a4de24 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/c4a4de24
Branch: refs/heads/master Commit: c4a4de24a53849a9a6945eeaecc9b0f7bdf385c0 Parents: f5b7cce Author: Guillaume Nodet <[email protected]> Authored: Mon Jul 24 22:42:32 2017 +0200 Committer: Guillaume Nodet <[email protected]> Committed: Tue Jul 25 21:40:14 2017 +0200 ---------------------------------------------------------------------- .../karaf/features/internal/osgi/Activator.java | 21 ++++++------ .../internal/service/FeaturesServiceConfig.java | 34 ++++++++++++++------ 2 files changed, 35 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/c4a4de24/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 5d2e996..b3ec0a1 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 @@ -213,17 +213,16 @@ public class Activator extends BaseActivator { } private FeaturesServiceConfig getConfig() { - FeaturesServiceConfig cfg = new FeaturesServiceConfig(); - cfg.overrides = getString("overrides", new File(System.getProperty("karaf.etc"), "overrides.properties").toURI().toString()); - cfg.featureResolutionRange = getString("featureResolutionRange", FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE); - cfg.bundleUpdateRange = getString("bundleUpdateRange", FeaturesService.DEFAULT_BUNDLE_UPDATE_RANGE); - cfg.updateSnapshots = getString("updateSnapshots", FeaturesService.DEFAULT_UPDATE_SNAPSHOTS); - cfg.downloadThreads = getInt("downloadThreads", FeaturesService.DEFAULT_DOWNLOAD_THREADS); - cfg.scheduleDelay = getLong("scheduleDelay", FeaturesService.DEFAULT_SCHEDULE_DELAY); - cfg.scheduleMaxRun = getInt("scheduleMaxRun", FeaturesService.DEFAULT_SCHEDULE_MAX_RUN); - cfg.blacklisted = getString("blacklisted", new File(System.getProperty("karaf.etc"), "blacklisted.properties").toURI().toString()); - cfg.serviceRequirements = getString("serviceRequirements", FeaturesService.SERVICE_REQUIREMENTS_DEFAULT); - return cfg; + return new FeaturesServiceConfig( + getString("overrides", new File(System.getProperty("karaf.etc"), "overrides.properties").toURI().toString()), + getString("featureResolutionRange", FeaturesService.DEFAULT_FEATURE_RESOLUTION_RANGE), + getString("bundleUpdateRange", FeaturesService.DEFAULT_BUNDLE_UPDATE_RANGE), + getString("updateSnapshots", FeaturesService.DEFAULT_UPDATE_SNAPSHOTS), + getInt("downloadThreads", FeaturesService.DEFAULT_DOWNLOAD_THREADS), + getLong("scheduleDelay", FeaturesService.DEFAULT_SCHEDULE_DELAY), + getInt("scheduleMaxRun", FeaturesService.DEFAULT_SCHEDULE_MAX_RUN), + getString("blacklisted", new File(System.getProperty("karaf.etc"), "blacklisted.properties").toURI().toString()), + getString("serviceRequirements", FeaturesService.SERVICE_REQUIREMENTS_DEFAULT)); } private StateStorage createStateStorage() { http://git-wip-us.apache.org/repos/asf/karaf/blob/c4a4de24/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java ---------------------------------------------------------------------- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java index 45362e3..68f957c 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceConfig.java @@ -18,20 +18,20 @@ package org.apache.karaf.features.internal.service; public class FeaturesServiceConfig { - public String overrides; + public final String overrides; /** * Range to use when a version is specified on a feature dependency. * The default is {@link org.apache.karaf.features.FeaturesService#DEFAULT_FEATURE_RESOLUTION_RANGE} */ - public String featureResolutionRange; + public final String featureResolutionRange; /** * Range to use when verifying if a bundle should be updated or * new bundle installed. * The default is {@link org.apache.karaf.features.FeaturesService#DEFAULT_BUNDLE_UPDATE_RANGE} */ - public String bundleUpdateRange; + public final String bundleUpdateRange; /** * Use CRC to check snapshot bundles and update them if changed. @@ -40,18 +40,34 @@ public class FeaturesServiceConfig { * - always : always update snapshots * - crc : use CRC to detect changes */ - public String updateSnapshots; + public final String updateSnapshots; - public int downloadThreads = 1; + public final int downloadThreads; - public long scheduleDelay; + public final long scheduleDelay; - public int scheduleMaxRun; + public final int scheduleMaxRun; /** * Service requirements enforcement */ - public String serviceRequirements; + public final String serviceRequirements; - public String blacklisted; + public final String blacklisted; + + public FeaturesServiceConfig() { + this(null, null, null, null, 1, 0, 0, null, null); + } + + public FeaturesServiceConfig(String overrides, String featureResolutionRange, String bundleUpdateRange, String updateSnapshots, int downloadThreads, long scheduleDelay, int scheduleMaxRun, String blacklisted, String serviceRequirements) { + this.overrides = overrides; + this.featureResolutionRange = featureResolutionRange; + this.bundleUpdateRange = bundleUpdateRange; + this.updateSnapshots = updateSnapshots; + this.downloadThreads = downloadThreads; + this.scheduleDelay = scheduleDelay; + this.scheduleMaxRun = scheduleMaxRun; + this.blacklisted = blacklisted; + this.serviceRequirements = serviceRequirements; + } }
