Package org.glassfish.embeddable

Examples of org.glassfish.embeddable.CommandRunner


        gf = GlassFishRuntime.bootstrap().newGlassFish(gfProps);
       
        gf.start();

        CommandRunner cr = gf.getCommandRunner();

        while (true) {
            System.out.print("\n\nGlassFish $ ");
            String str = null;
            try {
                str = new BufferedReader(new InputStreamReader(System.in)).readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (str != null && str.trim().length() != 0) {
                if ("exit".equalsIgnoreCase(str) || "quit".equalsIgnoreCase(str)) {
                    break;
                }
                String[] split = str.split(" ");
                String command = split[0].trim();
                String[] commandParams = null;
                if (split.length > 1) {
                    commandParams = new String[split.length - 1];
                    for (int i = 1; i < split.length; i++) {
                        commandParams[i - 1] = split[i].trim();
                    }
                }
                try {
                    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());
                }
            }
View Full Code Here


        this.habitat = habitat;
    }

    @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());
                }
            }
View Full Code Here

        addShutdownHook(); // handle Ctrt-C.

        gf = GlassFishRuntime.bootstrap().newGlassFish();
        gf.start();

        CommandRunner cr = gf.getCommandRunner();

        while (true) {
            System.out.print("\n\nGlassFish $ ");
            String str = null;
            try {
                str = new BufferedReader(new InputStreamReader(System.in)).readLine();
            } catch (Exception e) {
                e.printStackTrace();
            }
            if (str != null && str.trim().length() != 0) {
                if ("exit".equalsIgnoreCase(str) || "quit".equalsIgnoreCase(str)) {
                    break;
                }
                String[] split = str.split(" ");
                String command = split[0].trim();
                String[] commandParams = null;
                if (split.length > 1) {
                    commandParams = new String[split.length - 1];
                    for (int i = 1; i < split.length; i++) {
                        commandParams[i - 1] = split[i].trim();
                    }
                }
                try {
                    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());
                }
            }
View Full Code Here

    public ConfiguratorImpl(Habitat habitat) {
        this.habitat = habitat;
    }

    public void configure(Properties props) throws GlassFishException {
        CommandRunner commandRunner = habitat.getComponent(CommandRunner.class);
        for (Object obj : props.keySet()) {
            String key = (String) obj;
            if (key.startsWith(CONFIG_PROP_PREFIX)) {
                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());
                }
            }
View Full Code Here

      }
   }
  
   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:
View Full Code Here

      }
      return output;
   }
  
   private void bindCommandRunner() throws NamingException, GlassFishException  {
        CommandRunner runner = glassfish.getCommandRunner();
        new InitialContext().bind("org.glassfish.embeddable.CommandRunner", runner);
   }
View Full Code Here

      }
   }
  
   private void executeCommand(String command, String... parameterList) throws Throwable
   {
      CommandRunner runner = glassfish.getCommandRunner();
      CommandResult result = runner.run(command, parameterList);

      switch(result.getExitStatus())
      {
         case FAILURE:
         case WARNING:
View Full Code Here

            break;
      }
   }
  
   private void bindCommandRunner() throws NamingException, GlassFishException  {
        CommandRunner runner = glassfish.getCommandRunner();
        new InitialContext().bind("org.glassfish.embeddable.CommandRunner", runner);
   }
View Full Code Here

      }
   }
  
   private void executeCommand(String command, String... parameterList) throws Throwable
   {
      CommandRunner runner = glassfish.getCommandRunner();
      CommandResult result = runner.run(command, parameterList);

      switch(result.getExitStatus())
      {
         case FAILURE:
         case WARNING:
View Full Code Here

            break;
      }
   }
  
   private void bindCommandRunner() throws NamingException, GlassFishException  {
        CommandRunner runner = glassfish.getCommandRunner();
        new InitialContext().bind("org.glassfish.embeddable.CommandRunner", runner);
   }
View Full Code Here

TOP

Related Classes of org.glassfish.embeddable.CommandRunner

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.