private List<Profile> getInheritedProfiles() { List<Profile> profiles = new ArrayList<>(); fillParentProfiles(self, profiles); return profiles; }
private Map<String, byte[]> getFileConfigurations() { Map<String, SupplementControl> aggregate = new HashMap<>(); for (Profile profile : getInheritedProfiles()) { supplement(profile, aggregate); } Map<String, byte[]> rc = new HashMap<>(); for (Map.Entry<String, SupplementControl> entry : aggregate.entrySet()) { SupplementControl ctrl = entry.getValue(); if (ctrl.props != null) { ctrl.data = Utils.toBytes(ctrl.props); } rc.put(entry.getKey(), ctrl.data); } return rc; }
private void fillParentProfiles(Profile profile, List<Profile> profiles) { if (!profiles.contains(profile)) { for (String parentId : profile.getParentIds()) { Profile parent = getRequiredProfile(parentId); fillParentProfiles(parent, profiles); } profiles.add(profile); } }
/** * <p>Gets an <em>overlay</em> profile for given <code>profile</code>, where passed in map of additional profiles * is searched for possible parent profiles of given <code>profile</code>.</p> * <p><code>environment</code> may be used to select different <em>variants</em> of profile configuration files. * For example, if <code>environment</code> is specified, configuration for <code>my.pid</code> PID will be read * from <code>my.pid.cfg#<environment></code>.</p> * @param profile * @param profiles * @param environment * @return */ public static Profile getOverlay(Profile profile, Map<String, Profile> profiles, String environment) { assertNotNull(profile, "profile is null"); assertNotNull(profile, "profiles is null"); if (profile.isOverlay()) { return profile; } else { String profileId = profile.getId(); ProfileBuilder builder = ProfileBuilder.Factory.create(profileId); new OverlayOptionsProvider(profiles, profile, environment).addOptions(builder); return builder.getProfile(); } }
/** * <p>Gets an <em>overlay</em> profile for given <code>profile</code>, where passed in map of additional profiles * is searched for possible parent profiles of given <code>profile</code>.</p> * <p><code>environment</code> may be used to select different <em>variants</em> of profile configuration files. * For example, if <code>environment</code> is specified, configuration for <code>my.pid</code> PID will be read * from <code>my.pid.cfg#<environment></code>.</p> * @param profile * @param profiles * @param environment * @return */ public static Profile getOverlay(Profile profile, Map<String, Profile> profiles, String environment) { assertNotNull(profile, "profile is null"); assertNotNull(profile, "profiles is null"); if (profile.isOverlay()) { return profile; } else { String profileId = profile.getId(); ProfileBuilder builder = ProfileBuilder.Factory.create(profileId); new OverlayOptionsProvider(profiles, profile, environment).addOptions(builder); return builder.getProfile(); } }
private Map<String, byte[]> getFileConfigurations() { Map<String, SupplementControl> aggregate = new HashMap<>(); for (Profile profile : getInheritedProfiles()) { supplement(profile, aggregate); } Map<String, byte[]> rc = new HashMap<>(); for (Map.Entry<String, SupplementControl> entry : aggregate.entrySet()) { SupplementControl ctrl = entry.getValue(); if (ctrl.props != null) { ctrl.data = Utils.toBytes(ctrl.props); } rc.put(entry.getKey(), ctrl.data); } return rc; }
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
private ProfileBuilder addOptions(ProfileBuilder builder) { builder.setAttributes(self.getAttributes()); builder.setFileConfigurations(getFileConfigurations()); builder.setOverlay(true); return builder; }
private void fillParentProfiles(Profile profile, List<Profile> profiles) { if (!profiles.contains(profile)) { for (String parentId : profile.getParentIds()) { Profile parent = getRequiredProfile(parentId); fillParentProfiles(parent, profiles); } profiles.add(profile); } }
private List<Profile> getInheritedProfiles() { List<Profile> profiles = new ArrayList<>(); fillParentProfiles(self, profiles); return profiles; }