Package org.apache.geronimo.cli.deployer

Examples of org.apache.geronimo.cli.deployer.InstallBundleCommandArgs


       
        if (!isOffline(connection)) {
            if (!(commandArgs instanceof InstallBundleCommandArgs)) {
                throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + InstallBundleCommandArgs.class + "]");
            }
            InstallBundleCommandArgs recordBundleCommandArgs = (InstallBundleCommandArgs) commandArgs;
           
            File bundleFile = new File(recordBundleCommandArgs.getArgs()[0]);
            if(!bundleFile.exists() || !bundleFile.isFile() || !bundleFile.canRead()) {
                throw new DeploymentException("File does not exist or not a normal file or not readable. "+bundleFile);
            }
           
            DeploymentManager dmgr = connection.getDeploymentManager();
            if(dmgr instanceof GeronimoDeploymentManager) {
                GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
               
                boolean start = recordBundleCommandArgs.isStart();
                int startLevel = recordBundleCommandArgs.getStartLevel();
                String groupId = recordBundleCommandArgs.getGroupId();
                try {
                    long bundleId = mgr.recordInstall(bundleFile, groupId, startLevel);
                    if ( bundleId > 0 ){
                        consoleReader.printString(DeployUtils.reformat("Installed and recorded bundle: " + bundleId, 4, 72));
                       
                        if (start){
                            if(mgr instanceof RemoteDeploymentManager) {
                                MBeanServerConnection mbsc = ((RemoteDeploymentManager) mgr).getJMXConnector().getMBeanServerConnection();
                                try {
                                    FrameworkMBean frameworkMBean = getFrameworkMBean(mbsc);
                                    frameworkMBean.startBundle(bundleId);
                                    consoleReader.printString(DeployUtils.reformat("Started bundle: " + bundleId, 4, 72));
                                } catch (Exception e) {
                                    throw new DeploymentException("Unable to start bundle.", e);
                                }
                               
                            }else {
                                consoleReader.printString(DeployUtils.reformat("Currently the start option only support JMX connection.", 4, 72));
                            }
                        }
                    }else {
                        consoleReader.printString(DeployUtils.reformat("Bundle installation failed, so did not record bundle.", 4, 72));
                    }
                } catch (Exception e) {
                    throw new DeploymentException("Unable to record bundle "+recordBundleCommandArgs.getArgs()[0], e);
                }
            } else {
                throw new DeploymentException("Unable to record bundle using " + dmgr.getClass().getName() + " deployment manager");
            }
           
View Full Code Here


    protected Object doExecute() throws Exception {
        ServerConnection connection = connect();

        CommandInstallBundle command = new CommandInstallBundle();

        InstallBundleCommandArgs args = new InstallBundleCommandArgsImpl(groupId, startLevel, start, new String[]{bundleFile});

        command.execute(this, connection, args);
        return null;
    }
View Full Code Here

       
        if (!isOffline(connection)) {
            if (!(commandArgs instanceof InstallBundleCommandArgs)) {
                throw new DeploymentSyntaxException("CommandArgs has the type [" + commandArgs.getClass() + "]; expected [" + InstallBundleCommandArgs.class + "]");
            }
            InstallBundleCommandArgs recordBundleCommandArgs = (InstallBundleCommandArgs) commandArgs;
           
            File bundleFile = new File(recordBundleCommandArgs.getArgs()[0]);
            if(!bundleFile.exists() || !bundleFile.isFile() || !bundleFile.canRead()) {
                throw new DeploymentException("File does not exist or not a normal file or not readable. "+bundleFile);
            }
           
            DeploymentManager dmgr = connection.getDeploymentManager();
            if(dmgr instanceof GeronimoDeploymentManager) {
                GeronimoDeploymentManager mgr = (GeronimoDeploymentManager) dmgr;
               
                boolean start = recordBundleCommandArgs.isStart();
                int startLevel = recordBundleCommandArgs.getStartLevel();
                String groupId = recordBundleCommandArgs.getGroupId();
                try {
                    long bundleId = mgr.recordInstall(bundleFile, groupId, startLevel);
                    if ( bundleId > 0 ){
                        consoleReader.printString(DeployUtils.reformat("Installed bundle: " + bundleId, 4, 72));
                       
                        if (start){
                            if(mgr instanceof RemoteDeploymentManager) {
                                MBeanServerConnection mbsc = ((RemoteDeploymentManager) mgr).getJMXConnector().getMBeanServerConnection();
                                try {
                                    FrameworkMBean frameworkMBean = getFrameworkMBean(mbsc);
                                    frameworkMBean.startBundle(bundleId);
                                    consoleReader.printString(DeployUtils.reformat("Started bundle: " + bundleId, 4, 72));
                                } catch (Exception e) {
                                    throw new DeploymentException("Unable to start bundle.", e);
                                }
                               
                            }else {
                                consoleReader.printString(DeployUtils.reformat("Currently the start option only support JMX connection.", 4, 72));
                            }
                        }
                    }else {
                        consoleReader.printString(DeployUtils.reformat("Bundle installation failed, so did not record bundle.", 4, 72));
                    }
                } catch (Exception e) {
                    throw new DeploymentException("Unable to record bundle "+recordBundleCommandArgs.getArgs()[0], e);
                }
            } else {
                throw new DeploymentException("Unable to record bundle using " + dmgr.getClass().getName() + " deployment manager");
            }
           
View Full Code Here

TOP

Related Classes of org.apache.geronimo.cli.deployer.InstallBundleCommandArgs

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.