Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Profile

Thomas Diesler edited this page May 23, 2014 · 33 revisions

Working with Profiles

A Profile is an identifiable set of configuration and resource items that can be applied to a Container.

A Profile has the following properties.

Clients can obtain instances of profiles from the ProfileManager.

Managing Profile

The ProfileManager is the central entry point for working with profiles. It contains operations to

  • Add, update, remove profiles
  • Find profiles by given identifiers

Profile instances returned by the ProfileManager are shallow immutable objects. They represent the state of physical profile at a moment in time.

There is the notion of LinkedProfile which gives access to the complete hierarchy of a given Profile (including its parent profiles). LinkedProfileVersion gives access to the complete hierarchy of all Profiles associated with a given version.

Creating a Profile

To create a profile, a client would use a ProfileBuilder and pass the so built Profile to the ProfileManager like this

// Building the profile
Profile profile = ProfileBuilder.Factory.create("foo")
   .addConfigurationItem("some.pid", Collections.singletonMap("foo", "bar"))
   .getProfile();

// Adding the profile to a version
ProfileManager manager = ProfileManagerLocator.getProfileManager();
profile = manager.addProfile(version, profile);

Every builder (not just for Profiles) supports the use of OptionsProvider. An OptionsProvider can take its information from an arbitrary source and invoke methods on a builder. This decouples data format from the Fabric8 builders.

Here is an example that builds a profile from JMX composite data.

Profile profile = ProfileBuilder.Factory.create()
   .addOptions(new CompositeDataOptionsProvider(cdata));
   profileBuilder.getProfile();

class CompositeDataOptionsProvider implements OptionsProvider<ProfileBuilder> {

    ...

    @Override
    public ProfileBuilder addBuilderOptions(ProfileBuilder builder) {
        Profile profile = ProfileOpenType.getProfile(cdata);
        builder.identity(profile.getIdentity());
        return builder.addAttributes(profile.getAttributes());
    }
}

Effective Profile

From the ProfileManager you can obtain the effective profile for a given profile. This would be the flat profile representation of a given profile and the transitive tree of its parents. Child items override parent items based on identity.

ProfileManager manager = ProfileManagerLocator.getProfileManager();
Profile effectiveFoo = manager.getEffectiveProfile(version, "foo");

Removing a Profile

// Removing the profile to a version
ProfileManager manager = ProfileManagerLocator.getProfileManager();
manager.removeProfile(version, profile.getIdentity());

A profile that is associated with an active container cannot be removed.

Clone this wiki locally