Search in sources :

Example 11 with Profile

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;
    }
}
Also used : LockHandle(org.apache.karaf.profile.LockHandle) Profile(org.apache.karaf.profile.Profile)

Example 12 with 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
}
Also used : Profile(org.apache.karaf.profile.Profile) Test(org.junit.Test)

Example 13 with Profile

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"));
}
Also used : Profile(org.apache.karaf.profile.Profile) Test(org.junit.Test)

Example 14 with Profile

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;
}
Also used : Profile(org.apache.karaf.profile.Profile)

Example 15 with 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();
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ConfigFile(org.apache.karaf.features.internal.model.ConfigFile) Bundle(org.apache.karaf.features.internal.model.Bundle) Downloader(org.apache.karaf.features.internal.download.Downloader) Features(org.apache.karaf.features.internal.model.Features) Conditional(org.apache.karaf.features.internal.model.Conditional) Feature(org.apache.karaf.features.internal.model.Feature) Profile(org.apache.karaf.profile.Profile) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Profile (org.apache.karaf.profile.Profile)20 HashMap (java.util.HashMap)5 ArrayList (java.util.ArrayList)4 Features (org.apache.karaf.features.internal.model.Features)4 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 Properties (org.apache.felix.utils.properties.Properties)3 Downloader (org.apache.karaf.features.internal.download.Downloader)3 Feature (org.apache.karaf.features.internal.model.Feature)3 LockHandle (org.apache.karaf.profile.LockHandle)3 IOException (java.io.IOException)2 Bundle (org.apache.karaf.features.internal.model.Bundle)2 Conditional (org.apache.karaf.features.internal.model.Conditional)2 ConfigFile (org.apache.karaf.features.internal.model.ConfigFile)2 ProfileBuilder (org.apache.karaf.profile.ProfileBuilder)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1