Search in sources :

Example 1 with LockHandle

use of org.apache.karaf.profile.LockHandle in project karaf by apache.

the class ProfileServiceImpl method updateProfile.

@Override
@SuppressWarnings("unused")
public void updateProfile(Profile profile) {
    assertNotNull(profile, "profile is null");
    try (LockHandle lock = acquireWriteLock()) {
        final String profileId = profile.getId();
        final Profile lastProfile = getRequiredProfile(profileId);
        createOrUpdateProfile(lastProfile, profile);
    }
}
Also used : LockHandle(org.apache.karaf.profile.LockHandle) Profile(org.apache.karaf.profile.Profile)

Example 2 with LockHandle

use of org.apache.karaf.profile.LockHandle in project karaf by apache.

the class ProfileServiceImpl method deleteProfile.

@Override
@SuppressWarnings("unused")
public void deleteProfile(String profileId) {
    assertNotNull(profileId, "profileId is null");
    try (LockHandle lock = acquireWriteLock()) {
        final Profile lastProfile = getRequiredProfile(profileId);
        deleteProfileFromCache(lastProfile);
    }
}
Also used : LockHandle(org.apache.karaf.profile.LockHandle) Profile(org.apache.karaf.profile.Profile)

Example 3 with LockHandle

use of org.apache.karaf.profile.LockHandle 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 4 with LockHandle

use of org.apache.karaf.profile.LockHandle in project karaf by apache.

the class ProfileServiceImpl method createProfile.

@Override
@SuppressWarnings("unused")
public void createProfile(Profile profile) {
    assertNotNull(profile, "profile is null");
    try (LockHandle lock = acquireWriteLock()) {
        String profileId = profile.getId();
        assertFalse(hasProfile(profileId), "Profile already exists: " + profileId);
        createOrUpdateProfile(null, profile);
    }
}
Also used : LockHandle(org.apache.karaf.profile.LockHandle)

Aggregations

LockHandle (org.apache.karaf.profile.LockHandle)4 Profile (org.apache.karaf.profile.Profile)3