Package org.infinispan.cli.commands

Examples of org.infinispan.cli.commands.ProcessedCommand


      } catch (Exception e) {
      }
   }

   private void execute(final String line) {
      ProcessedCommand parsed = new ProcessedCommand(line);
      Command command = context.getCommandRegistry().getCommand(parsed.getCommand());
      if (command != null) {
         command.execute(context, parsed);
      } else {
         context.error("Command " + parsed.getCommand() + " unknown or not available");
      }
   }
View Full Code Here


      } catch (Exception e) {
      }
   }

   private void execute(final String line) {
      ProcessedCommand parsed = new ProcessedCommand(line);
      Command command = context.getCommandRegistry().getCommand(parsed.getCommand());
      if (command != null) {
         command.execute(context, parsed);
      } else {
         context.error("Command " + parsed.getCommand() + " unknown or not available");
      }
   }
View Full Code Here

@Test(groups="functional", testName="cli.shell.ProcessedCommandTest")
public class ProcessedCommandTest {

   public void testArgumentParsing() {
      ProcessedCommand pc = new ProcessedCommand("cmd abc");
      assert "cmd".equals(pc.getCommand());

      assert pc.getArguments().size()==1;

      assert "abc".equals(pc.getArguments().get(0).getValue());
   }
View Full Code Here

      assert "abc".equals(pc.getArguments().get(0).getValue());
   }

   public void testQuotedArgumentParsing() {
      ProcessedCommand pc = new ProcessedCommand("cmd \"abc\" \"def\"");
      assert "cmd".equals(pc.getCommand());

      assert pc.getArguments().size()==2;

      assert "abc".equals(pc.getArguments().get(0).getValue());
      assert "def".equals(pc.getArguments().get(1).getValue());
   }
View Full Code Here

      assert "abc".equals(pc.getArguments().get(0).getValue());
      assert "def".equals(pc.getArguments().get(1).getValue());
   }

   public void testMixedArgumentParsing() {
      ProcessedCommand pc = new ProcessedCommand("cmd \"abc\" 'def' ghi");
      assert "cmd".equals(pc.getCommand());

      assert pc.getArguments().size()==3;

      assert "abc".equals(pc.getArguments().get(0).getValue());
      assert "def".equals(pc.getArguments().get(1).getValue());
      assert "ghi".equals(pc.getArguments().get(2).getValue());
   }
View Full Code Here

      assert "def".equals(pc.getArguments().get(1).getValue());
      assert "ghi".equals(pc.getArguments().get(2).getValue());
   }

   public void testNoArguments() {
      ProcessedCommand pc = new ProcessedCommand("cmd ");
      assert "cmd".equals(pc.getCommand());

      assert pc.getArguments().size()==0;

      assert pc.isCommandComplete();
   }
View Full Code Here

   }

   @Override
   public MarshalledEntry<K, V> load(Object key) {
      // TODO: a CLI command to retrieve value + metadata is needed
      ProcessedCommand parsed = new ProcessedCommand("get " + key.toString() + ";");

      // Having CLI context as field of this cache loader produces all sorts of
      // issues when paralell requests are received, since the commands get
      // bunched up. This is valid in shell mode, but a bit problematic for
      // the cache loader. So, instead create a context instance for each
      // operation. This is obviously not very efficient, but this cache loader
      // should only be used during migration, so any inefficiencies should
      // only be temporary.
      Context cliCtx = createContext();
      Command command = cliCtx.getCommandRegistry().getCommand(parsed.getCommand());
      command.execute(cliCtx, parsed);
      ResponseMatcher.Result result = ((ResponseMatcher) cliCtx.getOutputAdapter())
            .getResult(Collections.singletonList(parsed));
      if (result.isError)
         throw new CacheException("Unable to load entry: " + result.result);
View Full Code Here

   }

   @Override
   public MarshalledEntry<K, V> load(K key) {
      // TODO: a CLI command to retrieve value + metadata is needed
      ProcessedCommand parsed = new ProcessedCommand("get " + key.toString() + ";");

      // Having CLI context as field of this cache loader produces all sorts of
      // issues when paralell requests are received, since the commands get
      // bunched up. This is valid in shell mode, but a bit problematic for
      // the cache loader. So, instead create a context instance for each
      // operation. This is obviously not very efficient, but this cache loader
      // should only be used during migration, so any inefficiencies should
      // only be temporary.
      Context cliCtx = createContext();
      Command command = cliCtx.getCommandRegistry().getCommand(parsed.getCommand());
      command.execute(cliCtx, parsed);
      ResponseMatcher.Result result = ((ResponseMatcher) cliCtx.getOutputAdapter())
            .getResult(Collections.singletonList(parsed));
      if (result.isError)
         throw new CacheException("Unable to load entry: " + result.result);
View Full Code Here

      } catch (Exception e) {
      }
   }

   private void execute(final String line) {
      ProcessedCommand parsed = new ProcessedCommand(line);
      Command command = context.getCommandRegistry().getCommand(parsed.getCommand());
      if (command != null) {
         command.execute(context, parsed);
      } else {
         context.error("Command " + parsed.getCommand() + " unknown or not available");
      }
   }
View Full Code Here

            if(command.isAvailable(context)) {
               candidates.add(name);
            }
         }
      } else {
         ProcessedCommand procCmd = new ProcessedCommand(buffer, op.getCursor());
         if(!procCmd.isCommandComplete()) {
            // A possibly incomplete command in the buffer, return the commands that match
            for(String name : context.getCommandRegistry().getCommandNames()) {
               Command command = context.getCommandRegistry().getCommand(name);
               if(command.isAvailable(context) && name.startsWith(procCmd.getCommand())) {
                  candidates.add(name);
               }
            }
         } else {
            Command command = context.getCommandRegistry().getCommand(procCmd.getCommand());
            if(command.isAvailable(context)) {
               op.setOffset(op.getCursor());
               for(Argument arg : procCmd.getArguments()) {
                  if(arg.getOffset()<op.getCursor()) {
                     op.setOffset(arg.getOffset());
                  } else {
                     break;
                  }
               }
               addPrefixMatches(procCmd.getCurrentArgument(), command.getOptions(), candidates);
               command.complete(context, procCmd, candidates);
            }
         }
      }
      Collections.sort(candidates);
View Full Code Here

TOP

Related Classes of org.infinispan.cli.commands.ProcessedCommand

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.