use of org.apache.karaf.profile.Profile in project karaf by apache.
the class ProfileServiceImpl method getRequiredProfile.
@Override
@SuppressWarnings("unused")
public Profile getRequiredProfile(String profileId) {
assertNotNull(profileId, "profileId is null");
try (LockHandle lock = acquireReadLock()) {
Profile profile = getProfileFromCache(profileId);
assertNotNull(profile, "Profile does not exist: " + profileId);
return profile;
}
}
use of org.apache.karaf.profile.Profile in project karaf by apache.
the class ProfilesTest method testProfilePlaceholderResolverWitCycle.
@Test(expected = IllegalArgumentException.class)
public void testProfilePlaceholderResolverWitCycle() {
Profile profile = ProfileBuilder.Factory.create("test").addConfiguration("pid1", "foo", "b${profile:pid2/bar}").addConfiguration("pid2", "bar", "a${rep}").addConfiguration("pid2", "rep", "h${profile:pid1/foo}").getProfile();
Profile effective = Profiles.getEffective(profile);
effective.getConfiguration("pid1").get("foo");
// Should throw an exception
}
use of org.apache.karaf.profile.Profile in project karaf by apache.
the class ProfilesTest method testNonSubstitution.
@Test
public void testNonSubstitution() {
Profile profile = ProfileBuilder.Factory.create("test").addConfiguration("pid1", "key", "${foo}/${bar}").getProfile();
Profile effective = Profiles.getEffective(profile, false);
assertEquals("${foo}/${bar}", effective.getConfiguration("pid1").get("key"));
}
use of org.apache.karaf.profile.Profile in project karaf by apache.
the class Builder method generateProfile.
private Profile generateProfile(Stage stage, Map<String, Stage> profiles, Map<String, RepositoryInfo> repositories, Map<String, Stage> features, Map<String, Stage> bundles) {
Profile profile = ProfileBuilder.Factory.create(UUID.randomUUID().toString()).setParents(getStaged(stage, profiles)).setRepositories(getStagedRepositories(stage, repositories)).setFeatures(getStaged(stage, features)).setBundles(getStaged(stage, bundles)).getProfile();
allProfiles.put(profile.getId(), profile);
return profile;
}
use of org.apache.karaf.profile.Profile in project karaf by apache.
the class Builder method installStage.
private void installStage(Profile installedProfile, Set<Feature> allBootFeatures) throws Exception {
LOGGER.info("Install stage");
//
// Handle installed profiles
//
Profile installedOverlay = Profiles.getOverlay(installedProfile, allProfiles, environment);
Profile installedEffective = Profiles.getEffective(installedOverlay, false);
Downloader downloader = manager.createDownloader();
// Load startup repositories
Map<String, Features> installedRepositories = loadRepositories(manager, installedEffective.getRepositories(), true);
// Compute startup feature dependencies
Set<Feature> allInstalledFeatures = new HashSet<>();
for (Features repo : installedRepositories.values()) {
allInstalledFeatures.addAll(repo.getFeature());
}
Set<Feature> installedFeatures = new LinkedHashSet<>();
// Add boot features for search
allInstalledFeatures.addAll(allBootFeatures);
for (String feature : installedEffective.getFeatures()) {
addFeatures(allInstalledFeatures, feature, installedFeatures, true);
}
for (Feature feature : installedFeatures) {
LOGGER.info(" Feature {} is defined as an installed feature", feature.getId());
for (Bundle bundle : feature.getBundle()) {
if (!ignoreDependencyFlag || !bundle.isDependency()) {
installArtifact(downloader, bundle.getLocation().trim());
}
}
// Install config files
for (ConfigFile configFile : feature.getConfigfile()) {
installArtifact(downloader, configFile.getLocation().trim());
}
for (Conditional cond : feature.getConditional()) {
for (Bundle bundle : cond.getBundle()) {
if (!ignoreDependencyFlag || !bundle.isDependency()) {
installArtifact(downloader, bundle.getLocation().trim());
}
}
}
}
for (String location : installedEffective.getBundles()) {
installArtifact(downloader, location);
}
downloader.await();
}
Aggregations