@Override public void exec(CLIContext ctx, String[] args) throws Exception { final ObjectName on = new ObjectName("Q2:type=qbean,service=*"); MBeanServer server = ctx.getCLI().getQ2().getMBeanServer(); Set<ObjectInstance> b = server.queryMBeans(on, null); Iterator<ObjectInstance> it = b.iterator(); while (it.hasNext()) { ObjectInstance instance = it.next(); int status = (Integer) server.getAttribute(instance.getObjectName(), "State"); if (status == QBean.STARTED) { ctx.println(instance.getObjectName().getKeyProperty("service") + "\t\t" + instance.getClassName()); } } }
@Override public void exec(CLIContext ctx, String[] args) throws Exception { if (args.length < 2) { ctx.println("Usage: enable <xml_file(no extenssion)>"); return; } File deployDir = ctx.getCLI().getQ2().getDeployDir(); File deploy = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml.off"); if (deploy.exists() && deploy.isFile()) { File dest = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml"); deploy.renameTo(dest); ctx.println("ENABLED: " + args[1]); return; } File dest = new File(deployDir.getAbsolutePath() + "/" + args[1] + ".xml"); if (dest.exists()) { ctx.println("Already enabled: " + args[1]); return; } ctx.println("Can't find the bean descriptor: " + args[1]); return; } }
@Override public void exec(CLIContext ctx, String[] args) throws Exception { if (args.length < 2) { ctx.println("Usage: enable <xml_file(no extenssion)>"); return; } File deployDir = ctx.getCLI().getQ2().getDeployDir(); File deploy = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml"); if(deploy.exists() && deploy.isFile()){ File dest = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml.off"); deploy.renameTo(dest); ctx.println("DISABLED: " + args[1]); return; } File dest = new File(deployDir.getAbsolutePath()+"/"+args[1]+".xml.off"); if (dest.exists()) { ctx.println("Already disabled: " + args[1]); return; } ctx.println("Can't find the bean descriptor: "+args[1]); return; } }
@Override public void exec(CLIContext ctx, String[] args) throws Exception { Q2 q2 = ctx.getCLI().getQ2(); File deployDir = q2.getDeployDir(); ctx.println(printDirectoryTree(deployDir)); return; }
public void exec(CLIContext ctx, String[] args) throws Exception { ctx.println(ISOUtil.millisToString(ctx.getCLI().getQ2().getUptime())); } }
MBeanServer server = ctx.getCLI().getQ2().getMBeanServer();
public void exec(CLIContext cli, String[] args) throws IOException { boolean shutdown; if (cli.isInteractive() && cli.getOutputStream() != System.out) { cli.println ("Can't shutdown remotely"); return; } if (hasOption(args, "-f", "--force", "-fq")) { shutdown = true; } else { shutdown = cli.confirm("Confirm shutdown (Yes/No) ? "); } if (shutdown) { if (!hasOption (args, "-q", "--quiet", "-fq")) cli.println("Shutting down."); cli.getCLI().getQ2().shutdown(); } else { cli.println("Q2 will continue running."); } }
if (cmd instanceof CLISubSystem) { CLISubSystem ss = (CLISubSystem) cmd; ctx.getCLI().setPrompt(ss.getPrompt(ctx, args), ss.getCompletionPrefixes(ctx, args));