Package io.fabric8.api

Examples of io.fabric8.api.ProfileService


        }
    }

    private DeployResults resolveProfileDeployments(ProjectRequirements requirements, FabricService fabric, Profile profile, ProfileBuilder builder) throws Exception {
        DependencyDTO rootDependency = requirements.getRootDependency();
        ProfileService profileService = fabricService.get().adapt(ProfileService.class);

        if (rootDependency != null) {
            // as a hack lets just add this bundle in
            LOG.info("Got root: " + rootDependency);
            List<String> parentIds = profile.getParentIds();
            Profile overlay = profileService.getOverlayProfile(profile);

            String bundleUrl = rootDependency.toBundleUrlWithType();
            LOG.info("Using resolver to add extra features and bundles on " + bundleUrl);

            List<String> features = new ArrayList<String>();
            List<String> bundles = new ArrayList<String>();
            List<String> optionals = new ArrayList<String>();

            if (requirements.getFeatures() != null) {
                features.addAll(requirements.getFeatures());
            }
            if (requirements.getBundles() != null) {
                bundles.addAll(requirements.getBundles());
            }

            bundles.add(bundleUrl);
            LOG.info("Adding bundle: " + bundleUrl);

            // TODO we maybe should detect a karaf based container in a nicer way than this?
            boolean isKarafContainer = parentIds.contains("karaf") || parentIds.contains("containers-karaf");
            boolean addBundleDependencies = Objects.equal("bundle", rootDependency.getType()) || isKarafContainer;
            if (addBundleDependencies && requirements.isUseResolver()) {

                // lets build up a list of all current active features and bundles along with all discovered features
                List<Feature> availableFeatures = new ArrayList<Feature>();
                addAvailableFeaturesFromProfile(availableFeatures, fabric, overlay);

                Set<String> currentBundleLocations = new HashSet<>();
                currentBundleLocations.addAll(bundles);

                // lets add the current features
                DownloadManager downloadManager = DownloadManagers.createDownloadManager(fabric, executorService);
                Set<Feature> currentFeatures = AgentUtils.getFeatures(fabric, downloadManager, overlay);
                addBundlesFromProfile(currentBundleLocations, overlay);

                List<String> parentProfileIds = requirements.getParentProfiles();
                if (parentProfileIds != null) {
                    for (String parentProfileId : parentProfileIds) {
                        Profile parentProfile = profileService.getProfile(profile.getVersion(), parentProfileId);
                        Profile parentOverlay = profileService.getOverlayProfile(parentProfile);
                        Set<Feature> parentFeatures = AgentUtils.getFeatures(fabric, downloadManager, parentOverlay);
                        currentFeatures.addAll(parentFeatures);
                        addAvailableFeaturesFromProfile(availableFeatures, fabric, parentOverlay);
                        addBundlesFromProfile(currentBundleLocations, parentOverlay);
                    }
                }

                // lets add all known features from the known repositories
                for (DependencyDTO dependency : rootDependency.getChildren()) {
                    if ("test".equals(dependency.getScope()) || "provided".equals(dependency.getScope())) {
                        continue;
                    }
                    if ("jar".equals(dependency.getType())) {
                        String match = getAllServiceMixBundles().get(dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion());
                        if (match != null) {
                            LOG.info("Replacing artifact " + dependency + " with servicemix bundle " + match);
                            String[] parts = match.split(":");
                            dependency.setGroupId(parts[0]);
                            dependency.setArtifactId(parts[1]);
                            dependency.setVersion(parts[2]);
                            dependency.setType("bundle");
                        }
                    }
                    String prefix = dependency.toBundleUrlWithoutVersion();
                    Feature feature = findFeatureWithBundleLocationPrefix(currentFeatures, prefix);
                    if (feature != null) {
                        LOG.info("Feature is already is in the profile " + feature.getId() + " for " + dependency.toBundleUrl() );
                    } else {
                        feature = findFeatureWithBundleLocationPrefix(availableFeatures, prefix);
                        if (feature != null) {
                            String name = feature.getName();
                            if (features.contains(name)) {
                                LOG.info("Feature is already added " + name + " for " + dependency.toBundleUrl() );
                            } else {
                                LOG.info("Found a matching feature for bundle " + dependency.toBundleUrl() + ": " + feature.getId());
                                features.add(name);
                            }
                        } else {
                            String bundleUrlWithType = dependency.toBundleUrlWithType();
                            String foundBundleUri = findBundleUri(currentBundleLocations, prefix);
                            if (foundBundleUri != null) {
                                LOG.info("Bundle already included " + foundBundleUri + " for " + bundleUrlWithType);
                            } else {
                                boolean ignore = false;
                                String bundleWithoutMvnPrefix = getMavenCoords(bundleUrlWithType);
                                for (String ignoreBundlePrefix : RESOLVER_IGNORE_BUNDLE_PREFIXES) {
                                    if (bundleWithoutMvnPrefix.startsWith(ignoreBundlePrefix)) {
                                        ignore = true;
                                        break;
                                    }
                                }
                                if (ignore) {
                                    LOG.info("Ignoring bundle: " + bundleUrlWithType);
                                } else {
                                    boolean optional = dependency.isOptional();
                                    LOG.info("Adding " + (optional ? "optional " : "") + " bundle: " + bundleUrlWithType);
                                    if (optional) {
                                        optionals.add(bundleUrlWithType);
                                    } else {
                                        bundles.add(bundleUrlWithType);
                                    }
                                }
                            }
                        }
                    }
                }
                // Modify the profile through the {@link ProfileBuilder}
                builder.setOptionals(optionals).setFeatures(features);
            }
            builder.setBundles(bundles);
        }

        profile = profileService.updateProfile(builder.getProfile());

        Integer minimumInstances = requirements.getMinimumInstances();
        if (minimumInstances != null) {
            FabricRequirements fabricRequirements = fabricService.get().getRequirements();
            ProfileRequirements profileRequirements = fabricRequirements.getOrCreateProfileRequirement(profile.getId());
View Full Code Here


        Profile profile;
        if (!version.hasProfile(profileId)) {
            LOG.info("Creating new profile " + profileId + " version " + version + " for requirements: " + requirements);
            String versionId = version.getId();
            ProfileService profileService = fabricService.get().adapt(ProfileService.class);
            ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId);
            profile = profileService.createProfile(builder.getProfile());
        } else {
            profile = version.getRequiredProfile(profileId);
        }
        return profile;
    }
