Package org.crsh.command

Examples of org.crsh.command.ScriptException


  public static ScriptException unwrap(groovy.util.ScriptException cause) {
    // Special handling for groovy.util.ScriptException
    // which may be thrown by scripts because it is imported by default
    // by groovy imports
    String msg = cause.getMessage();
    ScriptException translated;
    if (msg != null) {
      translated = new ScriptException(msg);
    } else {
      translated = new ScriptException();
    }
    translated.setStackTrace(cause.getStackTrace());
    return translated;
  }
View Full Code Here


    try {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      return server.getMBeanInfo(mbean);
    }
    catch (JMException e) {
      throw new ScriptException("Could not retrieve mbean " + mbean + "info", e);
    }
  }
View Full Code Here

            MBeanInfo mbeanInfo;
            try {
              mbeanInfo = server.getMBeanInfo(mbean);
            }
            catch (JMException e) {
              throw new ScriptException(e);
            }
            for (MBeanAttributeInfo attributeInfo : mbeanInfo.getAttributes()) {
              if (attributeInfo.isReadable()) {
                tmp.add(attributeInfo.getName());
              }
            }
          }
          names = tmp.toArray(new String[tmp.size()]);
        } else {
          names = attributes.toArray(new String[attributes.size()]);
        }

        // Produce the output
        for (ObjectName mbean : buffer) {
          LinkedHashMap<String, Object> tuple = new LinkedHashMap<String, Object>();
          if (name != null) {
            tuple.put(name, mbean);
          }
          for (String name : names) {
            Object value;
            try {
              value = server.getAttribute(mbean, name);
            }
            catch (RuntimeMBeanException runtime) {
              if (Boolean.TRUE.equals(silent)) {
                throw new ScriptException(runtime.getCause());
              } else {
                value = null;
              }
            }
            catch (AttributeNotFoundException e) {
              value = null;
            }
            catch (JMException e) {
              throw new ScriptException(e);
            }
            tuple.put(name, value);
          }
          context.provide(tuple);
        }
View Full Code Here

            "}\n";
    lifeCycle.bindClass("producer", Commands.ProduceInteger.class);
    lifeCycle.bindGroovy("consumer", consumer);
    Commands.list.clear();
    Throwable t = assertError("producer | consumer", ErrorKind.EVALUATION);
    ScriptException ex = assertInstance(ScriptException.class, t);
    assertEquals("foo", ex.getMessage());
  }
View Full Code Here

            if (lang.isActive()) {
              found = lang.getRepl();
              if (found != null) {
                break;
              } else {
                throw new ScriptException("Language " + name + " does not provide a repl");
              }
            } else {
              throw new ScriptException("Language " + name + " not active");
            }
          }
        }
        if (found != null) {
          session.setRepl(found);
          context.provide("Using repl " + name);
        } else {
          throw new ScriptException("Repl " + name + " not found");
        }
      }
    } else {

      //
View Full Code Here

TOP

Related Classes of org.crsh.command.ScriptException

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.