@Resource(mappedName = "org.glassfish.embeddable.CommandRunner") CommandRunner commandRunner; public void configureLoginRealm() { CommandResult commandResult = commandRunner.run("create-auth-realm", "--classname=com.blah.blah.SecureJDBCRealm", "--property=jaas-context= secureJDBCRealm", "secure-JDBC-realm"); log.debug(commandResult.getExitStatus().toString() + " " + commandResult.getOutput()); Throwable throwable = commandResult.getFailureCause(); if (throwable != null) { log.error(throwable.getMessage(), throwable); } }
@Override public void execute(final TestContext ctx) throws Exception { log.info("delete auth realm"); CommandResult result = ctx.runCommand("delete-auth-realm", realmName); log.info("result={}", result.getExitStatus()); if (ExitStatus.FAILURE.equals(result.getExitStatus())) { log.error("command failed", result.getFailureCause()); fail(); } }
@Override public void configure(Properties props) throws GlassFishException { CommandRunner commandRunner = null; for (Object obj : props.keySet()) { String key = (String) obj; if (key.startsWith(CONFIG_PROP_PREFIX)) { if (commandRunner == null) { // only create the CommandRunner if needed commandRunner = habitat.getService(CommandRunner.class); } CommandResult result = commandRunner.run("set", key.substring(CONFIG_PROP_PREFIX.length()) + "=" + props.getProperty(key)); if (result.getExitStatus() != CommandResult.ExitStatus.SUCCESS) { throw new GlassFishException(result.getOutput()); } } } } }
public void removeVirtualCluster(String virtualClusterName) { try { VirtualCluster virtualCluster = virtualClusters.byName(virtualClusterName); if (virtualCluster != null) { virtualClusters.remove(virtualCluster); // removes config. } } catch (Exception ex) { logger.log(Level.WARNING,localStrings.getString("exception.while.remove.cluster",ex.getLocalizedMessage()),ex); } /* stop-cluster is deliberately commented. invoking stop-cluster causes the re-deploy to fail next time (due to IMS layer fails to create virtual-machine config). But since all the instances in the cluster are already stopped we don't really need to call stop-cluster. CommandResult commandResult = commandRunner.run("stop-cluster", virtualClusterName); Throwable failureCause = commandResult.getFailureCause(); if (failureCause != null) { logger.log(Level.WARNING, failureCause.getLocalizedMessage(), failureCause); } */ CommandResult commandResult = commandRunner.run("delete-cluster", virtualClusterName); Object args[]=new Object[]{virtualClusterName,commandResult.getOutput()}; logger.log(Level.INFO,"delete.cluster.exec.output",args); Throwable failureCause = commandResult.getFailureCause(); if (failureCause != null) { args[0]= failureCause.getLocalizedMessage(); args[1]=failureCause; logger.log(Level.WARNING,localStrings.getString("failure.cause",args[0]),args[1]); } }
String command = "list-jdbc-resources"; CommandRunner commandRunner = glassfish.getCommandRunner(); CommandResult commandResult = commandRunner.run(command); System.out.println("jdbc resources=" + commandResult.getOutput()); Logger.getLogger(this.getClass().getName()).log(Level.INFO,"jdbc resources=" +commandResult.getOutput());
@Override public void configure(Properties props) throws GlassFishException { CommandRunner commandRunner = null; for (Object obj : props.keySet()) { String key = (String) obj; if (key.startsWith(CONFIG_PROP_PREFIX)) { if (commandRunner == null) { // only create the CommandRunner if needed commandRunner = habitat.getService(CommandRunner.class); } CommandResult result = commandRunner.run("set", key.substring(CONFIG_PROP_PREFIX.length()) + "=" + props.getProperty(key)); if (result.getExitStatus() != CommandResult.ExitStatus.SUCCESS) { throw new GlassFishException(result.getOutput()); } } } } }
@Override public void execute(final TestContext ctx) throws Exception { log.info("Create auth realm"); CommandResult result = ctx .runCommand( "create-auth-realm", "--classname", realmClass.getName(), "--property", "jaas-context=" + jaasContext + ":datasource-jndi=jdbc/__default:user-table=users:group-table=groups:user-name-column=username:password-column=password:group-name-column=groupname", realmName); log.info("result={}", result.getExitStatus()); if (ExitStatus.FAILURE.equals(result.getExitStatus())) { log.error("command failed", result.getFailureCause()); fail(); } ctx.addTeardownCommand(new JDBCAuthRealmDelete(realmName)); }
CommandResult result = commandParams == null ? cr.run(command) : cr.run(command, commandParams); System.out.println("\n" + result.getOutput()); } catch (Exception ex) { System.out.println(ex.getMessage());
private String executeCommand(String command, String... parameterList) throws Throwable { CommandRunner runner = glassfish.getCommandRunner(); CommandResult result = runner.run(command, parameterList); String output = null; switch (result.getExitStatus()) { case FAILURE: case WARNING: throw result.getFailureCause(); case SUCCESS: output = result.getOutput(); log.info("command " + command + " parameters" + parameterList + " result: " + output); break; } return output; }
if(virtualClusterName != null){ CommandResult result = commandRunner.run("create-cluster", virtualClusterName); Object args[]=new Object[]{virtualClusterName,result.getOutput()}; logger.log(Level.INFO,"create.cluster.exec.output",args); if (result.getExitStatus().equals(CommandResult.ExitStatus.FAILURE)) { throw new RuntimeException("Failure while provisioning services, " + "Unable to create cluster [" + virtualClusterName + "]");
CommandResult result = commandParams == null ? cr.run(command) : cr.run(command, commandParams); System.out.println("\n" + result.getOutput()); } catch (Exception ex) { System.out.println(ex.getMessage());
String[] tokens = command.split("\\s"); CommandResult result = cmdRunner.run(tokens[0], Arrays.copyOfRange(tokens, 1, tokens.length)); System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) { result.getFailureCause().printStackTrace();
Object[] args = new Object[] {virtualClusterName,result.getOutput()}; logger.log(Level.FINEST,localStrings.getString("delete.cluster.exec.output",args)); if (result.getExitStatus().equals(CommandResult.ExitStatus.FAILURE)) { throw new RuntimeException("Failure while deleting virtual-cluster, " + "Unable to delete virtual-cluster [" + virtualClusterName + "]");
String[] tokens = command.split("\\s"); CommandResult result = cmdRunner.run(tokens[0], Arrays.copyOfRange(tokens, 1, tokens.length)); System.out.println(result.getExitStatus()); System.out.println(result.getOutput()); if (result.getFailureCause() != null) { result.getFailureCause().printStackTrace();