List of usage examples for java.lang.reflect InvocationTargetException getMessage
public String getMessage()
From source file:org.kie.server.services.jbpm.ui.JBPMUIKieContainerCommandServiceImpl.java
@Override public ServiceResponsesList executeScript(CommandScript commands, MarshallingFormat marshallingFormat, String classType) {//from w w w . ja v a2 s. c o m List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>(); for (KieServerCommand command : commands.getCommands()) { if (!(command instanceof DescriptorCommand)) { logger.warn("Unsupported command '{}' given, will not process it", command.getClass().getName()); continue; } try { Object result = null; Object handler = null; DescriptorCommand descriptorCommand = (DescriptorCommand) command; // find out the handler to call to process given command if ("FormService".equals(descriptorCommand.getService())) { handler = formServiceBase; } else if ("ImageService".equals(descriptorCommand.getService())) { handler = imageServiceBase; } else if ("FormRendererService".equals(descriptorCommand.getService())) { handler = formRendererBase; } else { throw new IllegalStateException( "Unable to find handler for " + descriptorCommand.getService() + " service"); } List<Object> arguments = new ArrayList(); // process and unwrap arguments for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } logger.debug("After :: Argument with type {} and value {}", arg.getClass(), arg); arguments.add(arg); } logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); // process command via reflection and handler result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); logger.debug("Handler {} returned response {}", handler, result); // return successful result responses.add(new ServiceResponse(ServiceResponse.ResponseType.SUCCESS, "", result)); } catch (InvocationTargetException e) { responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getTargetException().getMessage())); } catch (Throwable e) { logger.error("Error while processing {} command", command, e); // return failure result responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getMessage())); } } logger.debug("About to return responses '{}'", responses); return new ServiceResponsesList(responses); }
From source file:org.kie.server.services.dmn.DMNKieContainerCommandServiceImpl.java
@Override public ServiceResponsesList executeScript(CommandScript commands, MarshallingFormat marshallingFormat, String classType) {/* ww w. j a v a 2s. com*/ List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>(); for (KieServerCommand command : commands.getCommands()) { if (!(command instanceof DescriptorCommand)) { LOG.warn("Unsupported command '{}' given, will not process it", command.getClass().getName()); continue; } try { ServiceResponse<?> result = null; Object handler = null; DescriptorCommand descriptorCommand = (DescriptorCommand) command; // find out the handler to call to process given command if ("DMNService".equals(descriptorCommand.getService())) { handler = modelEvaluatorServiceBase; } else { throw new IllegalStateException( "Unable to find handler for " + descriptorCommand.getService() + " service"); } List<Object> arguments = new ArrayList(); // process and unwrap arguments for (Object arg : descriptorCommand.getArguments()) { LOG.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } LOG.debug("After :: Argument with type {} and value {}", arg.getClass(), arg); arguments.add(arg); } if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload()); } if (descriptorCommand.getMarshallerFormat() != null && !descriptorCommand.getMarshallerFormat().isEmpty()) { arguments.add(descriptorCommand.getMarshallerFormat()); } LOG.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); // process command via reflection and handler result = (ServiceResponse<?>) MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); LOG.debug("Handler {} returned response {}", handler, result); // return successful result responses.add(result); } catch (InvocationTargetException e) { responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getTargetException().getMessage())); } catch (Throwable e) { LOG.error("Error while processing {} command", command, e); // return failure result responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getMessage())); } } LOG.debug("About to return responses '{}'", responses); return new ServiceResponsesList(responses); }
From source file:org.kie.server.services.casemgmt.CaseKieContainerCommandServiceImpl.java
@Override public ServiceResponsesList executeScript(CommandScript commands, MarshallingFormat marshallingFormat, String classType) {//from w ww .j a v a2 s . co m List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>(); for (KieServerCommand command : commands.getCommands()) { if (!(command instanceof DescriptorCommand)) { logger.warn("Unsupported command '{}' given, will not process it", command.getClass().getName()); continue; } try { Object result = null; Object handler = null; DescriptorCommand descriptorCommand = (DescriptorCommand) command; // find out the handler to call to process given command if ("CaseService".equals(descriptorCommand.getService())) { handler = caseManagementServiceBase; } else if ("CaseQueryService".equals(descriptorCommand.getService())) { handler = caseManagementRuntimeDataService; } else if ("CaseAdminService".equals(descriptorCommand.getService())) { handler = caseAdminServiceBase; } else { throw new IllegalStateException( "Unable to find handler for " + descriptorCommand.getService() + " service"); } List<Object> arguments = new ArrayList(); // process and unwrap arguments for (Object arg : descriptorCommand.getArguments()) { logger.debug("Before :: Argument with type {} and value {}", arg.getClass(), arg); if (arg instanceof Wrapped) { arg = ((Wrapped) arg).unwrap(); } logger.debug("After :: Argument with type {} and value {}", arg.getClass(), arg); arguments.add(arg); } if (descriptorCommand.getPayload() != null && !descriptorCommand.getPayload().isEmpty()) { arguments.add(descriptorCommand.getPayload()); } if (descriptorCommand.getMarshallerFormat() != null && !descriptorCommand.getMarshallerFormat().isEmpty()) { arguments.add(descriptorCommand.getMarshallerFormat()); } logger.debug("About to execute {} operation on {} with args {}", descriptorCommand.getMethod(), handler, arguments); // process command via reflection and handler result = MethodUtils.invokeMethod(handler, descriptorCommand.getMethod(), arguments.toArray()); logger.debug("Handler {} returned response {}", handler, result); // return successful result responses.add(new ServiceResponse(ServiceResponse.ResponseType.SUCCESS, "", result)); } catch (InvocationTargetException e) { responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getTargetException().getMessage())); } catch (Throwable e) { logger.error("Error while processing {} command", command, e); // return failure result responses.add(new ServiceResponse(ServiceResponse.ResponseType.FAILURE, e.getMessage())); } } logger.debug("About to return responses '{}'", responses); return new ServiceResponsesList(responses); }
From source file:net.mojodna.sprout.SproutAutoLoaderPlugIn.java
@SuppressWarnings("unchecked") private void loadAction(final Class bean) { final Annotation[] annotations = bean.getAnnotations(); for (int i = 0; i < annotations.length; i++) { final Annotation a = annotations[i]; final Class type = a.annotationType(); if (type.equals(SproutAction.class)) { final SproutAction form = (SproutAction) a; final String path = form.path(); final Class<ActionConfig> mappingClass = form.mappingClass(); final String scope = form.scope(); final String name = form.name(); final boolean validate = form.validate(); final String input = form.input(); final SproutProperty[] properties = form.properties(); final SproutForward[] forwards = form.forwards(); ActionConfig actionConfig = null; try { Constructor<ActionConfig> constructor = mappingClass.getDeclaredConstructor(new Class[] {}); actionConfig = constructor.newInstance(new Object[] {}); } catch (NoSuchMethodException nsme) { log.error("Failed to create a new instance of " + mappingClass.toString() + ", " + nsme.getMessage()); } catch (InstantiationException ie) { log.error("Failed to create a new instance of " + mappingClass.toString() + ", " + ie.getMessage()); } catch (IllegalAccessException iae) { log.error("Failed to create a new instance of " + mappingClass.toString() + ", " + iae.getMessage()); } catch (InvocationTargetException ite) { log.error("Failed to create a new instance of " + mappingClass.toString() + ", " + ite.getMessage()); }/*from ww w .java2s. c o m*/ if (actionConfig != null) { actionConfig.setPath(path); actionConfig.setType(bean.getName()); actionConfig.setScope(scope); actionConfig.setValidate(validate); if (name.length() > 0) { actionConfig.setName(name); } if (input.length() > 0) { actionConfig.setInput(input); } if (properties != null && properties.length > 0) { Map actionConfigBeanMap = new BeanMap(actionConfig); for (int j = 0; j < properties.length; j++) { actionConfigBeanMap.put(properties[j].property(), properties[j].value()); } } if (forwards != null && forwards.length > 0) { for (int j = 0; j < forwards.length; j++) { String fcModule = forwards[j].module(); actionConfig.addForwardConfig(makeForward(forwards[j].name(), forwards[j].path(), forwards[j].redirect(), fcModule.length() == 0 ? null : fcModule)); } } } if (log.isDebugEnabled()) { log.debug("Action " + path + " -> " + bean.getName()); } getModuleConfig().addActionConfig(actionConfig); } } }
From source file:net.wastl.webmail.server.WebMailServer.java
protected void initStorage() throws UnavailableException { /* Storage API */ try {// ww w . ja v a 2 s .c o m Class storage_api = Class.forName(config.getProperty("webmail.storage")); Class[] tmp = new Class[1]; tmp[0] = Class.forName("net.wastl.webmail.server.WebMailServer"); Constructor cons = storage_api.getConstructor(tmp); Object[] sargs = new Object[1]; sargs[0] = this; storage = (Storage) cons.newInstance(sargs); } catch (InvocationTargetException e) { log.fatal("Could not initialize. Exiting now! Nested exc:", e.getTargetException()); throw new UnavailableException(e.getMessage()); } catch (Exception e) { log.fatal("Could not initialize. Exiting now!", e); throw new UnavailableException(e.getMessage()); } }
From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java
@Override protected void okPressed() { if (invalidWidgetValue(cboLayer, cboXField, cboYField)) { openInformation(getShell(), Messages.Task_ParameterRequired); return;//from w w w. ja v a2s .co m } if (inputLayer.getFilter() != Filter.EXCLUDE) { map.select(Filter.EXCLUDE, inputLayer); } try { PlatformUI.getWorkbench().getProgressService().run(false, true, this); } catch (InvocationTargetException e) { MessageDialog.openError(getShell(), Messages.General_Error, e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(getShell(), Messages.General_Cancelled, e.getMessage()); } }
From source file:com.zenesis.qx.remote.ProxyMethod.java
/** * Gets the prefetch value//from w w w . j av a 2 s . c o m * @param self * @return */ public Object getPrefetchValue(Object self) { try { return method.invoke(self); } catch (InvocationTargetException e) { throw new IllegalStateException( "Error while invoking " + method + " on " + self + ": " + e.getCause().getMessage(), e.getCause()); } catch (IllegalAccessException e) { throw new IllegalStateException( "Error while invoking " + method + " on " + self + ": " + e.getMessage(), e); } }
From source file:no.sesat.search.datamodel.BeanDataObjectInvocationHandler.java
protected Object invokeSupport(final Method m, final Object support, final Object[] args) { Object result = null;//from w w w. ja va2 s. c o m try { // if( !support.getClass().isAssignableFrom(m.getDeclaringClass()) ){ // // try to find method again since m is an override and won't be found as is in support // m = support.getClass().getMethod(m.getName(), m.getParameterTypes()); // } result = m.invoke(support, args); } catch (IllegalAccessException iae) { LOG.info(iae.getMessage(), iae); } catch (IllegalArgumentException iae) { LOG.trace(iae.getMessage()); // }catch(NoSuchMethodException nsme){ // LOG.trace(nsme.getMessage()); } catch (InvocationTargetException ite) { LOG.info(ite.getMessage(), ite); } return result; }
From source file:org.locationtech.udig.processingtoolbox.tools.HistogramDialog.java
@Override protected void okPressed() { if (invalidWidgetValue(cboLayer, cboField)) { openInformation(getShell(), Messages.Task_ParameterRequired); return;/*from ww w .jav a 2s . c o m*/ } if (inputLayer.getFilter() != Filter.EXCLUDE) { map.select(Filter.EXCLUDE, inputLayer); } try { PlatformUI.getWorkbench().getProgressService().run(false, true, this); } catch (InvocationTargetException e) { MessageDialog.openError(getShell(), Messages.General_Error, e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(getShell(), Messages.General_Cancelled, e.getMessage()); } }
From source file:no.sesat.search.datamodel.BeanDataObjectInvocationHandler.java
protected Object invokeSelf(final Method method, final Object[] args) { // try invoking one of our own methods. (Works for example on methods declared by the Object class). Object result = null;/*ww w .j ava 2 s .c om*/ // a quick optimisation is to check if there's any method at all with the same name. final Method[] knownMethods = this.getClass().getMethods(); boolean hasSameNameMethod = false; for (Method m : knownMethods) { if (m.getName().equals(method.getName())) { hasSameNameMethod = true; break; } } if (hasSameNameMethod) { try { result = method.invoke(this, args); } catch (IllegalAccessException iae) { LOG.info(iae.getMessage(), iae); } catch (IllegalArgumentException iae) { LOG.debug(iae.getMessage()); } catch (InvocationTargetException ite) { LOG.info(ite.getMessage(), ite); } } return result; }