Package org.rioproject.deploy

Examples of org.rioproject.deploy.DeployAdmin


            if(lineCounter % listLength==0)
                promptMore(br, out);
            out.println(provisioners[i]);
            try {
                if(items[i].service instanceof ProvisionMonitor) {
                    DeployAdmin deployAdmin = (DeployAdmin)((ProvisionMonitor)items[i].service).getAdmin();
                    OperationalStringManager[] opMgrs = deployAdmin.getOperationalStringManagers();
                    if(opMgrs.length==0)
                        out.println("\tNo Managed Deployments");
                    for (OperationalStringManager opMgr : opMgrs) {
                        listMgr(opMgr, br, out, lineCounter);
                    }
View Full Code Here


    static Map<String, DeployAdmin> getDeployedOpStrings(final ServiceItem[] items) {
        Map<String, DeployAdmin> map = new HashMap<String, DeployAdmin>();
        for (ServiceItem item : items) {
            try {
                DeployAdmin deployAdmin = (DeployAdmin) CLI.getInstance().getServiceFinder().
                        getPreparedAdmin(item.service);
                OperationalStringManager[] opMgrs = deployAdmin.getOperationalStringManagers();
                for (OperationalStringManager opMgr : opMgrs) {
                    OperationalString opString = opMgr.getOperationalString();
                    if (opMgr.isManaging()) {
                        map.put(opString.getName(), deployAdmin);
                    }
View Full Code Here

    static OperationalStringManager findOperationalStringManager(final ServiceItem[] items,
                                                                 final OperationalString deploy) {
        OperationalStringManager primary = null;
        for (ServiceItem item : items) {
            try {
                DeployAdmin deployAdmin =
                    (DeployAdmin) CLI.getInstance().getServiceFinder().getPreparedAdmin(item.service);
                OperationalStringManager[] opMgrs = deployAdmin.getOperationalStringManagers();
                for (OperationalStringManager opMgr : opMgrs) {
                    OperationalString opString = opMgr.getOperationalString();
                    if (opString.getName().equals(deploy.getName()) && opMgr.isManaging()) {
                        primary = opMgr;
                        break;
View Full Code Here

                      final OperationalString deploy,
                      final DeployOptions deployOptions,
                      final BufferedReader br,
                      final PrintStream out) {
            try {
                DeployAdmin deployAdmin = (DeployAdmin)CLI.getInstance().getServiceFinder().getPreparedAdmin(item.service);
                Boolean wait = (Boolean) CLI.getInstance().settings.get(CLI.DEPLOY_BLOCK);
                if (deployAdmin.hasDeployed(deploy.getName())) {
                    if (deployOptions.update()) {
                        try {
                            out.print("The [" + deploy.getName() + "] is currently deployed, updating ...\n");
                            OperationalStringManager mgr = deployAdmin.getOperationalStringManager(deploy.getName());
                            mgr.update(deploy);
                        } catch (Exception e) {
                            e.printStackTrace();
                            return ("Exception "+e.getClass()+":"+e.getLocalizedMessage()+", check log for details");
                        }
                    } else {
                        if (deployOptions.noPrompt()) {
                            return ("The [" + deploy.getName() + "] is currently deployed, interactive mode disabled, " +
                                    "returning");
                        }
                        out.print("The ["+deploy.getName()+"] is currently deployed, update the deployment? [y/n] ");
                        BufferedReader reader = br;
                        try {
                            if (reader == null)
                                reader = new BufferedReader(new InputStreamReader(System.in));
                            String response = reader.readLine();
                            if (response == null) {
                                return ("");
                            }
                            if (response.startsWith("y") || response.startsWith("Y")) {
                                OperationalStringManager mgr = deployAdmin.getOperationalStringManager(deploy.getName());
                                mgr.update(deploy);
                                return ("Updated");
                            } else {
                                return ("Skipped");
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            return ("Exception "+e.getClass()+":"+e.getLocalizedMessage()+", check log for details");
                        }
                    }
                } else {
                    if (deployOptions.getDeployTimeout() > 0 && wait) {
                        ServiceProvisionNotification spn = CLI.getInstance().provisionNotifier;
                        deployAdmin.deploy(deploy, spn.getServiceProvisionListener());
                        long t0 = System.currentTimeMillis();
                        out.println("Deploying [" +
                                    ServiceProvisionNotification.getDeploymentNames(deploy) + "], " +
                                    "total services ["+ServiceProvisionNotification.sumUpServices(deploy) + "] ...");
                        spn.notify(
                            ServiceProvisionNotification.sumUpServices(deploy),
                            deployOptions.getDeployTimeout());
                        long t1 = System.currentTimeMillis();
                        return ((deployOptions.verbose ?
                                 "Deployment notification time " +(t1 - t0) + " millis, Command completed"
                                                       : ""));
                    } else {
                        deployAdmin.deploy(deploy, null);
                    }
                }
                return ((deployOptions.verbose ? "Command completed" : ""));
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

                e.printStackTrace();
                return("Problem resolving ["+deployName+"], Exception : "+e.getLocalizedMessage());
            }

            try {
                DeployAdmin deployAdmin =
                    (DeployAdmin)CLI.getInstance().getServiceFinder().getPreparedAdmin(item.service);
                Boolean wait = (Boolean)CLI.getInstance().settings.get(CLI.DEPLOY_BLOCK);

                if(deployOptions.getDeployTimeout()>0 && wait) {
                    ServiceProvisionNotification spn = CLI.getInstance().provisionNotifier;
                    String label = "Artifact";
                    if(isArtifact) {
                        deployAdmin.deploy(deployName, spn.getServiceProvisionListener());
                    } else {
                        label = "OAR";
                        try{
                            //deployAdmin.deploy(toDeploy, spn.getServiceProvisionListener());
                            deployAdmin.deploy(oarUrl, spn.getServiceProvisionListener());
                        } finally {
                            if(embeddedWebster!=null)
                                embeddedWebster.terminate();
                        }
                    }
                    long t0 = System.currentTimeMillis();
                    out.println("Deploying "+label+" ["+deployName+"] ...");
                    spn.notify(1, deployOptions.getDeployTimeout());
                    long t1 = System.currentTimeMillis();
                    return((deployOptions.verbose?
                            "Deployment notification time "+(t1-t0)+" millis, Command completed":""));
                } else {
                    if(isArtifact)
                        deployAdmin.deploy(deployName, null);
                    else
                        deployAdmin.deploy(toDeploy, null);
                }

                return((deployOptions.verbose?"Command completed":""));
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

                                printRequest(out);
                            } else {
                                try {
                                    String opStringName =
                                        entries[num - 1].getKey();
                                    DeployAdmin dAdmin =
                                        entries[num - 1].getValue();
                                    dAdmin.undeploy(opStringName);
                                    out.println("Command successful");
                                } catch (Exception e) {
                                    return ("Problem undeploying " +
                                            deployment + ", " +
                                            "Exception :" +
                                            e.getClass().getName() + ": " +
                                            e.getLocalizedMessage());
                                }
                            }
                            break;
                        } catch (NumberFormatException e) {
                            out.println("Invalid choice [" + response + "]");
                            printRequest(out);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                return ("");
            }
            //OperationalString toUndeploy = null;
            String undeployName = null;
            try {
                new Artifact(deployment);
                undeployName = deployment;
            } catch(Exception e) {
                /* */
            }
            if (deployment.endsWith("oar")) {
                try {
                    File oarFile = getDeploymentFile(deployment);
                    OAR oar = new OAR(oarFile);
                    OperationalString toUndeploy = oar.loadOperationalStrings()[0];
                    undeployName = toUndeploy.getName();
                } catch (Exception e) {
                    return ("Problem loading [" + deployment + "], " +
                            "Exception : " + e.getLocalizedMessage() + "\n");
                }
            }

            if(undeployName==null) {
                try {
                    OperationalString toUndeploy = loadDeployment(deployment);
                    if (toUndeploy == null) {
                        return (deployment + ": Cannot find file\n");
                    }
                    undeployName = toUndeploy.getName();
                } catch (Exception e) {
                    return ("Problem loading [" + deployment + "], " +
                            "Exception : " + e.getLocalizedMessage() + "\n");
                }
            }

            try {
                DeployAdmin dAdmin =
                (DeployAdmin) CLI.getInstance().getServiceFinder().getPreparedAdmin(items[0].service);
                try {
                    dAdmin.undeploy(undeployName);
                    out.println("Command successful");
                } catch(OperationalStringException e) {
                    if(e.getMessage().startsWith("No deployment for")) {
                        return ("Command failed, no active deployment for " +
                                deployment);
View Full Code Here

                    JMenuItem undeploy = new JMenuItem("Undeploy");
                    undeploy.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent actionEvent) {
                            try {
                                DeployAdmin dAdmin =
                                    (DeployAdmin) node.getProvisionMonitor()
                                        .getAdmin();
                                dAdmin.undeploy(node.getOpStringName());
                            } catch (OperationalStringException e) {
                                GraphUtil.removeOpString(g,
                                                         item.getVisualization(),
                                                         node.getOpStringName());
                            } catch (Exception e) {
View Full Code Here

                                                 500);
        SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    ProvisionMonitor monitor = (ProvisionMonitor) item.service;
                    DeployAdmin dAdmin = (DeployAdmin) monitor.getAdmin();
                    for (OperationalString opString : opstrings) {
                        if (dAdmin.hasDeployed(opString.getName())) {
                            int result = JOptionPane.showConfirmDialog(frame,
                                                                       "The [" + opString.getName() + "] " +
                                                                       "is already deployed, " +
                                                                       "update the deployment?",
                                                                       "Update Deployed Application",
                                                                       JOptionPane.YES_NO_OPTION);
                            if (result == JOptionPane.YES_OPTION) {
                                dAdmin.getOperationalStringManager(opString.getName()).update(opString);
                            }
                        } else {
                            dAdmin.deploy(opString);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    Util.showError(e, frame, "Failure trying to deploy " + deployName);
View Full Code Here

        SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    ProvisionMonitor monitor = (ProvisionMonitor) item.service;
                    DeployAdmin dAdmin = (DeployAdmin) monitor.getAdmin();
                    dAdmin.deploy(artifact);
                } catch (Exception e) {
                    e.printStackTrace();
                    Throwable cause = e.getCause();
                    if(cause != null) {
                        Throwable nested = cause.getCause();
View Full Code Here

    @SuppressWarnings("unchecked")
    private <T> T doLookupService(String serviceName, String opstringName, Class<T> type) {
        T service = null;
        try {
            DeployAdmin dAdmin = (DeployAdmin)monitor.getAdmin();
            OperationalStringManager opMgr = dAdmin.getOperationalStringManager(opstringName);
            OperationalString opstring = opMgr.getOperationalString();
            ServiceElement serviceElement = null;
            for(ServiceElement elem : opstring.getServices()) {
                if(elem.getName().equals(serviceName)) {
                    serviceElement = elem;
View Full Code Here

TOP

Related Classes of org.rioproject.deploy.DeployAdmin

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.