View Full Code Here

        }
        return profile;
    }

    private Version getOrCreateVersion(ProjectRequirements requirements) {
        ProfileService profileService = fabricService.get().adapt(ProfileService.class);
        String versionId = getVersionId(requirements);
        Version version = findVersion(fabricService.get(), versionId);
        if (version == null) {
            String baseId = requirements.getBaseVersion();
            baseId = getVersionOrDefaultVersion(fabricService.get(), baseId);
            Version baseVersion = findVersion(fabricService.get(), baseId);
            if (baseVersion != null) {
                version = profileService.createVersionFrom(baseVersion.getId(), versionId, null);
            } else {
                version = VersionBuilder.Factory.create(versionId).getVersion();
                version = profileService.createVersion(version);
            }
        }
        return version;
    }
View Full Code Here

      String versionId = profile.getVersion();
      String profileId = profile.getId();
        output.printf("Containers: %s\n", toString(fabricService.getAssociatedContainers(versionId, profileId)));

        ProfileService profileService = fabricService.adapt(ProfileService.class);
        if (overlay) {
            profile = profileService.getOverlayProfile(profile);
        }

        Map<String, Map<String, String>> configuration = new HashMap<>(profile.getConfigurations());
        Map<String, byte[]> resources = profile.getFileConfigurations();
        Map<String,String> agentConfiguration = profile.getConfiguration(Constants.AGENT_PID);
View Full Code Here

        }
        return version;
    }

    private Version findVersion(FabricService fabricService, String versionId) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        return profileService.getVersion(versionId);
    }
View Full Code Here

        return getJavaContainerArtifactsFiles(fabricService, profileList, downloadManager);
    }

    public static Map<String, File> getJavaContainerArtifactsFiles(FabricService fabricService, List<Profile> profileList, DownloadManager downloadManager) throws Exception {
        Map<String, File> answer = new HashMap<String, File>();
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        for (Profile profile : profileList) {
            Profile overlay = profileService.getOverlayProfile(profile);
            Map<String, Parser> profileArtifacts = AgentUtils.getProfileArtifacts(fabricService, downloadManager, overlay);
            appendMavenDependencies(profileArtifacts, profile);
            Set<String> rawUrls = profileArtifacts.keySet();
            downloadArtifactUrls(downloadManager, rawUrls, answer);
        }
View Full Code Here

        }
    }

    protected Profile getProcessProfile(ProcessRequirements requirements, boolean includeController) {
        Container container = fabricService.getCurrentContainer();
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        Profile processProfile = getProcessProfile(requirements, includeController, container);
        return Profiles.getEffectiveProfile(fabricService, profileService.getOverlayProfile(processProfile));
    }
View Full Code Here

    @Override
    public Profile getOverlayProfile(Profile profile) {
        Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
        try {
            ProfileService service = permit.getInstance();
            return service.getOverlayProfile(profile);
        } finally {
            permit.release();
        }
    }
View Full Code Here

    @Override
    public Profile updateProfile(Profile profile) {
        Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
        try {
            ProfileService service = permit.getInstance();
            return service.updateProfile(profile);
        } finally {
            permit.release();
        }
    }
View Full Code Here

    @Override
    public void deleteProfile(String versionId, String profileId, boolean force) {
        Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
        try {
            ProfileService service = permit.getInstance();
            service.deleteProfile(versionId, profileId, force);
        } finally {
            permit.release();
        }
    }
View Full Code Here

TOP

Related Classes of io.fabric8.api.ProfileService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.