Package javax.enterprise.deploy.spi

Examples of javax.enterprise.deploy.spi.DeploymentManager


    public CommandListConfigurations(String command, String group, String helpArgumentList, String helpText) {
        super(command, group, helpArgumentList, helpText);
    }

    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
        DeploymentManager dmgr = connection.getDeploymentManager();
        if(dmgr instanceof GeronimoDeploymentManager) {
            GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
            try {
                String repo = null;
                if(args.length == 1) {
View Full Code Here


    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
        setOut(out);
        if(args.length == 0) {
            throw new DeploymentSyntaxException("Must specify a module or plan (or both) and optionally module IDs to replace");
        }
        DeploymentManager mgr = connection.getDeploymentManager();
        Target[] allTargets = mgr.getTargets();
        TargetModuleID[] allModules;
        try {
            allModules = mgr.getAvailableModules(null, allTargets);
        } catch(TargetException e) {
            throw new DeploymentException("Unable to load modules from server", e);
        }
        List modules = new ArrayList();
        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("Must specify a module or plan (or both) and optionally module IDs to replace");
        }
        if(!test.canRead()) {
            throw new DeploymentException("Cannot read file "+test.getAbsolutePath());
        }
        if(DeployUtils.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(DeployUtils.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("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("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("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());
            }
            if(moduleId != null) {
                emit("Attempting to use ModuleID '"+moduleId+"'");
                modules.addAll(DeployUtils.identifyTargetModuleIDs(allModules, moduleId, true));
            } else {
                emit("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 = (TargetModuleID[]) modules.toArray(new TargetModuleID[modules.size()]);
        boolean multiple = isMultipleTargets(ids);
        ProgressObject po = mgr.redeploy(ids, module, plan);
        waitForProgress(out, po);
        TargetModuleID[] done = po.getResultTargetModuleIDs();
        for(int i = 0; i < done.length; i++) {
            TargetModuleID id = done[i];
            emit("Redeployed "+id.getModuleID()+(multiple ? " on "+id.getTarget().getName() : "")+(id.getWebURL() == null ? "" : " @ "+id.getWebURL()));
View Full Code Here

        ClassLoader oldcl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            DeploymentFactoryManager factoryManager = DeploymentFactoryManager.getInstance();
            DeploymentManager manager = factoryManager.getDeploymentManager(getUri(), getUsername(), getPassword());
            return manager;
        } finally {
            Thread.currentThread().setContextClassLoader(oldcl);
        }
    }
View Full Code Here

    public void setId(String id) {
        this.id = id;
    }

    public void execute() throws Exception {
        DeploymentManager manager = getDeploymentManager();

        Target[] targets = manager.getTargets();
        TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
        List toUndeploy = new ArrayList(moduleIds.length);
        for (int i = 0; i < moduleIds.length; i++) {
            TargetModuleID moduleId = moduleIds[i];
            if (getId().equals(moduleId.getModuleID())) {
                toUndeploy.add(moduleId);
            }
        }
        if (toUndeploy.size() == 0) {
            System.out.println("Module is running or not deployed: " + getId());
            return;
        }
        moduleIds = (TargetModuleID[]) toUndeploy.toArray(new TargetModuleID[toUndeploy.size()]);
        ProgressObject progress = manager.undeploy(moduleIds);
        DeploymentClient.waitFor(progress);
    }
View Full Code Here

    public void setPlan(String plan) {
        this.plan = plan;
    }

    public void execute() throws Exception {
        DeploymentManager manager = getDeploymentManager();

        Target[] targets = manager.getTargets();
        File moduleFile = (getModule() == null)? null: getFile(getModule());
        File planFile = (getPlan() == null)? null: getFile((getPlan()));
        ProgressObject progress = manager.distribute(targets, moduleFile, planFile);
        DeploymentClient.waitFor(progress);
    }
View Full Code Here

    public void setId(String id) {
        this.id = id;
    }

    public void execute() throws Exception {
        DeploymentManager manager = getDeploymentManager();

        Target[] targets = manager.getTargets();
        TargetModuleID moduleIds[] = manager.getNonRunningModules(null, targets);
        List toStart = new ArrayList(moduleIds.length);
        for (int i = 0; i < moduleIds.length; i++) {
            TargetModuleID moduleId = moduleIds[i];
            if (getId().equals(moduleId.getModuleID())) {
                toStart.add(moduleId);
            }
        }
        if (toStart.size() == 0) {
            System.out.println("Module is already running or may not be deployed: " + getId());
            return;
        }
        moduleIds = (TargetModuleID[]) toStart.toArray(new TargetModuleID[toStart.size()]);
        ProgressObject progress = manager.start(moduleIds);
        DeploymentClient.waitFor(progress);
    }
View Full Code Here

    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
        if(args.length == 0) {
            throw new DeploymentSyntaxException("Must specify at least one module name or TargetModuleID");
        }
        DeploymentManager mgr = connection.getDeploymentManager();
        Target[] allTargets = mgr.getTargets();
        TargetModuleID[] allModules;
        try {
            allModules = mgr.getAvailableModules(null, allTargets);
        } catch(TargetException e) {
            throw new DeploymentException("Unable to load module list from server", e);
        }
        List modules = new ArrayList();
        for(int i=0; i<args.length; i++) {
View Full Code Here

    public void execute(PrintWriter out, ServerConnection connection, String[] args) throws DeploymentException {
        if(args.length == 0) {
            throw new DeploymentSyntaxException("Must specify Plugin CAR file");
        }
        DeploymentManager dmgr = connection.getDeploymentManager();
        if(dmgr instanceof GeronimoDeploymentManager) {
            GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
            File carFile = new File(args[0]);
            carFile = carFile.getAbsoluteFile();
            if(!carFile.exists() || !carFile.canRead()) {
View Full Code Here

                }
            } else {
                targets.add(arg);
            }
        }
        final DeploymentManager mgr = connection.getDeploymentManager();
        TargetModuleID[] running = null, notrunning = null;
        Target[] tlist = identifyTargets(targets, mgr);
        if(tlist.length == 0) {
            tlist = mgr.getTargets();
        }
        try {
            if(started == null || started.booleanValue()) {
                running = mgr.getRunningModules(null, tlist);
            }
            if(started == null || !started.booleanValue()) {
                notrunning = mgr.getNonRunningModules(null, tlist);
            }
        } catch (TargetException e) {
            throw new DeploymentException("Unable to query modules", e);
        } catch (IllegalStateException e) {
            throw new DeploymentSyntaxException(e.getMessage());
View Full Code Here

        }
        executeOnline(connection, inPlaceHolder.inPlace, targets, out, module, plan);
    }

    private void executeOnline(ServerConnection connection, boolean inPlace, List targets, PrintWriter out, File module, File plan) throws DeploymentException {
        final DeploymentManager mgr = connection.getDeploymentManager();
        TargetModuleID[] results;
        boolean multipleTargets;
        ProgressObject po;
        if(targets.size() > 0) {
            Target[] tlist = identifyTargets(targets, mgr);
            multipleTargets = tlist.length > 1;
            po = runCommand(mgr, out, inPlace, tlist, module, plan);
            waitForProgress(out, po);
        } else {
            final Target[] tlist = mgr.getTargets();
            multipleTargets = tlist.length > 1;
            po = runCommand(mgr, out, inPlace, tlist, module, plan);
            waitForProgress(out, po);
        }
View Full Code Here

TOP

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

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.