Examples of BundleDistributionInfo


Examples of org.rhq.enterprise.server.bundle.BundleDistributionInfo

        fileName += ".zip";

        Map<String, File> patchFiles = new HashMap<String, File>();
        patchFiles.put(fileName, distributionFile);

        return new BundleDistributionInfo(recipe, parseResults, patchFiles);
    }
View Full Code Here

Examples of org.rhq.enterprise.server.bundle.BundleDistributionInfo

        if (recipe == null) {
            throw new IllegalArgumentException("recipe == null");
        }

        BundleDistributionInfo info = null;

        for (ServerPluginEnvironment env : getPluginEnvironments()) {
            BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor();

            // get the facet and see if this plugin can deal with the recipe
            String pluginName = env.getPluginKey().getPluginName();
            ServerPluginComponent component = getServerPluginComponent(pluginName);
            BundleServerPluginFacet facet = (BundleServerPluginFacet) component; // we know this cast will work because our loadPlugin ensured so
            getLog().debug("Bundle server plugin [" + pluginName + "] is parsing a recipe");
            ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(env.getPluginClassLoader());
                try {
                    RecipeParseResults results = facet.parseRecipe(recipe);
                    info = new BundleDistributionInfo(recipe, results, null);
                    info.setBundleTypeName(descriptor.getBundle().getType());
                    break;
                } catch (UnknownRecipeException ure) {
                    // the recipe is not a type that the plugin can handle, go on to the next
                    info = null;
                }
            } finally {
                Thread.currentThread().setContextClassLoader(originalContextClassLoader);
            }
        }

        if (null == info) {
            throw new IllegalArgumentException("Invalid recipe not recognized by any deployed server bundle plugin.");
        }

        ensureDisplayNameIsSet(info.getRecipeParseResults());

        return info;
    }
View Full Code Here

Examples of org.rhq.enterprise.server.bundle.BundleDistributionInfo

        if (null == distributionFile) {
            throw new IllegalArgumentException("bundleDistributionFile == null");
        }

        // find the bundle plugin that can handle this distribution and get the distro info
        BundleDistributionInfo info = null;

        for (ServerPluginEnvironment env : getPluginEnvironments()) {
            BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor();

            // get the facet and see if this plugin can deal with the distro
            String pluginName = env.getPluginKey().getPluginName();
            ServerPluginComponent component = getServerPluginComponent(pluginName);
            BundleServerPluginFacet facet = (BundleServerPluginFacet) component; // we know this cast will work because our loadPlugin ensured so
            getLog().debug(
                "Bundle server plugin [" + pluginName + "] is parsing a distribution file [" + distributionFile + "]");
            ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(env.getPluginClassLoader());
                try {
                    info = facet.processBundleDistributionFile(distributionFile);
                    info.setBundleTypeName(descriptor.getBundle().getType());
                    break;
                } catch (UnknownRecipeException ure) {
                    // the recipe is not a type that the plugin can handle, go on to the next
                    info = null;
                }
            } finally {
                Thread.currentThread().setContextClassLoader(originalContextClassLoader);
            }
        }
        if (null == info) {
            throw new IllegalArgumentException(
                "Invalid bundle distribution file. BundleType/Recipe not recognized by any deployed server bundle plugin.");
        }

        ensureDisplayNameIsSet(info.getRecipeParseResults());

        return info;
    }
View Full Code Here

Examples of org.rhq.enterprise.server.bundle.BundleDistributionInfo

        Exception {
        if (null == distributionFile) {
            throw new IllegalArgumentException("distributionFile == null");
        }

        BundleDistributionInfo info = null;
        String recipe = null;
        RecipeParseResults recipeParseResults = null;
        Map<String, File> bundleFiles = null;

        // try and parse the recipe, if successful then process the distributionFile completely
        RecipeVisitor recipeVisitor = new RecipeVisitor(this, "deploy.txt");
        ZipUtil.walkZipFile(distributionFile, recipeVisitor);
        recipe = recipeVisitor.getRecipe();
        recipeParseResults = recipeVisitor.getResults();

        if (null == recipeParseResults) {
            // we also want to support the ability to provide just a file template recipe as the distro file
            // so see if we can parse it, but note that we don't even bother if its a really big file since
            // that's probably not a recipe file and we don't want to risk loading in a huge file in memory
            if (distributionFile.length() < 50000L) {
                byte[] content = StreamUtil.slurp(new FileInputStream(distributionFile));
                recipe = new String(content);
                content = null;
                recipeParseResults = parseRecipe(recipe); // if it isn't a recipe either, this will throw UnknownRecipeException
            } else {
                throw new UnknownRecipeException("Not a File Template Bundle");
            }
        } else {
            // if we parsed the recipe, then this is a distribution zip we can deal with, get the bundle file Map                
            BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleMetadata()
                .getBundleName(), recipeParseResults.getBundleFileNames());
            ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);
            bundleFiles = bundleFileVisitor.getBundleFiles();
        }

        info = new BundleDistributionInfo(recipe, recipeParseResults, bundleFiles);

        return info;
    }
View Full Code Here

Examples of org.rhq.enterprise.server.bundle.BundleDistributionInfo

        // if we parsed the recipe then this is a distribution we can deal with, get the bundle file Map                
        BundleFileVisitor bundleFileVisitor = new BundleFileVisitor(recipeParseResults.getBundleFileNames());
        ZipUtil.walkZipFile(distributionFile, bundleFileVisitor);

        return new BundleDistributionInfo(recipe, recipeParseResults, bundleFileVisitor.getBundleFiles());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.