use of org.jboss.resteasy.core.ResourceMethodRegistry in project openremote by openremote.
the class JSAPIServlet method scanResources.
@SuppressWarnings("unchecked")
public void scanResources() throws Exception {
ServletConfig config = getServletConfig();
ServletContext servletContext = config.getServletContext();
Map<String, ResteasyDeployment> deployments = (Map<String, ResteasyDeployment>) servletContext.getAttribute(ResteasyContextParameters.RESTEASY_DEPLOYMENTS);
if (deployments == null)
return;
synchronized (this) {
services = new HashMap<String, ServiceRegistry>();
for (Map.Entry<String, ResteasyDeployment> entry : deployments.entrySet()) {
ResourceMethodRegistry registry = (ResourceMethodRegistry) entry.getValue().getRegistry();
ResteasyProviderFactory providerFactory = entry.getValue().getProviderFactory();
ServiceRegistry service = new ServiceRegistry(null, registry, providerFactory, null);
services.put(entry.getKey(), service);
}
}
}
use of org.jboss.resteasy.core.ResourceMethodRegistry 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));
}
}
}
}
}
Aggregations