output.println("Profile id: " + profile.getId()); Map<String, String> props = profile.getAttributes(); for (String key : props.keySet()) { output.println("\t" + key + ": " + props.get(key)); Map<String, Map<String, Object>> configuration = new HashMap<>(profile.getConfigurations()); Map<String, byte[]> resources = profile.getFileConfigurations(); Map<String,Object> profileConfiguration = profile.getConfiguration(Profile.INTERNAL_PID); List<String> profileProperties = new ArrayList<>(); List<String> systemProperties = new ArrayList<>(); output.println("----------------------------"); if (profile.getLibraries().size() > 0) { printConfigList("Libraries : ", output, profile.getLibraries()); if (profile.getRepositories().size() > 0) { printConfigList("Repositories : ", output, profile.getRepositories()); if (profile.getFeatures().size() > 0) { printConfigList("Features : ", output, profile.getFeatures()); if (profile.getBundles().size() > 0) { printConfigList("Bundles : ", output, profile.getBundles()); if (profile.getOverrides().size() > 0) { printConfigList("Overrides : ", output, profile.getOverrides());
@Override public ProfileBuilder from(Profile profile) { profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
static void applyProfiles(File karafBase, List<String> profiles, boolean printOutput) throws IOException { BundleContext bundleContext = FrameworkUtil.getBundle(ProfileApplier.class).getBundleContext(); ServiceReference<ProfileService> reference = bundleContext.getServiceReference(ProfileService.class); ProfileService service = bundleContext.getService(reference); Profile profile = ProfileBuilder.Factory.create("temp") .addParents(profiles) .getProfile(); Profile overlay = service.getOverlayProfile(profile); final Profile effective = service.getEffectiveProfile(overlay, false); Map<String, byte[]> configs = effective.getFileConfigurations(); for (Map.Entry<String, byte[]> config : configs.entrySet()) { String pid = config.getKey(); if (!pid.equals(Profile.INTERNAL_PID + Profile.PROPERTIES_SUFFIX)) { Path configFile = Paths.get(karafBase.toString(), "etc", pid); logDebug("Creating file: %s", printOutput, configFile.toString()); Files.write(configFile, config.getValue()); } } FileLockUtils.execute(new File(karafBase, FEATURES_CFG), properties -> { appendToPropList(properties, "featuresBoot", effective.getFeatures()); appendToPropList(properties, "featuresRepositories", effective.getRepositories()); }, true); bundleContext.ungetService(reference); }
Map<String, Features> installedRepositories = loadRepositories(manager, installedEffective.getRepositories(), true, processor); Set<Feature> installedFeatures = selector.getMatching(installedEffective.getFeatures()); ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklist); for (Feature feature : installedFeatures) { for (String location : installedEffective.getBundles()) { installer.installArtifact(location);
Set<String> overrides = processOverrides(initialEffective.getOverrides()); processor.addOverrides(overrides); allProfiles.put(startupProfile.getId(), startupProfile); profiles.put(startupProfile.getId(), Stage.Boot); Profile bootProfile = generateProfile(Stage.Boot, profiles, repositories, features, bundles); allProfiles.put(bootProfile.getId(), bootProfile); allProfiles.put(installedProfile.getId(), installedProfile); .setParents(Arrays.asList(startupProfile.getId(), bootProfile.getId(), installedProfile.getId())); config.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.CONFIG_PREFIX + k, v)); system.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.SYSTEM_PREFIX + k, v)); configProperties.putAll(overallEffective.getConfig()); configProperties.save(); systemProperties.putAll(overallEffective.getSystem()); systemProperties.save(); downloadLibraries(downloader, configProperties, overallEffective.getLibraries(), ""); LOGGER.info("Downloading additional libraries"); downloadLibraries(downloader, configProperties, libraries, ""); for (Map.Entry<String, byte[]> config : overallEffective.getFileConfigurations().entrySet()) { Path configFile = etcDirectory.resolve(config.getKey()); if (Files.exists(configFile)) {
Map<String, Features> startupRepositories = loadRepositories(manager, startupEffective.getRepositories(), false, processor); LOGGER.info(" Features: " + startupEffective.getFeatures().stream().collect(Collectors.joining(", "))); LOGGER.info(" Bundles: " + startupEffective.getBundles().stream().collect(Collectors.joining(", "))); resolver, startupRepositories.values(), startupEffective.getFeatures(), startupEffective.getBundles(), startupEffective.getOptionals(), processor);
for (LocationPattern br : initialProfile.getBlacklistedRepositories()) { for (FeaturePattern bf : initialProfile.getBlacklistedFeatures()) { for (LocationPattern bb : initialProfile.getBlacklistedBundles()) {
private void supplement(Profile profile, Map<String, SupplementControl> aggregate) { Map<String, byte[]> configs = profile.getFileConfigurations(); for (String key : configs.keySet()) {
installFeatures.addAll(installedEffective.getFeatures());
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
Map<String, Features> installedRepositories = loadRepositories(manager, installedEffective.getRepositories(), true, processor); Set<Feature> installedFeatures = selector.getMatching(installedEffective.getFeatures()); ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklist); for (Feature feature : installedFeatures) { for (String location : installedEffective.getBundles()) { installer.installArtifact(location);
Set<String> overrides = processOverrides(initialEffective.getOverrides()); processor.addOverrides(overrides); allProfiles.put(startupProfile.getId(), startupProfile); profiles.put(startupProfile.getId(), Stage.Boot); Profile bootProfile = generateProfile(Stage.Boot, profiles, repositories, features, bundles); allProfiles.put(bootProfile.getId(), bootProfile); allProfiles.put(installedProfile.getId(), installedProfile); .setParents(Arrays.asList(startupProfile.getId(), bootProfile.getId(), installedProfile.getId())); config.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.CONFIG_PREFIX + k, v)); system.forEach((k ,v) -> builder.addConfiguration(Profile.INTERNAL_PID, Profile.SYSTEM_PREFIX + k, v)); configProperties.putAll(overallEffective.getConfig()); configProperties.save(); systemProperties.putAll(overallEffective.getSystem()); systemProperties.save(); downloadLibraries(downloader, configProperties, overallEffective.getLibraries(), ""); LOGGER.info("Downloading additional libraries"); downloadLibraries(downloader, configProperties, libraries, ""); for (Map.Entry<String, byte[]> config : overallEffective.getFileConfigurations().entrySet()) { Path configFile = etcDirectory.resolve(config.getKey()); if (Files.exists(configFile)) {
static void applyProfiles(File karafBase, List<String> profiles, boolean printOutput) throws IOException { BundleContext bundleContext = FrameworkUtil.getBundle(ProfileApplier.class).getBundleContext(); ServiceReference<ProfileService> reference = bundleContext.getServiceReference(ProfileService.class); ProfileService service = bundleContext.getService(reference); Profile profile = ProfileBuilder.Factory.create("temp") .addParents(profiles) .getProfile(); Profile overlay = service.getOverlayProfile(profile); final Profile effective = service.getEffectiveProfile(overlay, false); Map<String, byte[]> configs = effective.getFileConfigurations(); for (Map.Entry<String, byte[]> config : configs.entrySet()) { String pid = config.getKey(); if (!pid.equals(Profile.INTERNAL_PID + Profile.PROPERTIES_SUFFIX)) { Path configFile = Paths.get(karafBase.toString(), "etc", pid); logDebug("Creating file: %s", printOutput, configFile.toString()); Files.write(configFile, config.getValue()); } } FileLockUtils.execute(new File(karafBase, FEATURES_CFG), properties -> { appendToPropList(properties, "featuresBoot", effective.getFeatures()); appendToPropList(properties, "featuresRepositories", effective.getRepositories()); }, true); bundleContext.ungetService(reference); }
Map<String, Features> startupRepositories = loadRepositories(manager, startupEffective.getRepositories(), false, processor); LOGGER.info(" Features: " + startupEffective.getFeatures().stream().collect(Collectors.joining(", "))); LOGGER.info(" Bundles: " + startupEffective.getBundles().stream().collect(Collectors.joining(", "))); resolver, startupRepositories.values(), startupEffective.getFeatures(), startupEffective.getBundles(), startupEffective.getOptionals(), processor);
@Override public ProfileBuilder from(Profile profile) { profileId = profile.getId(); setFileConfigurations(profile.getFileConfigurations()); return this; }
for (LocationPattern br : initialProfile.getBlacklistedRepositories()) { for (FeaturePattern bf : initialProfile.getBlacklistedFeatures()) { for (LocationPattern bb : initialProfile.getBlacklistedBundles()) {
private void supplement(Profile profile, Map<String, SupplementControl> aggregate) { Map<String, byte[]> configs = profile.getFileConfigurations(); for (String key : configs.keySet()) {
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
output.println("Profile id: " + profile.getId()); Map<String, String> props = profile.getAttributes(); for (String key : props.keySet()) { output.println("\t" + key + ": " + props.get(key)); Map<String, Map<String, Object>> configuration = new HashMap<>(profile.getConfigurations()); Map<String, byte[]> resources = profile.getFileConfigurations(); Map<String,Object> profileConfiguration = profile.getConfiguration(Profile.INTERNAL_PID); List<String> profileProperties = new ArrayList<>(); List<String> systemProperties = new ArrayList<>(); output.println("----------------------------"); if (profile.getLibraries().size() > 0) { printConfigList("Libraries : ", output, profile.getLibraries()); if (profile.getRepositories().size() > 0) { printConfigList("Repositories : ", output, profile.getRepositories()); if (profile.getFeatures().size() > 0) { printConfigList("Features : ", output, profile.getFeatures()); if (profile.getBundles().size() > 0) { printConfigList("Bundles : ", output, profile.getBundles()); if (profile.getOverrides().size() > 0) { printConfigList("Overrides : ", output, profile.getOverrides());
Map<String, Features> bootRepositories = loadRepositories(manager, bootEffective.getRepositories(), true, processor); generated.setName(generatedBootFeatureName); for (String nameOrPattern : bootEffective.getFeatures()) { for (String location : bootEffective.getBundles()) { location = location.replace("profile:", "file:etc/"); Bundle bun = new Bundle(); rep.getRepository().addAll(bootEffective.getRepositories()); rep.getFeature().add(generated); allBootFeatures.add(generated); for (Dependency d : f.getFeature()) { if (d.isPrerequisite()) { if (!startupEffective.getFeatures().contains(d.getName())) { LOGGER.warn("Feature " + d.getName() + " is a prerequisite and should be installed as a startup feature."); }