Search in sources :

Example 1 with ResourceMethodInvoker

use of org.jboss.resteasy.core.ResourceMethodInvoker in project openremote by openremote.

the class ServiceRegistry method scanRegistry.

private void scanRegistry() throws Exception {
    methods = new ArrayList<MethodMetaData>();
    locators = new ArrayList<ServiceRegistry>();
    for (Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) {
        List<ResourceInvoker> invokers = entry.getValue();
        for (ResourceInvoker invoker : invokers) {
            if (invoker instanceof ResourceMethodInvoker) {
                methods.add(new MethodMetaData(this, (ResourceMethodInvoker) invoker));
            } else if (invoker instanceof ResourceLocatorInvoker) {
                ResourceLocatorInvoker locator = (ResourceLocatorInvoker) invoker;
                Method method = locator.getMethod();
                Class<?> locatorType = method.getReturnType();
                Class<?>[] locatorResourceTypes = GetRestful.getSubResourceClasses(locatorType);
                for (Class<?> locatorResourceType : locatorResourceTypes) {
                    if (locatorResourceType == null) {
                        // FIXME: we could generate an error for the client, which would be more informative than
                        // just logging this
                        LOG.warning("Error generating JS API: " + method.getDeclaringClass().getName() + ":" + method.getName());
                        // skip this
                        continue;
                    }
                    ResourceMethodRegistry locatorRegistry = new ResourceMethodRegistry(providerFactory);
                    locatorRegistry.addResourceFactory(null, null, locatorResourceType);
                    locators.add(new ServiceRegistry(this, locatorRegistry, providerFactory, locator));
                }
            }
        }
    }
}
Also used : ResourceLocatorInvoker(org.jboss.resteasy.core.ResourceLocatorInvoker) ResourceMethodRegistry(org.jboss.resteasy.core.ResourceMethodRegistry) Method(java.lang.reflect.Method) ResourceInvoker(org.jboss.resteasy.core.ResourceInvoker) ResourceMethodInvoker(org.jboss.resteasy.core.ResourceMethodInvoker) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ResourceInvoker (org.jboss.resteasy.core.ResourceInvoker)1 ResourceLocatorInvoker (org.jboss.resteasy.core.ResourceLocatorInvoker)1 ResourceMethodInvoker (org.jboss.resteasy.core.ResourceMethodInvoker)1 ResourceMethodRegistry (org.jboss.resteasy.core.ResourceMethodRegistry)1