se.fortnox.reactivewizard.jaxrs.JaxRsResources Maven / Gradle / Ivy
package se.fortnox.reactivewizard.jaxrs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
public class JaxRsResources {
private static final Logger log = LoggerFactory.getLogger(JaxRsResources.class);
private final Object[] services;
private List resources;
private boolean reloadClasses;
private JaxRsResourceFactory jaxRsResourceFactory;
public JaxRsResources(Object[] services, JaxRsResourceFactory jaxRsResourceFactory, Boolean classReloading) {
this.services = services;
this.reloadClasses = classReloading;
this.jaxRsResourceFactory = jaxRsResourceFactory;
this.resources = jaxRsResourceFactory.createResources(services);
StringBuilder sb = new StringBuilder();
for (JaxRsResource r : resources) {
sb.append(System.lineSeparator());
sb.append('\t');
sb.append(r.toString());
}
log.info(sb.toString());
}
/**
* Return the request resource.
* @param request the request
* @return the resource
*/
public JaxRsResource> findResource(JaxRsRequest request) {
if (reloadClasses) {
resources = jaxRsResourceFactory.createResources(services);
}
for (JaxRsResource> r : resources) {
if (r.canHandleRequest(request)) {
return r;
}
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy