Search in sources :

Example 1 with ResourceClass

use of org.jboss.resteasy.spi.metadata.ResourceClass 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;
}
Also used : ResourceMethod(org.jboss.resteasy.spi.metadata.ResourceMethod) ResourceClass(org.jboss.resteasy.spi.metadata.ResourceClass) ResourceLocator(org.jboss.resteasy.spi.metadata.ResourceLocator)

Example 2 with ResourceClass

use of org.jboss.resteasy.spi.metadata.ResourceClass in project candlepin by candlepin.

the class ResourceLocatorMap method init.

@SuppressWarnings("rawtypes")
public void init() {
    if (hasBeenInitialized) {
        throw new IllegalStateException("This map has already been initialized.");
    }
    List<Binding<?>> rootResourceBindings = new ArrayList<>();
    for (final Binding<?> binding : injector.getBindings().values()) {
        final Type type = binding.getKey().getTypeLiteral().getType();
        if (type instanceof Class) {
            final Class<?> beanClass = (Class) type;
            if (GetRestful.isRootResource(beanClass)) {
                rootResourceBindings.add(binding);
            }
        }
    }
    for (Binding<?> binding : rootResourceBindings) {
        Class<?> clazz = (Class) binding.getKey().getTypeLiteral().getType();
        if (Proxy.isProxyClass(clazz)) {
            for (Class<?> intf : clazz.getInterfaces()) {
                ResourceClass resourceClass = ResourceBuilder.rootResourceFromAnnotations(intf);
                registerLocators(resourceClass);
            }
        } else {
            ResourceClass resourceClass = ResourceBuilder.rootResourceFromAnnotations(clazz);
            registerLocators(resourceClass);
        }
    }
    logLocators();
    lock();
}
Also used : Binding(com.google.inject.Binding) MediaType(javax.ws.rs.core.MediaType) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) ResourceClass(org.jboss.resteasy.spi.metadata.ResourceClass) ResourceClass(org.jboss.resteasy.spi.metadata.ResourceClass)

Aggregations

ResourceClass (org.jboss.resteasy.spi.metadata.ResourceClass)2 Binding (com.google.inject.Binding)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 MediaType (javax.ws.rs.core.MediaType)1 ResourceLocator (org.jboss.resteasy.spi.metadata.ResourceLocator)1 ResourceMethod (org.jboss.resteasy.spi.metadata.ResourceMethod)1