use of org.jboss.resteasy.spi.metadata.ResourceLocator in project openremote by openremote.
the class MethodMetaData method getResourceLocator.
public static ResourceLocator getResourceLocator(ResourceInvoker invoker) throws Exception {
Field resourceMethodField = null;
resourceMethodField = invoker.getClass().getDeclaredField("method");
resourceMethodField.setAccessible(true);
return (ResourceLocator) resourceMethodField.get(invoker);
}
use of org.jboss.resteasy.spi.metadata.ResourceLocator in project candlepin by candlepin.
the class VerifyAuthorizationFilter method getArguments.
protected Map<Verify, Object> getArguments(HttpRequest request, Method method) {
ResteasyProviderFactory resourceFactory = ResteasyProviderFactory.getInstance();
InjectorFactory injectorFactory = resourceFactory.getInjectorFactory();
ResourceLocator locator = locatorMap.get(method);
if (null == locator) {
throw new IseException("Method " + method.getName() + " not registered as RESTful.");
}
MethodInjector methodInjector = injectorFactory.createMethodInjector(locator, resourceFactory);
HttpResponse response = ResteasyProviderFactory.popContextData(HttpResponse.class);
Object[] args = methodInjector.injectArguments(request, response);
// LinkedHashMap preserves insertion order
Map<Verify, Object> argMap = new LinkedHashMap<>();
Annotation[][] allAnnotations = method.getParameterAnnotations();
// Any occurrence of the Verify annotation means the method is not superadmin exclusive.
for (int i = 0; i < allAnnotations.length; i++) {
for (Annotation a : allAnnotations[i]) {
if (a instanceof Verify) {
Verify v = (Verify) a;
if (!v.nullable() && args[i] == null) {
throw new IllegalStateException("Null passed to a non-nullable Verify annotation.");
} else {
argMap.put(v, args[i]);
}
}
}
}
return argMap;
}
use of org.jboss.resteasy.spi.metadata.ResourceLocator in project wildfly by wildfly.
the class DeploymentRestResourcesDefintion method resLocatorDescription.
private JaxrsResourceLocatorDescription resLocatorDescription(ResourceClass resClass, String contextPath, String mapping, Collection<String> servletMappings, List<Class<?>> resolvedCls) {
JaxrsResourceLocatorDescription locatorRes = new JaxrsResourceLocatorDescription();
locatorRes.resourceClass = resClass.getClazz();
resolvedCls.add(resClass.getClazz());
for (ResourceMethod resMethod : resClass.getResourceMethods()) {
JaxrsResourceMethodDescription jaxrsRes = new JaxrsResourceMethodDescription();
jaxrsRes.consumeTypes = resMethod.getConsumes();
jaxrsRes.contextPath = contextPath;
jaxrsRes.httpMethods = resMethod.getHttpMethods();
jaxrsRes.method = resMethod.getMethod();
jaxrsRes.produceTypes = resMethod.getProduces();
jaxrsRes.resourceClass = resClass.getClazz();
String resPath = new StringBuilder(mapping).append("/").append(resMethod.getFullpath()).toString().replace("//", "/");
jaxrsRes.resourcePath = resPath;
jaxrsRes.servletMappings = servletMappings;
addMethodParameters(jaxrsRes, resMethod.getMethod());
locatorRes.methodsDescriptions.add(jaxrsRes);
}
for (ResourceLocator resLocator : resClass.getResourceLocators()) {
Class<?> clz = resLocator.getReturnType();
if (clz.equals(resClass.getClazz())) {
break;
}
if (resolvedCls.contains(clz)) {
break;
} else {
resolvedCls.add(clz);
}
ResourceClass subResClass = ResourceBuilder.locatorFromAnnotations(clz);
String subMapping = new StringBuilder(mapping).append("/").append(resLocator.getFullpath()).toString().replace("//", "/");
JaxrsResourceLocatorDescription inner = resLocatorDescription(subResClass, contextPath, subMapping, servletMappings, resolvedCls);
if (inner.containsMethodResources()) {
locatorRes.subLocatorDescriptions.add(inner);
}
}
return locatorRes;
}
Aggregations