List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException
public InvocationTargetException(Throwable target)
From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java
/** * Invokes the runnable for creating the service images *///from w w w . j a v a2 s . c o m protected void createServiceImages() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try { dialog.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { executeImageCreation(monitor); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InterruptedException e) { log.error("Error creating images", e); ErrorDialog.openError(super.getShell(), "Error creating images", e.getMessage(), new Status(Status.ERROR, Activator.PLUGIN_ID, "Exception creating Images", e)); } catch (InvocationTargetException e) { log.error("Error creating images", e); ErrorDialog.openError(super.getShell(), "Error creating images", e.getMessage(), new Status(Status.ERROR, Activator.PLUGIN_ID, "Exception creating Images", e)); } }
From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java
@Override public void deploy() { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); try {//from w ww. ja v a 2s.co m dialog.run(false, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { executeDeployment(monitor); } catch (Exception e) { throw (new InvocationTargetException(e)); } } }); } catch (InterruptedException e) { String message = e.getMessage(); log.error("Error message: " + message, e); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service: " + message, new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e)); } catch (InvocationTargetException e) { String message = e.getMessage(); log.error("Error message: " + message, e); ErrorDialog.openError(super.getShell(), "Error", "Deploying the service: " + message, new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, e)); } }
From source file:es.bsc.servicess.ide.editors.deployers.LicenseTokensTableComposite.java
/** * Write the service manifest to a file/* w w w .j a v a2s .c o m*/ */ protected void writeManifestToFile() { try { final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); final IFile sm = getProject().getProject().getFolder(ProjectMetadata.OUTPUT_FOLDER) .getFolder(ProjectMetadata.PACKAGES_FOLDER).getFile(ProjectMetadata.SERVICE_MANIFEST); dialog.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException { try { if (sm.exists()) { sm.delete(true, monitor); } if (manifest == null) { generateNewManifest(); } log.debug("writing the manifest in the file "); sm.create(new ByteArrayInputStream(manifest.toString().getBytes()), true, monitor); } catch (Exception e) { log.debug("Exception writing manifest"); throw (new InvocationTargetException(e)); } } }); } catch (InvocationTargetException e) { log.error("Exception writing manifest", e); ErrorDialog.openError(getShell(), "Error writing manifest", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Invocation Exception", e)); } catch (InterruptedException e) { log.error("Exception writing manifest", e); ErrorDialog.openError(getShell(), "Building interrumped", e.getMessage(), new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Interruption Exception", e)); } }
From source file:org.aludratest.maven.surefire.AludraTestSurefireProvider.java
@Override public RunResult invoke(Object forkTestSet) throws TestSetFailedException, ReporterException, InvocationTargetException { if (forkTestSet != null) { throw new IllegalArgumentException( "AludraTest Surefire Provider does not expect forkTestSet parameter"); }//from ww w . j a va2s . c o m RunListener reporter = reporterFactory.createReporter(); // check direct test request first String directTest = testRequest.getRequestedTest(); String directTestMethod = testRequest.getRequestedTestMethod(); if (directTest != null) { directTest = directTest.trim(); while (directTest.endsWith(",")) { directTest = directTest.substring(0, directTest.length() - 1); directTest = directTest.trim(); } Class<?> classToTest = ReflectionUtils.tryLoadClass(testClassLoader, directTest); if (classToTest == null) { throw new IllegalArgumentException("Class " + directTest + " not found in test scope"); } // startup AludraTest Framework Object aludraTest = AludraTestReflectionUtil.startFramework(testClassLoader); try { // create our very own RunnerListener Class<?> runnerListenerClass = testClassLoader.loadClass(RunnerListener.class.getName()); AludraTestReportListener reportListener = new AludraTestReportListener(reporter); Object runnerListenerProxy = Proxy.newProxyInstance(testClassLoader, new Class<?>[] { runnerListenerClass }, reportListener); // register it to RunnerListenerRegistry AludraTestReflectionUtil.registerRunnerListener(runnerListenerProxy, aludraTest, runnerListenerClass); AludraTestReflectionUtil.runAludraTest(aludraTest, classToTest); // extract results from listener return reportListener.createRunResult(); } catch (ClassNotFoundException e) { throw new InvocationTargetException(e); } finally { AludraTestReflectionUtil.stopFramework(aludraTest); } } else if (directTestMethod != null) { // TODO support for method only invocation throw new TestSetFailedException("Running AludraTest test methods currently not supported (" + directTestMethod + " cannot be executed)"); } else { if (testsToRun == null) { // if (forkTestSet instanceof TestsToRun) { // testsToRun = (TestsToRun) forkTestSet; // } // else if (forkTestSet instanceof Class) { // testsToRun = TestsToRun.fromClass((Class<?>) forkTestSet); // } // else { testsToRun = scanClassPath(); // } } throw new TestSetFailedException( "Running multiple AludraTest test classes currently not supported. Please use -Dtest=<testOrSuiteClass>"); } }
From source file:org.apache.axis.providers.java.EJBProvider.java
/** * Override the default implementation such that we can include * special handling for {@link java.rmi.ServerException}. * <p/>//from w w w .j a v a 2 s.c o m * Converts {@link java.rmi.ServerException} exceptions to * {@link InvocationTargetException} exceptions with the same cause. * This allows the axis framework to create a SOAP fault. * </p> * * @see org.apache.axis.providers.java.RPCProvider#invokeMethod(org.apache.axis.MessageContext, java.lang.reflect.Method, java.lang.Object, java.lang.Object[]) */ protected Object invokeMethod(MessageContext msgContext, Method method, Object obj, Object[] argValues) throws Exception { try { return super.invokeMethod(msgContext, method, obj, argValues); } catch (InvocationTargetException ite) { Throwable cause = getCause(ite); if (cause instanceof java.rmi.ServerException) { throw new InvocationTargetException(getCause(cause)); } throw ite; } }
From source file:org.apache.sling.ide.eclipse.ui.internal.ImportRepositoryContentAction.java
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, SerializationException, CoreException { // TODO: We should try to make this give 'nice' progress feedback (aka here's what I'm processing) monitor.beginTask("Repository import", IProgressMonitor.UNKNOWN); this.monitor = monitor; repository = ServerUtil.getConnectedRepository(server, monitor); this.builder = serializationManager.newBuilder(repository, ProjectUtil.getSyncDirectoryFile(project)); SerializationKindManager skm;// w w w . j ava 2 s . c o m try { skm = new SerializationKindManager(); skm.init(repository); } catch (RepositoryException e1) { throw new InvocationTargetException(e1); } filter = ProjectUtil.loadFilter(project); ProgressUtils.advance(monitor, 1); try { contentSyncRootDir = ProjectUtil.getSyncDirectory(project); repositoryImportRoot = projectRelativePath.makeRelativeTo(contentSyncRootDir.getProjectRelativePath()) .makeAbsolute(); contentSyncRoot = ProjectUtil.getSyncDirectoryFullPath(project).toFile(); readVltIgnoresNotUnderImportRoot(contentSyncRootDir, repositoryImportRoot); ProgressUtils.advance(monitor, 1); Activator.getDefault().getPluginLogger().trace( "Starting import; repository start point is {0}, workspace start point is {1}", repositoryImportRoot, projectRelativePath); recordNotIgnoredResources(); ProgressUtils.advance(monitor, 1); crawlChildrenAndImport(repositoryImportRoot.toPortableString()); removeNotIgnoredAndNotUpdatedResources(new NullProgressMonitor()); ProgressUtils.advance(monitor, 1); } catch (OperationCanceledException e) { throw e; } catch (Exception e) { throw new InvocationTargetException(e); } finally { if (builder != null) { builder.destroy(); builder = null; } monitor.done(); } }
From source file:org.apache.sling.ide.eclipse.ui.internal.InstallEditorSection.java
private void initialize() { final ISlingLaunchpadConfiguration config = launchpadServer.getConfiguration(); quickLocalInstallButton.setSelection(config.bundleInstallLocally()); bundleLocalInstallButton.setSelection(!config.bundleInstallLocally()); SelectionListener listener = new SelectionAdapter() { @Override//from ww w. ja v a2 s. c o m public void widgetSelected(SelectionEvent e) { execute(new SetBundleInstallLocallyCommand(server, quickLocalInstallButton.getSelection())); } }; quickLocalInstallButton.addSelectionListener(listener); bundleLocalInstallButton.addSelectionListener(listener); Version serverVersion = launchpadServer .getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME); final EmbeddedArtifact supportBundle = artifactLocator.loadToolingSupportBundle(); final Version embeddedVersion = new Version(supportBundle.getVersion()); updateActionArea(serverVersion, embeddedVersion); installOrUpdateSupportBundleLink.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent e) { ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell()); dialog.setCancelable(true); try { dialog.run(true, false, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { final Version remoteVersion; monitor.beginTask("Installing support bundle", 3); // double-check, just in case monitor.setTaskName("Getting remote bundle version"); Version deployedVersion; final String message; try { RepositoryInfo repositoryInfo = ServerUtil.getRepositoryInfo(server.getOriginal(), monitor); OsgiClient client = osgiClientFactory.createOsgiClient(repositoryInfo); remoteVersion = client .getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME); deployedVersion = remoteVersion; monitor.worked(1); if (remoteVersion != null && remoteVersion.compareTo(embeddedVersion) >= 0) { // version already up-to-date, due to bundle version // changing between startup check and now message = "Bundle is already installed and up to date"; } else { monitor.setTaskName("Installing bundle"); InputStream contents = null; try { contents = supportBundle.openInputStream(); client.installBundle(contents, supportBundle.getName()); } finally { IOUtils.closeQuietly(contents); } deployedVersion = embeddedVersion; message = "Bundle version " + embeddedVersion + " installed"; } monitor.worked(1); monitor.setTaskName("Updating server configuration"); final Version finalDeployedVersion = deployedVersion; Display.getDefault().syncExec(new Runnable() { @Override public void run() { execute(new SetBundleVersionCommand(server, EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME, finalDeployedVersion.toString())); try { server.save(false, new NullProgressMonitor()); } catch (CoreException e) { Activator.getDefault().getLog().log(e.getStatus()); } } }); monitor.worked(1); } catch (OsgiClientException e) { throw new InvocationTargetException(e); } catch (URISyntaxException e) { throw new InvocationTargetException(e); } catch (IOException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } Display.getDefault().asyncExec(new Runnable() { @Override public void run() { MessageDialog.openInformation(getShell(), "Support bundle install operation", message); } }); } }); } catch (InvocationTargetException e1) { IStatus status = new Status(Status.ERROR, Activator.PLUGIN_ID, "Error while installing support bundle: " + e1.getTargetException().getMessage(), e1.getTargetException()); ErrorDialog.openError(getShell(), "Error while installing support bundle", e1.getMessage(), status); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); return; } } }); }
From source file:org.braiden.fpm2.util.PropertyUtils.java
public static void setProperty(Object bean, String property, Object value) throws InvocationTargetException, IllegalAccessException { Validate.notNull(bean);/* w w w .j av a 2 s . c o m*/ Validate.notEmpty(property); Method method = findMethod(bean.getClass(), property, SETTER); if (method == null) { throw new InvocationTargetException(new NoSuchMethodException()); } method.invoke(bean, value); }
From source file:org.braiden.fpm2.util.PropertyUtils.java
public static Object getProperty(Object bean, String property) throws InvocationTargetException, IllegalAccessException { Validate.notNull(bean);// www .j a v a 2s .c o m Validate.notEmpty(property); Method method = findMethod(bean.getClass(), property, GETTER); if (method == null) { throw new InvocationTargetException(new NoSuchMethodException()); } return method.invoke(bean); }
From source file:org.browsermob.proxy.jetty.xml.XmlConfiguration.java
private Object value(Object obj, XmlParser.Node node) throws NoSuchMethodException, ClassNotFoundException, InvocationTargetException, IllegalAccessException { Object value = null;/*from ww w. ja v a 2s.c om*/ // Get the type String type = node.getAttribute("type"); // Try a ref lookup String ref = node.getAttribute("ref"); if (ref != null) { value = _idMap.get(ref); } else { // handle trivial case if (node.size() == 0) { if ("String".equals(type)) return ""; return null; } // Trim values int first = 0; int last = node.size() - 1; // Handle default trim type if (type == null || !"String".equals(type)) { // Skip leading white Object item = null; while (first <= last) { item = node.get(first); if (!(item instanceof String)) break; item = ((String) item).trim(); if (((String) item).length() > 0) break; first++; } // Skip trailing white while (first < last) { item = node.get(last); if (!(item instanceof String)) break; item = ((String) item).trim(); if (((String) item).length() > 0) break; last--; } // All white, so return null if (first > last) return null; } if (first == last) // Single Item value value = itemValue(obj, node.get(first)); else { // Get the multiple items as a single string StringBuffer buf = new StringBuffer(); synchronized (buf) { for (int i = first; i <= last; i++) { Object item = node.get(i); buf.append(itemValue(obj, item)); } value = buf.toString(); } } } // Untyped or unknown if (value == null) { if ("String".equals(type)) return ""; return null; } // Try to type the object if (type == null) { if (value != null && value instanceof String) return ((String) value).trim(); return value; } if ("String".equals(type) || "java.lang.String".equals(type)) return value.toString(); Class pClass = TypeUtil.fromName(type); if (pClass != null) return TypeUtil.valueOf(pClass, value.toString()); if ("URL".equals(type) || "java.net.URL".equals(type)) { if (value instanceof URL) return value; try { return new URL(value.toString()); } catch (MalformedURLException e) { throw new InvocationTargetException(e); } } if ("InetAddress".equals(type) || "java.net.InetAddress".equals(type)) { if (value instanceof InetAddress) return value; try { return InetAddress.getByName(value.toString()); } catch (UnknownHostException e) { throw new InvocationTargetException(e); } } if ("InetAddrPort".equals(type) || "org.browsermob.proxy.jetty.util.InetAddrPort".equals(type)) { if (value instanceof InetAddrPort) return value; try { return new InetAddrPort(value.toString()); } catch (UnknownHostException e) { throw new InvocationTargetException(e); } } throw new IllegalStateException("Unknown type " + type); }