use of org.jboss.resteasy.spi.ResteasyProviderFactory 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.spi.ResteasyProviderFactory in project syndesis-qe by syndesisio.
the class RestUtils method getClient.
public static Client getClient(ResteasyJackson2Provider jackson2Provider) throws RestClientException {
final ApacheHttpClient4Engine engine = new ApacheHttpClient4Engine(RestUtils.createAllTrustingClient());
final Client client = new ResteasyClientBuilder().providerFactory(// this is needed otherwise default jackson2provider is used, which causes problems with JDK8 Optional
new ResteasyProviderFactory()).register(jackson2Provider).httpEngine(engine).build();
return client;
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory in project adeptj-modules by AdeptJ.
the class JaxRSWhiteboardManager method start.
/**
* Bootstrap the RESTEasy Framework, open ServiceTracker for JAX-RS providers and resources.
*
* @param servletConfig the {@link ServletConfig} provided by OSGi HttpService.
* @param vf the Java Bean Validation's {@link ValidatorFactory}
*/
public void start(ServletConfig servletConfig, ValidatorFactory vf) {
try {
final long startTime = System.nanoTime();
LOGGER.info("Bootstrapping JAX-RS Runtime!!");
this.resteasyDispatcher = new HttpServlet30Dispatcher();
this.resteasyDispatcher.init(servletConfig);
Dispatcher dispatcher = this.resteasyDispatcher.getDispatcher();
ResteasyProviderFactory providerFactory = dispatcher.getProviderFactory();
ResteasyUtil.removeInternalValidators(providerFactory);
ResteasyUtil.registerInternalProviders(providerFactory, this.config, vf);
this.serviceTrackers.add(new JaxRSProviderTracker(this.context, providerFactory));
this.serviceTrackers.add(new JaxRSResourceTracker(this.context, dispatcher.getRegistry()));
LOGGER.info(JAXRS_RT_BOOTSTRAP_MSG, NANOSECONDS.toMillis(System.nanoTime() - startTime));
} catch (Exception ex) {
// NOSONAR
LOGGER.error("Exception while bootstrapping JAX-RS Runtime!!", ex);
throw new JaxRSBootstrapException(ex.getMessage(), ex);
}
}
use of org.jboss.resteasy.spi.ResteasyProviderFactory 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.ResteasyProviderFactory in project narayana by jbosstm.
the class BaseTest method startRestEasy.
protected static void startRestEasy(Class<?>... classes) throws Exception {
server = new TJWSEmbeddedJaxrsServer();
server.setPort(PORT);
server.start();
Registry registry = server.getDeployment().getRegistry();
ResteasyProviderFactory factory = server.getDeployment().getDispatcher().getProviderFactory();
if (classes != null)
for (Class<?> clazz : classes) registry.addPerRequestResource(clazz);
factory.registerProvider(TMUnavailableMapper.class);
factory.registerProvider(TransactionStatusMapper.class);
factory.registerProvider(HttpResponseMapper.class);
factory.registerProvider(NotFoundMapper.class);
}
Aggregations