/** * Determine which operation is being fired for a specific request * * @param theRequestDetails * The request */ public RestOperationTypeEnum getRestOperationType(RequestDetails theRequestDetails) { return getRestOperationType(); }
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider); if (foundMethodBinding == null) { continue; String resourceName = foundMethodBinding.getResourceName(); ResourceBinding resourceBinding; if (resourceName == null) { if (foundMethodBinding.isGlobalMethod()) { resourceBinding = myGlobalBinding; } else { List<Class<?>> allowableParams = foundMethodBinding.getAllowableParamAnnotations(); if (allowableParams != null) { for (Annotation[] nextParamAnnotations : m.getParameterAnnotations()) {
protected final Object invokeServerMethod(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) { // Handle server action interceptors RestOperationTypeEnum operationType = getRestOperationType(theRequest); if (operationType != null) { for (IServerInterceptor next : theServer.getInterceptors()) { ActionRequestDetails details = new ActionRequestDetails(theRequest); populateActionRequestDetailsForInterceptor(theRequest, details, theMethodParams); next.incomingRequestPreHandled(operationType, details); } } // Actually invoke the method try { Method method = getMethod(); return method.invoke(getProvider(), theMethodParams); } catch (InvocationTargetException e) { if (e.getCause() instanceof BaseServerResponseException) { throw (BaseServerResponseException) e.getCause(); } throw new InternalErrorException("Failed to call access method: " + e.getCause(), e); } catch (Exception e) { throw new InternalErrorException("Failed to call access method: " + e.getCause(), e); } }
private void addMethodBinding(String key, BaseMethodBinding<?> binding) { ConcurrentHashMap<String, BaseMethodBinding<?>> mapByOperation = getMapForOperation(binding.getRestOperationType()); if (mapByOperation.containsKey(key)) { throw new IllegalArgumentException("Multiple Search Method Bindings Found : " + mapByOperation.get(key) + " -- " + binding.getMethod()); } mapByOperation.put(key, binding); }
private void removeResourceMethods(Object theProvider, Class<?> clazz, Collection<String> resourceNames) throws ConfigurationException { for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) { BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider); if (foundMethodBinding == null) { continue; // not a bound method } if (foundMethodBinding instanceof ConformanceMethodBinding) { myServerConformanceMethod = null; continue; } String resourceName = foundMethodBinding.getResourceName(); if (!resourceNames.contains(resourceName)) { resourceNames.add(resourceName); } } }
if (nextMethodBinding.getRestOperationType() != null) { String resOpCode = nextMethodBinding.getRestOperationType().getCode(); if (resOpCode != null) { TypeRestfulInteraction resOp; if (nextMethodBinding.isSupportsConditional()) { switch (resOp) { case CREATE: break; case DELETE: if (nextMethodBinding.isSupportsConditionalMultiple()) { resource.setConditionalDelete(ConditionalDeleteStatus.MULTIPLE); } else {
if (nextMethodBinding.getRestOperationType() != null) { String resOpCode = nextMethodBinding.getRestOperationType().getCode(); if (resOpCode != null) { TypeRestfulInteraction resOp; if (nextMethodBinding.isSupportsConditional()) { switch (resOp) { case CREATE:
requestDetails.setRestOperationType(resourceMethod.getRestOperationType()); Closeable outputStreamOrWriter = (Closeable) resourceMethod.invokeServer(this, requestDetails);
BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider); if (foundMethodBinding == null) { continue; ourLog.debug("Scanning public method: {}#{}", theProvider.getClass(), m.getName()); String resourceName = foundMethodBinding.getResourceName(); ResourceBinding resourceBinding; if (resourceName == null) { List<Class<?>> allowableParams = foundMethodBinding.getAllowableParamAnnotations(); if (allowableParams != null) { for (Annotation[] nextParamAnnotations : m.getParameterAnnotations()) {
/** * Execute the method described by the requestBuilder and methodKey * * @param theRequestBuilder the requestBuilder that contains the information about the request * @param methodKey the key determining the method to be executed * @return the response */ private Response execute(final Builder theRequestBuilder, final String methodKey) throws IOException { final JaxRsRequest theRequest = theRequestBuilder.build(); final BaseMethodBinding<?> method = getBinding(theRequest.getRestOperationType(), methodKey); try { return (Response) method.invokeServer(this, theRequest); } catch (final Throwable theException) { return handleException(theRequest, theException); } }
/** * Get the key for the baseMethodBinding. This is: * <ul> * <li>the compartName for SearchMethodBindings * <li>the methodName for OperationMethodBindings * <li> {@link #DEFAULT_METHOD_KEY} for all other MethodBindings * </ul> * @param theBinding the methodbinding * @return the key for the methodbinding. */ private String getBindingKey(final BaseMethodBinding<?> theBinding) { if (theBinding instanceof OperationMethodBinding) { return ((OperationMethodBinding) theBinding).getName(); } else if (theBinding instanceof SearchMethodBinding) { Search search = theBinding.getMethod().getAnnotation(Search.class); return search.compartmentName(); } else { return DEFAULT_METHOD_KEY; } }
/** * The constructor * @param theProvider the provider which is an implementation of the theProviderClass * @param theProviderClass the class definition contaning the operations */ public JaxRsMethodBindings(AbstractJaxRsProvider theProvider, Class<? extends AbstractJaxRsProvider> theProviderClass) { for (final Method m : ReflectionUtil.getDeclaredMethods(theProviderClass)) { final BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, theProvider.getFhirContext(), theProvider); if (foundMethodBinding == null) { continue; } String bindingKey = getBindingKey(foundMethodBinding); addMethodBinding(bindingKey, foundMethodBinding); } }
if (nextMethodBinding.getRestOperationType() != null) { String resOpCode = nextMethodBinding.getRestOperationType().getCode(); if (resOpCode != null) { TypeRestfulInteraction resOp; if (nextMethodBinding.isSupportsConditional()) { switch (resOp) { case CREATE: break; case DELETE: if (nextMethodBinding.isSupportsConditionalMultiple()) { resource.setConditionalDelete(ConditionalDeleteStatus.MULTIPLE); } else {
if (nextMethodBinding.getRestOperationType() != null) { String resOpCode = nextMethodBinding.getRestOperationType().getCode(); if (resOpCode != null) { TypeRestfulInteraction resOp; if (nextMethodBinding.isSupportsConditional()) { switch (resOp) { case CREATE:
requestDetails.setRestOperationType(resourceMethod.getRestOperationType()); Closeable outputStreamOrWriter = (Closeable) resourceMethod.invokeServer(this, requestDetails);
private void removeResourceMethods(Object theProvider, Class<?> clazz, Collection<String> resourceNames) throws ConfigurationException { for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) { BaseMethodBinding<?> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider); if (foundMethodBinding == null) { continue; // not a bound method } if (foundMethodBinding instanceof ConformanceMethodBinding) { myServerConformanceMethod = null; continue; } String resourceName = foundMethodBinding.getResourceName(); if (!resourceNames.contains(resourceName)) { resourceNames.add(resourceName); } } }
/** * Execute the method described by the requestBuilder and methodKey * * @param theRequestBuilder the requestBuilder that contains the information about the request * @param methodKey the key determining the method to be executed * @return the response */ private Response execute(final Builder theRequestBuilder, final String methodKey) throws IOException { final JaxRsRequest theRequest = theRequestBuilder.build(); final BaseMethodBinding<?> method = getBinding(theRequest.getRestOperationType(), methodKey); try { return (Response) method.invokeServer(this, theRequest); } catch (final Throwable theException) { return handleException(theRequest, theException); } }
if (nextMethodBinding.getRestOperationType() != null) { String resOpCode = nextMethodBinding.getRestOperationType().getCode(); if (resOpCode != null) { TypeRestfulInteraction resOp; if (nextMethodBinding.isSupportsConditional()) { switch (resOp) { case CREATE: break; case DELETE: if (nextMethodBinding.isSupportsConditionalMultiple()) { resource.setConditionalDelete(ConditionalDeleteStatus.MULTIPLE); } else {
public BaseMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) { assert theMethod != null; assert theContext != null; myMethod = theMethod; myContext = theContext; myProvider = theProvider; myParameters = MethodUtil.getResourceParameters(theContext, theMethod, theProvider, getRestOperationType()); for (IParameter next : myParameters) { if (next instanceof ConditionalParamBinder) { mySupportsConditional = true; if (((ConditionalParamBinder) next).isSupportsMultiple()) { mySupportsConditionalMultiple = true; } break; } } // This allows us to invoke methods on private classes myMethod.setAccessible(true); }
protected final Object invokeServerMethod(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) { // Handle server action interceptors RestOperationTypeEnum operationType = getRestOperationType(theRequest); if (operationType != null) { for (IServerInterceptor next : theServer.getInterceptors()) { ActionRequestDetails details = new ActionRequestDetails(theRequest); populateActionRequestDetailsForInterceptor(theRequest, details, theMethodParams); next.incomingRequestPreHandled(operationType, details); } } // Actually invoke the method try { Method method = getMethod(); return method.invoke(getProvider(), theMethodParams); } catch (InvocationTargetException e) { if (e.getCause() instanceof BaseServerResponseException) { throw (BaseServerResponseException) e.getCause(); } throw new InternalErrorException("Failed to call access method: " + e.getCause(), e); } catch (Exception e) { throw new InternalErrorException("Failed to call access method: " + e.getCause(), e); } }