@Override
 public Object call(
     Object o,
     Object o2,
     Object o3,
     Object o4,
     Object o5,
     Object o6,
     Object o7,
     Object o8,
     Object o9,
     Object o10,
     Object o11,
     Object o12,
     Object o13,
     Object o14)
     throws Exception {
   Method udfMethod = udfClass.getDeclaredMethod(udfMethodName, parameterTypes);
   try {
     if (Modifier.isStatic(udfMethod.getModifiers())) {
       return udfMethod.invoke(null, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14);
     } else {
       Object udfInstance = udfClass.newInstance();
       return udfMethod.invoke(
           udfInstance, o, o2, o3, o4, o5, o6, o7, o8, o9, o10, o11, o12, o13, o14);
     }
   } catch (InvocationTargetException e) {
     log.error(
         "Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause());
     throw new Exception(
         "Error while invoking method: " + udfMethodName + ", " + e.getMessage(), e.getCause());
   }
 }
Example #2
0
  /**
   * @param row
   * @param string
   * @param column
   */
  private void addColumnLink(Vector row, Object userObject, Object column, int id)
      throws Exception {
    LinkCell cell = null;

    String methodName = null;
    if (((ColumnLink) column).getProperty().equals("")) {
      methodName = "toString";
    } else {
      methodName = PagerUtils.buildGetterName(((ColumnLink) column).getProperty());
    }

    try {
      Method method = userObject.getClass().getMethod(methodName, null);
      Object resultInvocation = method.invoke(userObject, null);

      if (resultInvocation != null && !resultInvocation.toString().trim().equals("")) {

        String label = null;

        if (((ColumnLink) column).getLabel() == null
            || ((ColumnLink) column).getLabel().trim().equals("")) {
          label = resultInvocation.toString().trim();
        } else {
          label = ((ColumnLink) column).getLabel();
        }

        cell = new LinkCell(label, ((ColumnLink) column).getLink() + id);
        // + resultInvocation.toString().trim());

        row.add(cell);
      } else {
        row.add(new ValueCell("-", ALIGN_CENTER));
      }

    } catch (SecurityException e) {
      e.printStackTrace();
      getLogger().error("TableTag::addColumnLink()::SecurityException::" + e.getMessage());
      throw new Exception(e.getMessage());
    } catch (NoSuchMethodException e) {
      e.printStackTrace();
      getLogger().error("TableTag::addColumnLink()::NoSuchMethodException::" + e.getMessage());
      throw new Exception(e.getMessage());
    } catch (IllegalArgumentException e) {
      e.printStackTrace();
      getLogger().error("TableTag::addColumnLink()::IllegalArgumentException::" + e.getMessage());
      throw new Exception(e.getMessage());
    } catch (IllegalAccessException e) {
      e.printStackTrace();
      getLogger().error("TableTag::addColumnLink()::IllegalAccessException::" + e.getMessage());
      throw new Exception(e.getMessage());
    } catch (InvocationTargetException e) {
      e.printStackTrace();
      getLogger().error("TableTag::addColumnLink()::InvocationTargetException::" + e.getMessage());
      throw new Exception(e.getMessage());
    }

    // getLogger().debug("TableTag: fine addColumnLink()");
  }
Example #3
0
  protected void perform(InvocationTargetException e, Shell shell, String title, String message) {
    Throwable target = e.getTargetException();

    if (target instanceof CoreException) {
      perform((CoreException) target, shell, title, message);
    } else {
      Plugin.log(e);

      if (e.getMessage() != null && e.getMessage().length() > 0) {
        displayMessageDialog(e, e.getMessage(), shell, title, message);
      } else {
        displayMessageDialog(e, target.getMessage(), shell, title, message);
      }
    }
  }
Example #4
0
  @Override
  public boolean performFinish() {
    final boolean isGit = optionsPage.gitFormat.getSelection();
    final boolean isFile = locationPage.fsRadio.getSelection();
    final String fileName = locationPage.fsPathText.getText();

    try {
      getContainer()
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                public void run(IProgressMonitor monitor) {
                  StringBuilder sb = new StringBuilder();
                  DiffFormatter diffFmt = new DiffFormatter();
                  try {
                    if (isGit) writeGitPatch(sb, diffFmt);
                    else writePatch(sb, diffFmt);

                    if (isFile) {
                      Writer output = new BufferedWriter(new FileWriter(fileName));
                      try {
                        // FileWriter always assumes default encoding is
                        // OK!
                        output.write(sb.toString());
                      } finally {
                        output.close();
                      }
                    } else {
                      copyToClipboard(sb.toString());
                    }
                  } catch (IOException e) {
                    Activator.logError("Patch file could not be written", e); // $NON-NLS-1$
                  }
                }
              });
    } catch (InvocationTargetException e) {
      ((WizardPage) getContainer().getCurrentPage())
          .setErrorMessage(
              e.getMessage() == null ? e.getMessage() : UIText.GitCreatePatchWizard_InternalError);
      Activator.logError("Patch file was not written", e); // $NON-NLS-1$
      return false;
    } catch (InterruptedException e) {
      Activator.logError("Patch file was not written", e); // $NON-NLS-1$
      return false;
    }
    return true;
  }
  /** @see IActionDelegate#run(IAction) */
  protected void doRun() {
    IRunnableWithProgress code =
        new IRunnableWithProgress() {

          public void run(IProgressMonitor monitor)
              throws InvocationTargetException, InterruptedException {
            monitor.beginTask(
                Messages.getString("ChangeLog.PrepareChangeLog"), 1000); // $NON-NLS-1$
            prepareChangeLog(monitor);
            monitor.done();
          }
        };

    ProgressMonitorDialog pd =
        new ProgressMonitorDialog(getWorkbench().getActiveWorkbenchWindow().getShell());

    try {
      pd.run(false /* fork */, false /* cancelable */, code);
    } catch (InvocationTargetException e) {
      ChangelogPlugin.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
      return;
    } catch (InterruptedException e) {
      ChangelogPlugin.getDefault()
          .getLog()
          .log(
              new Status(
                  IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
    }
  }
 private Object readSetting(java.io.Reader input, Object inst) throws IOException {
   try {
     java.lang.reflect.Method m =
         inst.getClass()
             .getDeclaredMethod("readProperties", new Class[] {Properties.class}); // NOI18N
     m.setAccessible(true);
     XMLPropertiesConvertor.Reader r = new XMLPropertiesConvertor.Reader();
     r.parse(input);
     m.setAccessible(true);
     Object ret = m.invoke(inst, new Object[] {r.getProperties()});
     if (ret == null) {
       ret = inst;
     }
     return ret;
   } catch (NoSuchMethodException ex) {
     IOException ioe = new IOException(ex.getMessage());
     ioe.initCause(ex);
     throw ioe;
   } catch (IllegalAccessException ex) {
     IOException ioe = new IOException(ex.getMessage());
     ioe.initCause(ex);
     throw ioe;
   } catch (java.lang.reflect.InvocationTargetException ex) {
     Throwable t = ex.getTargetException();
     IOException ioe = new IOException(ex.getMessage());
     ioe.initCause(t);
     throw ioe;
   }
 }
  private static void applyGroupMatching(TestNG testng, Map options) throws TestSetFailedException {
    String groups = (String) options.get(ProviderParameterNames.TESTNG_GROUPS_PROP);
    String excludedGroups = (String) options.get(ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP);

    if (groups == null && excludedGroups == null) {
      return;
    }

    // the class is available in the testClassPath
    String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector";
    // looks to need a high value
    testng.addMethodSelector(clazzName, 9999);
    try {
      Class clazz = Class.forName(clazzName);

      // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly.
      Method method = clazz.getMethod("setGroups", new Class[] {String.class, String.class});
      method.invoke(null, new Object[] {groups, excludedGroups});
    } catch (ClassNotFoundException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (SecurityException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    }
  }
  /** Send the event notification. */
  public void notify(T event) {
    Object instance = getInstance();

    if (instance == null) return;

    Method method = _method.getJavaMember();

    try {
      method.invoke(instance, getEventArguments(event));
    } catch (IllegalArgumentException e) {
      String loc = (method.getDeclaringClass().getSimpleName() + "." + method.getName() + ": ");

      throw new InjectionException(loc + e.getMessage(), e.getCause());
    } catch (RuntimeException e) {
      throw e;
    } catch (InvocationTargetException e) {
      String loc = (method.getDeclaringClass().getSimpleName() + "." + method.getName() + ": ");

      throw new InjectionException(loc + e.getMessage(), e.getCause());
    } catch (Exception e) {
      String loc = (method.getDeclaringClass().getSimpleName() + "." + method.getName() + ": ");

      throw new InjectionException(loc + e.getMessage(), e.getCause());
    }
  }
  private Document buildDoc(EntityBaseBean bean) throws IcatException {
    Map<Field, Integer> stringFields = ei.getStringFields(bean.getClass());
    StringBuilder sb = new StringBuilder();
    for (Entry<Field, Integer> item : stringFields.entrySet()) {
      Field field = item.getKey();
      Method getter = ei.getGetters(bean.getClass()).get(field);
      try {
        String text = (String) getter.invoke(bean);
        if (text != null) {
          if (sb.length() != 0) {
            sb.append(' ');
          }
          sb.append(text);
        }
      } catch (IllegalArgumentException e) {
        throw new IcatException(IcatExceptionType.INTERNAL, e.getMessage());
      } catch (IllegalAccessException e) {
        throw new IcatException(IcatExceptionType.INTERNAL, e.getMessage());
      } catch (InvocationTargetException e) {
        throw new IcatException(IcatExceptionType.INTERNAL, e.getMessage());
      }
    }

    Document doc = new Document();
    String id = bean.getClass().getSimpleName() + ":" + bean.getId();
    doc.add(new StringField("id", id, Store.YES));
    doc.add(new StringField("entity", bean.getClass().getSimpleName(), Store.NO));
    doc.add(new TextField("all", sb.toString(), Store.NO));
    logger.debug("Created document '" + sb.toString() + "' to index for " + id);
    return doc;
  }
  /**
   * This method does the work of creating an instance of the class given the URL of the wsdl
   * provided in the constructor. This is actually type-safe, so the fact that "abort" if anything
   * goes wrong should never happen.
   */
  protected void init() {
    try {
      URL url = WSDLService.getURLForWSDL(wsdl);
      Constructor<S> constructor = clazzS.getConstructor(URL.class);
      service = constructor.newInstance(url);

    } catch (SecurityException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (Security):" + e.getMessage());
    } catch (NoSuchMethodException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (NoSuchMethod):" + e.getMessage());
    } catch (IllegalArgumentException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (IllegalArgument):" + e.getMessage());
    } catch (IllegalAccessException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (IllegalAccess):" + e.getMessage());
    } catch (InvocationTargetException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (InvocationTarget):" + e.getMessage());
    } catch (InstantiationException e) {
      throw new RuntimeException(
          "You supplied a bad *service*/port pair (Instantiation):" + e.getMessage());
    }
  }
  public static String getValueAsString(Object bean, String property) {
    Object value = null;

    try {
      value = PropertyUtils.getProperty(bean, property);

    } catch (IllegalAccessException e) {
      Log log = LogFactory.getLog(CustomValidatorRules.class);
      log.error(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      Log log = LogFactory.getLog(CustomValidatorRules.class);
      log.error(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      Log log = LogFactory.getLog(CustomValidatorRules.class);
      log.error(e.getMessage(), e);
    }

    if (value == null) {
      return null;
    }

    if (value instanceof String[]) {
      return ((String[]) value).length > 0 ? value.toString() : "";

    } else if (value instanceof Collection) {
      return ((Collection) value).isEmpty() ? "" : value.toString();

    } else {
      return value.toString();
    }
  }
Example #12
0
 /**
  * Gets an instance of a checksum decoder for the specified encoding.
  *
  * @param encoding The encoding name.
  * @param config The configuration object.
  * @param in The input stream.
  * @throws NullPointerException If any parameter is null.
  * @throws IllegalArgumentException If the specified encoding cannot be found, or if any of the
  *     arguments are inappropriate.
  */
 public static ChecksumEncoder getInstance(String encoding, Configuration config, InputStream in) {
   if (encoding == null || config == null || in == null) {
     throw new NullPointerException();
   }
   if (encoding.length() == 0) {
     throw new IllegalArgumentException();
   }
   try {
     Class clazz = Class.forName(System.getProperty(PROPERTY + encoding));
     if (!ChecksumEncoder.class.isAssignableFrom(clazz)) {
       throw new IllegalArgumentException(
           clazz.getName() + ": not a subclass of " + ChecksumEncoder.class.getName());
     }
     Constructor c = clazz.getConstructor(new Class[] {Configuration.class, InputStream.class});
     return (ChecksumEncoder) c.newInstance(new Object[] {config, in});
   } catch (ClassNotFoundException cnfe) {
     throw new IllegalArgumentException("class not found: " + cnfe.getMessage());
   } catch (NoSuchMethodException nsme) {
     throw new IllegalArgumentException("subclass has no constructor");
   } catch (InvocationTargetException ite) {
     throw new IllegalArgumentException(ite.getMessage());
   } catch (InstantiationException ie) {
     throw new IllegalArgumentException(ie.getMessage());
   } catch (IllegalAccessException iae) {
     throw new IllegalArgumentException(iae.getMessage());
   }
 }
    public boolean canExecute(File file) {
      if (isExecutableMethod == null) {
        return true;
      }

      Boolean result = true;
      try {
        result = (Boolean) isExecutableMethod.invoke(file);
      } catch (IllegalArgumentException e) {
        log.warning(
            "Unable to check if "
                + file.getAbsolutePath()
                + " can be executed, will consider it executable."
                + e.getMessage());
      } catch (IllegalAccessException e) {
        log.warning(
            "Unable to check if "
                + file.getAbsolutePath()
                + " can be executed, will consider it executable."
                + e.getMessage());
      } catch (InvocationTargetException e) {
        log.warning(
            "Unable to check if "
                + file.getAbsolutePath()
                + " can be executed, will consider it executable."
                + e.getMessage());
      }

      return result;
    }
Example #14
0
  public void cmdIedeaExportsSelected() {
    DirectoryDialog dlg = new DirectoryDialog(getShell());
    dlg.setText("Select a folder to save the export files in");
    dlg.setMessage("Select a directory");
    final String dir = dlg.open();
    if (dir == null) {
      return;
    }

    final IedeaExporter iedeaExporter = new IedeaExporter();
    try {
      new ProgressMonitorDialog(null)
          .run(
              true,
              true,
              new IRunnableWithProgress() {
                @Override
                public void run(IProgressMonitor monitor)
                    throws InvocationTargetException, InterruptedException {
                  try {
                    iedeaExporter.setMonitor(monitor);
                    iedeaExporter.generate(dir);
                  } catch (TaskException e) {
                    throw new InvocationTargetException(e);
                  }
                }
              });
      MessageDialog.openInformation(null, "Completed", "Tier.net export successful");
    } catch (InvocationTargetException e) {
      MessageUtil.showError(e, "Error running export", e.getMessage());
    } catch (InterruptedException e) {
      MessageDialog.openInformation(null, "Cancelled", e.getMessage());
    }
  }
  /**
   * Creates an instance of an event class using a config which may be new or recycled from an
   * existing event, possibly of another type
   *
   * @param theClass
   * @param theTest
   * @param theInitialConfig
   * @return
   */
  public AbstractEvent createEvent(
      Class<? extends AbstractEvent> theClass, TestImpl theTest, Event theInitialConfig)
      throws ConfigurationException {
    Class<? extends Event> configType = myEventClasses2ConfigTypes.get(theClass);

    try {
      Constructor<? extends AbstractEvent> constructor =
          theClass.getConstructor(TestImpl.class, configType);
      final Event convertConfig = convertConfig(theInitialConfig, configType);
      AbstractEvent event = constructor.newInstance(theTest, convertConfig);

      return event;
    } catch (InstantiationException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (IllegalAccessException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (IllegalArgumentException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (InvocationTargetException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (NoSuchMethodException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (SecurityException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    }
  }
  /**
   * Creates the appropriate editor form for the given event type
   *
   * @throws InstantiationException If the form can't be created for any reason
   */
  public <T extends AbstractEvent, V extends AbstractEventEditorForm> V createEditorForm(
      EventEditorContextController theController, T event) throws ConfigurationException {
    Class<V> formClass = (Class<V>) myEventClasses2EditorForm.get(event.getClass());

    if (formClass == null) {
      throw new ConfigurationException("No editor for " + event.getClass());
    }

    try {
      Constructor<V> constructor = formClass.getConstructor();
      V instance = constructor.newInstance();
      instance.setController(theController);

      return instance;
    } catch (InstantiationException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (IllegalAccessException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (IllegalArgumentException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (InvocationTargetException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (NoSuchMethodException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    } catch (SecurityException ex) {
      throw new ConfigurationException(ex.getMessage(), ex);
    }
  }
  /**
   * Executes the sql sentence created by <code>getSql</code>.
   *
   * @param values the values
   * @return the list< map< string, object>>
   */
  protected List<Map<String, Object>> resolveLookups(Object[] values) {
    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

    try {
      IManagerBean bean = getForeignManagerBean();
      Criteria criteria = getCriteria(bean, values);
      List<ITransferObject> list = bean.getList(criteria);
      if (list.size() > 0) {
        List<String> alias = getAlias();
        for (ITransferObject to : list) {
          result.add(getToMap(to, alias));
        }
      }
    } catch (ManagerBeanException e) {
      LOGGER.severe(e.getMessage());
    } catch (IllegalAccessException e) {
      LOGGER.severe(e.getMessage());
    } catch (InvocationTargetException e) {
      LOGGER.severe(e.getMessage());
    } catch (NoSuchMethodException e) {
      LOGGER.severe(e.getMessage());
    } catch (ExpressionException e) {
      LOGGER.severe(e.getMessage());
    }

    return result;
  }
Example #18
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 private Spell getSpellClass(int id, String name) {
   try {
     Object[] instanceArguments = new Object[] {id};
     Class[] constructorArguments = new Class[] {int.class};
     Class spellClass = Class.forName("com.ignoreourgirth.gary.oakmagic.spells." + name);
     Constructor spellConstructor = spellClass.getConstructor(constructorArguments);
     Object instancedClass = spellConstructor.newInstance(instanceArguments);
     Spell returnValue = (Spell) instancedClass;
     // OakMagic.log.info("Loaded: " + spellClass.getSimpleName());
     return returnValue;
   } catch (ClassNotFoundException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (InstantiationException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (IllegalAccessException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (SecurityException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (NoSuchMethodException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (IllegalArgumentException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (InvocationTargetException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   }
   return null;
 }
  private static String getFilePathByFileDialog(Shell shell, boolean isExport, String fileName) {
    try {
      final Class<EMFStoreFileDialogHelper> clazz =
          loadClass(EMFSTORE_CLIENT_UI_PLUGIN_ID, FILE_DIALOG_HELPER_CLASS);
      final EMFStoreFileDialogHelper fileDialogHelper = clazz.getConstructor().newInstance();

      if (isExport) {
        return fileDialogHelper.getPathForExport(shell, fileName);
      }

      return fileDialogHelper.getPathForImport(shell);
    } catch (final ClassNotFoundException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final InstantiationException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final IllegalAccessException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final IllegalArgumentException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final InvocationTargetException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final NoSuchMethodException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final SecurityException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    }
    return null;
  }
Example #20
0
  private void begin() {
    // copy text from the component with keyboard focus
    Component keyboardComp =
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();

    if (keyboardComp != null && keyboardComp instanceof JTextComponent) {
      JTextComponent textComp = (JTextComponent) keyboardComp;
      textComp.copy();
    } else {
      // if it was not a text component, see if we have the cut
      // method available
      Method copyMethod = null;
      try {
        copyMethod = keyboardComp.getClass().getMethod("copy", new Class[0]);
      } catch (SecurityException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
      } catch (NoSuchMethodException ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
      }

      if (copyMethod != null) {
        try {
          copyMethod.invoke(keyboardComp, new Object[0]);
        } catch (IllegalArgumentException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        } catch (IllegalAccessException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        } catch (InvocationTargetException ex) {
          LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
        }
      }
    }
  }
Example #21
0
 private void showStencilGUI() throws AlgorithmExecutionException {
   try {
     SwingUtilities.invokeAndWait(
         new Runnable() {
           public void run() {
             try {
               LineGraphAlgorithm.this.stencilGUI.show();
             } catch (Exception e) {
               /*
                * Wrap all Exceptions as RuntimeExceptions, and rethrow the inner
                *  exception on the other side.
                */
               throw new RuntimeException(e);
             }
           }
         });
   } catch (InvocationTargetException invocationTargetException) {
     // TODO: This may not be the behavior we want.
     throw new AlgorithmExecutionException(
         invocationTargetException.getMessage(), invocationTargetException);
   } catch (InterruptedException interruptedException) {
     throw new AlgorithmExecutionException(
         interruptedException.getMessage(), interruptedException);
   }
 }
Example #22
0
  public synchronized Object getJavaClassInstance(Class<?> clazz) {
    Object instance = instanceCache.get(clazz);
    if (instance != null) {
      return instance;
    }

    try {
      Constructor<?> constructor = clazz.getConstructor(IValueFactory.class);
      instance = constructor.newInstance(vf);
      instanceCache.put(clazz, instance);
      return instance;
    } catch (IllegalArgumentException e) {
      throw new ImplementationError(e.getMessage(), e);
    } catch (InstantiationException e) {
      throw new ImplementationError(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new ImplementationError(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      throw new ImplementationError(e.getMessage(), e);
    } catch (SecurityException e) {
      throw new ImplementationError(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      throw new ImplementationError(e.getMessage(), e);
    }
  }
  @Override
  public void openCamera(final int cameraId) {
    releaseCamera();

    if (sSharpCameraClass != null) {
      final Method openMethod;
      try {
        openMethod = sSharpCameraClass.getMethod("open", int.class);
      } catch (final NoSuchMethodException e) {
        throw new RuntimeException(e.getMessage(), e);
      }
      try {
        setCamera((Camera) openMethod.invoke(null, cameraId));
      } catch (final IllegalArgumentException e) {
        throw new RuntimeException(e.getMessage(), e);
      } catch (final IllegalAccessException e) {
        throw new RuntimeException(e.getMessage(), e);
      } catch (final InvocationTargetException e) {
        throw new RuntimeException(e.getMessage(), e);
      }
    } else if (cameraId != DEFAULT_CAMERA_ID) {
      throw new RuntimeException();
    } else {
      setCamera(Camera.open());
    }

    setCameraId(cameraId);
    initializeFocusMode();
  }
Example #24
0
 @Override
 public Node.PropertySet[] getPropertySets() {
   final Node.PropertySet[][] props = new Node.PropertySet[1][];
   Runnable runnable =
       new Runnable() {
         @Override
         public void run() {
           FormLAF.executeWithLAFLocks(
               new Runnable() {
                 @Override
                 public void run() {
                   props[0] = component.getProperties();
                 }
               });
         }
       };
   if (EventQueue.isDispatchThread()) {
     runnable.run();
   } else {
     try {
       // We have made some attempts to keep initialization
       // of properties outside AWT thread, but it always
       // deadlocked with AWT thread for various reasons.
       EventQueue.invokeAndWait(runnable);
     } catch (InterruptedException iex) {
       FormUtils.LOGGER.log(Level.INFO, iex.getMessage(), iex);
     } catch (InvocationTargetException itex) {
       FormUtils.LOGGER.log(Level.INFO, itex.getMessage(), itex);
     }
   }
   return props[0];
 }
Example #25
0
 /**
  * Bean转换为Map
  *
  * @param <T>
  * @param pojo
  * @return Map
  */
 public static <T> Map<String, Object> converBean2Map(T pojo) {
   Map<String, Object> rtnMap = new HashMap<String, Object>();
   Class<? extends Object> classType = pojo.getClass();
   // bean方法
   Method[] methods = classType.getDeclaredMethods();
   try {
     // 获取所有get方法
     for (Method method : methods) {
       String methodName = method.getName();
       if (methodName.startsWith(GET)) {
         // 获取属性名
         String filedName = methodName.substring(GET.length());
         StringBuffer sb = new StringBuffer();
         sb.append(filedName.substring(0, 1).toLowerCase()).append(filedName.substring(1));
         // Map数据摄值
         rtnMap.put(sb.toString(), method.invoke(pojo));
       }
     }
   } catch (IllegalArgumentException e) {
     log.error(e.getMessage(), e);
   } catch (IllegalAccessException e) {
     log.error(e.getMessage(), e);
   } catch (InvocationTargetException e) {
     log.error(e.getMessage(), e);
   }
   return rtnMap;
 }
Example #26
0
  protected void runSootDirectly(String mainClass) {

    int length = getSootCommandList().getList().size();
    String temp[] = new String[length];

    getSootCommandList().getList().toArray(temp);

    sendSootOutputEvent(mainClass);
    sendSootOutputEvent(" ");

    final String[] cmdAsArray = temp;

    for (int i = 0; i < temp.length; i++) {

      sendSootOutputEvent(temp[i]);
      sendSootOutputEvent(" ");
    }
    sendSootOutputEvent("\n");

    IRunnableWithProgress op;
    try {
      newProcessStarting();
      op = new SootRunner(temp, Display.getCurrent(), mainClass);
      ((SootRunner) op).setParent(this);
      ModalContext.run(op, true, new NullProgressMonitor(), Display.getCurrent());
    } catch (InvocationTargetException e1) {
      // handle exception
      System.out.println("InvocationTargetException: " + e1.getMessage());
      System.out.println("InvocationTargetException: " + e1.getTargetException());
      System.out.println(e1.getStackTrace());
    } catch (InterruptedException e2) {
      // handle cancelation
      System.out.println("InterruptedException: " + e2.getMessage());
    }
  }
Example #27
0
 private void runBootJobs() {
   // Boot Jobs
   for (final Pair<String, IRunnableWithProgress> p : Activator.BOOT_JOBS) {
     try {
       p.second.run(new NullProgressMonitor());
     } catch (InvocationTargetException e) {
       Log.e(getClass(), e.getMessage(), e);
     } catch (InterruptedException e) {
       Log.e(getClass(), e.getMessage(), e);
     }
     //			Job job = new Job(p.first){
     //
     //				@Override
     //				protected IStatus run(IProgressMonitor monitor) {
     //					try{
     //						p.second.run(monitor);
     //					}
     //					catch(Throwable e){
     //						e.printStackTrace();
     //					}
     //					return Status.OK_STATUS;
     //				}
     //
     //			};
     //			job.setUser(true);
     //			job.schedule();
   }
 }
Example #28
0
 private void assertRGOReference(
     NonRootModelElement rgo, NonRootModelElement rto, boolean defaultReference) {
   Method defaultMethod;
   try {
     defaultMethod = getDefaultReferenceMethod(rgo, rto);
     Object result = defaultMethod.invoke(rgo, new Object[0]);
     if (defaultReference) {
       assertTrue(
           "After a cut the RGO of type "
               + rgo.getClass().getSimpleName()
               + " was not referring to default RTO.",
           ((Boolean) result).booleanValue());
     } else {
       assertFalse(
           "After a paste the RGO of type "
               + rgo.getClass().getSimpleName()
               + " was referring to default RTO.",
           ((Boolean) result).booleanValue());
     }
   } catch (SecurityException e) {
     fail(e.getMessage());
   } catch (NoSuchMethodException e) {
     fail(e.getMessage());
   } catch (IllegalArgumentException e) {
     fail(e.getMessage());
   } catch (IllegalAccessException e) {
     fail(e.getMessage());
   } catch (InvocationTargetException e) {
     fail(e.getMessage());
   }
 }
  private static void applyMethodNameFiltering(TestNG testng, String methodNamePattern)
      throws TestSetFailedException {
    // the class is available in the testClassPath
    String clazzName = "org.apache.maven.surefire.testng.utils.MethodSelector";
    // looks to need a high value
    testng.addMethodSelector(clazzName, 10000);
    try {
      Class clazz = Class.forName(clazzName);

      Method method = clazz.getMethod("setMethodName", new Class[] {String.class});
      method.invoke(null, new Object[] {methodNamePattern});
    } catch (ClassNotFoundException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (SecurityException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    }
  }
  /**
   * Loads a class (do not initialize) from an attribute of {@link ConfigurationElement}
   *
   * @param confElm the configuration element
   * @param name the attribute name
   * @return the Class
   * @throws NoSuchMethodException if an error occurs
   * @throws SecurityException if an error occurs
   * @throws InvocationTargetException if an error occurs
   * @throws IllegalAccessException if an error occurs
   * @throws InstantiationException if an error occurs
   * @throws IllegalArgumentException if an error occurs
   */
  public Object createExecutableExtension(
      ConfigurationElement confElm, String name, Class[] argsClass, Object[] args)
      throws ClassNotFoundException, SecurityException, NoSuchMethodException,
          IllegalArgumentException, InstantiationException, IllegalAccessException,
          InvocationTargetException {
    String symbolicName = confElm.getExtension().getPlugin().getSymbolicName();
    String attribute = confElm.getAttribute(name);
    org.osgi.framework.Bundle osgiBundle = getOsgiBundle(symbolicName);
    Class cls = osgiBundle.loadClass(attribute);
    Constructor constructor = cls.getConstructor(argsClass);

    try {
      return constructor.newInstance(args);
    } catch (InstantiationException e1) {
      NucleusLogger.GENERAL.error(e1.getMessage(), e1);
      throw e1;
    } catch (IllegalAccessException e2) {
      NucleusLogger.GENERAL.error(e2.getMessage(), e2);
      throw e2;
    } catch (IllegalArgumentException e3) {
      NucleusLogger.GENERAL.error(e3.getMessage(), e3);
      throw e3;
    } catch (InvocationTargetException e4) {
      NucleusLogger.GENERAL.error(e4.getMessage(), e4);
      throw e4;
    }
  }