private Object getResource(RoutingContext routingCtx) { final Object resource = routingCtx.peekMatchedResource(); try { Method handlingMethod = locatorModel.getInvocable().getHandlingMethod(); return handlingMethod.invoke( resource, ParameterValueHelper.getParameterValues(valueProviders)); } catch (IllegalAccessException ex) { throw new ProcessingException("Resource Java method invocation error.", ex); } catch (InvocationTargetException ex) { final Throwable cause = ex.getCause(); if (cause instanceof ProcessingException) { throw (ProcessingException) cause; } // exception cause potentially mappable throw new MappableException(cause); } catch (UndeclaredThrowableException ex) { throw new ProcessingException("Resource Java method invocation error.", ex); } catch (ProcessingException ex) { throw ex; } catch (Exception ex) { // exception potentially mappable throw new MappableException(ex); } catch (Throwable t) { throw new ProcessingException(t); } }
/** * Create a new sub-resource locator router. * * @param injector HK2 injector. * @param services HK2 services. * @param runtimeModelBuilder Runtime model builder. * @param locatorModel resource locator method model. */ public SubResourceLocatorRouter( final Injector injector, final Services services, final RuntimeModelBuilder runtimeModelBuilder, final ResourceMethod locatorModel) { this.injector = injector; this.runtimeModelBuilder = runtimeModelBuilder; this.locatorModel = locatorModel; this.valueProviders = ParameterValueHelper.createValueProviders(services, locatorModel.getInvocable()); }