Package javax.enterprise.deploy.spi

Examples of javax.enterprise.deploy.spi.TargetModuleID


            }
            waitForProgress(po);
            if (po.getDeploymentStatus().isCompleted()) {
                modules = po.getResultTargetModuleIDs();
                for (int i = 0; i < modules.length; i++) {
                    TargetModuleID result = modules[i];
                    log.info(DeployUtils.reformat("Redeployed " + result.getModuleID() + (targets.length > 1 ? " to " + result.getTarget().getName() : "") + (result.getWebURL() == null ? "" : " @ " + result.getWebURL()), 4, 72));
                    if (result.getChildTargetModuleID() != null) {
                        for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                            TargetModuleID child = result.getChildTargetModuleID()[j];
                            log.info(DeployUtils.reformat("  `-> " + child.getModuleID() + (child.getWebURL() == null ? "" : " @ " + child.getWebURL()), 4, 72));
                        }
                    }
                }
            } else {
                log.error("Unable to undeploy " + file.getAbsolutePath() + "(" + configId + ")" + po.getDeploymentStatus().getMessage());
View Full Code Here


            try {
                allModules = mgr.getAvailableModules(null, allTargets);
            } catch (TargetException e) {
                throw new MojoExecutionException("Unable to load module list from server", e);
            }
            TargetModuleID id = null;
            for (TargetModuleID test : allModules) {
                if (geronimoArtifact.matches(org.apache.geronimo.kernel.repository.Artifact.create(test.getModuleID()))) {
                    id = test;
                    break;
                }
View Full Code Here

        List modulesList = new ArrayList();

        DeploymentManager manager = getDeploymentManager();

        Target[] targets = manager.getTargets();
        TargetModuleID runningModuleIds[] = manager.getRunningModules(null, targets);

        for (int j = 0; j < moduleIds.length; j++) {
            String moduleId = moduleIds[j].getModuleID();
            log.debug("Checking if module is running: " + moduleId);
View Full Code Here

        log.debug("Checking if module is started: " + moduleId);
       
        DeploymentManager manager = getDeploymentManager();

        Target[] targets = manager.getTargets();
        TargetModuleID targetIds[] = manager.getRunningModules(null, targets);

        for (int i = 0; i < targetIds.length; i++) {
            if (moduleId.equals(targetIds[i].getModuleID())) {
                return true;
            }
View Full Code Here

            ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
            int alreadyStopped = 0;

            try {
                for (int i = 0; i < modules.length; i++) {
                    TargetModuleID module = modules[i];
                    Artifact moduleID = Artifact.create(module.getModuleID());
                    org.apache.geronimo.kernel.config.LifecycleResults lcresult = null;

                    if (configurationManager.isRunning(moduleID)) {
                        lcresult = configurationManager.stopConfiguration(moduleID);
                        addModule(module);
                    } else {
                        updateStatus("Module " + moduleID + " is already stopped");
                        alreadyStopped++;
                    }

                    if (configurationManager.isLoaded(moduleID)) {
                        configurationManager.unloadConfiguration(moduleID);
                    }

                    if (lcresult != null) {
                        java.util.Iterator iterator = lcresult.getStopped().iterator();
                        while (iterator.hasNext()) {
                            Artifact config = (Artifact)iterator.next();
                            if (!config.toString().equals(module.getModuleID())) {
                                //TODO might be a hack
                                List kidsChild = loadChildren(kernel, config.toString());
                                //this.updateStatus("printing kidsChild="+kidsChild);
                                //this.updateStatus("printing config="+config.toString());
                                // Build a response obect containg the started configuration and a list of it's contained modules
View Full Code Here

                }
                po = mgr.start(po.getResultTargetModuleIDs());
                waitForProgress(consoleReader, po);
                TargetModuleID[] resultsDeployment = po.getResultTargetModuleIDs();
                for (int i = 0; i < resultsDeployment.length; i++) {
                    TargetModuleID result = resultsDeployment[i];
                    consoleReader.printString(DeployUtils.reformat("Deployed"
                            + " "
                            + result.getModuleID()
                            + (multipleTargets ? " to " + result.getTarget().getName() : "")
                            + (result.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "
                                    + result.getWebURL()), 4, 72));
                    if (result.getChildTargetModuleID() != null) {
                        for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                            TargetModuleID child = result.getChildTargetModuleID()[j];
                            consoleReader.printString(DeployUtils.reformat("  `-> "
                                    + child.getModuleID()
                                    + (child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "
                                            + child.getWebURL()), 4, 72));
                        }
                    }
                }
                // print the results that succeeded
                TargetModuleID[] results = po.getResultTargetModuleIDs();
                for (int i = 0; i < results.length; i++) {
                    TargetModuleID result = results[i];
                    consoleReader.printString(DeployUtils.reformat(getAction()
                            + " "
                            + result.getModuleID()
                            + (multipleTargets ? " to " + result.getTarget().getName() : "")
                            + (result.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "
                                    + result.getWebURL()), 4, 72));
                    if (result.getChildTargetModuleID() != null) {
                        for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                            TargetModuleID child = result.getChildTargetModuleID()[j];
                            consoleReader.printString(DeployUtils.reformat("  `-> "
                                    + child.getModuleID()
                                    + (child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ "
                                            + child.getWebURL()), 4, 72));
                        }
                    }
                }
                // if any results failed then throw so that we'll return non-0 to the operating system
                if (po.getDeploymentStatus().isFailed()) {
                    throw new DeploymentException("Operation failed: " + po.getDeploymentStatus().getMessage());
                }
            } else { // case of local redeployment
                List<TargetModuleID> modules = new ArrayList<TargetModuleID>();
                File module = null;
                File plan = null;
                File test = new File(args[0]); // Guess whether the first argument is a module or a plan
                if (!test.exists()) {
                    throw new DeploymentSyntaxException("Module or plan file does not exist: " + test.getAbsolutePath());
                }
                if (!test.canRead()) {
                    throw new DeploymentException("Cannot read file " + test.getAbsolutePath());
                }
                if (JarUtils.isJarFile(test) || test.isDirectory()) {
                    module = test;
                } else {
                    plan = test;
                }
                if (args.length > 1) { // Guess whether the second argument is a module, plan, ModuleID or TargetModuleID
                    test = new File(args[1]);
                    if (test.exists() && test.canRead() && !args[1].equals(args[0])) {
                        if (JarUtils.isJarFile(test) || test.isDirectory()) {
                            if (module != null) {
                                throw new DeploymentSyntaxException(
                                        "Module and plan cannot both be JAR files or directories!");
                            }
                            module = test;
                        } else {
                            if (plan != null) {
                                throw new DeploymentSyntaxException("Module or plan must be a JAR file or directory!");
                            }
                            plan = test;
                        }
                    } else {
                        modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[1], false));
                    }
                }
                for (int i = 2; i < args.length; i++) { // Any arguments beyond 2 must be a ModuleID or TargetModuleID
                    modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, args[i], false));
                }
                // If we don't have any moduleIDs, try to guess one.
                if (modules.size() == 0 && connection.isGeronimo()) {
                    emit(consoleReader,
                            "No ModuleID or TargetModuleID provided.  Attempting to guess based on the content of the "
                                    + (plan == null ? "archive" : "plan") + ".");
                    String moduleId = null;
                    try {
                        if (plan != null) {
                            moduleId = DeployUtils.extractModuleIdFromPlan(plan);
                            if (moduleId == null) { // plan just doesn't have a config ID
                                String fileName = module == null ? plan.getName() : module.getName();
                                int pos = fileName.lastIndexOf('.');
                                String artifactId = pos > -1 ? module.getName().substring(0, pos) : module.getName();
                                moduleId = Artifact.DEFAULT_GROUP_ID + "/" + artifactId + "//";
                                emit(consoleReader,
                                        "Unable to locate Geronimo deployment plan in archive.  Calculating default ModuleID from archive name.");
                            }
                        } else if (module != null) {
                            moduleId = DeployUtils.extractModuleIdFromArchive(module);
                            if (moduleId == null) {
                                int pos = module.getName().lastIndexOf('.');
                                String artifactId = pos > -1 ? module.getName().substring(0, pos) : module.getName();
                                moduleId = Artifact.DEFAULT_GROUP_ID + "/" + artifactId + "//";
                                emit(consoleReader,
                                        "Unable to locate Geronimo deployment plan in archive.  Calculating default ModuleID from archive name.");
                            }
                        }
                    } catch (IOException e) {
                        throw new DeploymentException("Unable to read input files: " + e.getMessage(), e);
                    }
                    if (moduleId != null) {
                        emit(consoleReader, "Attempting to use ModuleID '" + moduleId + "'");
                        modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId, true));
                    } else {
                        emit(consoleReader, "Unable to calculate a ModuleID from supplied module and/or plan.");
                    }
                }
                if (modules.size() == 0) { // Either not deploying to Geronimo or unable to identify modules
                    throw new DeploymentSyntaxException(
                            "No ModuleID or TargetModuleID available.  Nothing to do.  Maybe you should add a ModuleID or TargetModuleID to the command line?");
                }
                if (module != null) {
                    module = module.getAbsoluteFile();
                }
                if (plan != null) {
                    plan = plan.getAbsoluteFile();
                }
                // Now that we've sorted out all the arguments, do the work
                TargetModuleID[] ids = modules.toArray(new TargetModuleID[modules.size()]);
                boolean multiple = isMultipleTargets(ids);
                po = mgr.redeploy(ids, module, plan);
                waitForProgress(consoleReader, po);
                TargetModuleID[] done = po.getResultTargetModuleIDs();
                for (int i = 0; i < done.length; i++) {
                    TargetModuleID id = done[i];
                    emit(consoleReader, "Redeployed " + id.getModuleID()
                            + (multiple ? " on " + id.getTarget().getName() : "")
                            + (id.getWebURL() == null ? "" : " @ " + id.getWebURL()));
                    if (id.getChildTargetModuleID() != null) {
                        for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
                            TargetModuleID child = id.getChildTargetModuleID()[j];
                            emit(consoleReader, "  `-> " + child.getModuleID()
                                    + (child.getWebURL() == null ? "" : " @ " + child.getWebURL()));
                        }
                    }
                }
            }
        } catch (IOException e) {
View Full Code Here

        for (TargetModuleID result : results) {
            out.printString(DeployUtils.reformat(
                    getAction() + " " + result.getModuleID() + (multipleTargets ? " to " + result.getTarget().getName() : "") + (result.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ " + result.getWebURL()), 4, 72));
            if (result.getChildTargetModuleID() != null) {
                for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                    TargetModuleID child = result.getChildTargetModuleID()[j];
                    out.printString(DeployUtils.reformat("  `-> " + child.getModuleID() + (child.getWebURL() == null || !getAction().equals("Deployed") ? "" : " @ " + child.getWebURL()), 4, 72));
                }
            }
        }

        // if any results failed then throw so that we'll return non-0
View Full Code Here

            boolean multiple = isMultipleTargets(ids);
            po = runCommand(consoleReader, mgr, ids);
            TargetModuleID[] done = po.getResultTargetModuleIDs();
            consoleReader.printNewline();
            for(int i = 0; i < done.length; i++) {
                TargetModuleID id = done[i];
                consoleReader.printString(DeployUtils.reformat((getAction()+" "+id.getModuleID()+((multiple && id.getTarget() != null) ? " on "+ id.getTarget().getName() : "")+(id.getWebURL() == null || !getAction().equals("Started") ? "" : " @ "+id.getWebURL())), 4, 72));
                if(id.getChildTargetModuleID() != null) {
                    for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
                        TargetModuleID child = id.getChildTargetModuleID()[j];
                        consoleReader.printString(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4, 72));
                    }
                } // Also print childs if existing in earlier configuration
                else{
                    java.util.Iterator iterator = DeployUtils.identifyTargetModuleIDs(allModules, id.getModuleID(), false).iterator();
                    if(iterator.hasNext()){
                        TargetModuleID childs = (TargetModuleID)iterator.next();
                        if(childs.getChildTargetModuleID() != null) {
                            for (int j = 0; j < childs.getChildTargetModuleID().length; j++) {
                                TargetModuleID child = childs.getChildTargetModuleID()[j];
                                consoleReader.printString(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL() == null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4, 72));
                            }
                        }
                    }
                }
//                consoleReader.printNewline();
View Full Code Here

    }

    protected static boolean isMultipleTargets(TargetModuleID[] ids) {
        Set<String> set = new HashSet<String>();
        for (int i = 0; i < ids.length; i++) {
            TargetModuleID id = ids[i];
            set.add(id.getTarget().getName());
        }
        return set.size() > 1;
    }
View Full Code Here

     * @param prefix a <code>String</code> value that will be
     * prepended to each module
     */
    void printTargetModules(ConsoleReader out, Target target, TargetModuleID[] modules, String prefix) throws IOException {
        for (int i = 0; i < modules.length; i++) {
            TargetModuleID result = modules[i];
            if (result.getTarget().equals(target)) {
                out.printString(prefix+result.getModuleID());
                out.printNewline();
                if(result.getChildTargetModuleID() != null) {
                    for (int j = 0; j < result.getChildTargetModuleID().length; j++) {
                        TargetModuleID child = result.getChildTargetModuleID()[j];
                        out.printString("      `-> "+child.getModuleID());
                        out.printNewline();
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.enterprise.deploy.spi.TargetModuleID

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.