use of com.peterphi.std.guice.common.logging.logreport.jaxrs.LogReportMessageBodyReader in project stdlib by petergeneric.
the class GuicedResteasy method configure.
/**
* Try to initialise a ServletContainerDispatcher with the connection to the Guice REST services
*/
protected void configure(ServletContainerDispatcher dispatcher) throws ServletException {
// Make sure we are registered with the Guice registry
registry.register(this, true);
// Configure the dispatcher
final Registry resteasyRegistry;
final ResteasyProviderFactory providerFactory;
{
final ResteasyRequestResponseFactory converter = new ResteasyRequestResponseFactory(dispatcher);
dispatcher.init(context, bootstrap, converter, converter);
if (filterConfig != null)
dispatcher.getDispatcher().getDefaultContextObjects().put(FilterConfig.class, filterConfig);
if (servletConfig != null)
dispatcher.getDispatcher().getDefaultContextObjects().put(ServletConfig.class, servletConfig);
resteasyRegistry = dispatcher.getDispatcher().getRegistry();
providerFactory = dispatcher.getDispatcher().getProviderFactory();
}
// Register the REST provider classes
for (Class<?> providerClass : ResteasyProviderRegistry.getClasses()) {
log.debug("Registering REST providers: " + providerClass.getName());
providerFactory.registerProvider(providerClass);
}
// Register the REST provider singletons
for (Object provider : ResteasyProviderRegistry.getSingletons()) {
log.debug("Registering REST provider singleton: " + provider);
providerFactory.registerProviderInstance(provider);
}
providerFactory.registerProviderInstance(new LogReportMessageBodyReader());
// Register the JAXBContext provider
providerFactory.registerProviderInstance(jaxbContextResolver);
// Register the exception mapper
{
// Register the ExceptionMapper for ApplicationException
providerFactory.register(this.exceptionMapper);
log.trace("ExceptionMapper registered for ApplicationException");
}
// Register the REST resources
for (RestResource resource : RestResourceRegistry.getResources()) {
log.debug("Registering REST resource: " + resource.getResourceClass().getName());
resteasyRegistry.addResourceFactory(new ResteasyGuiceResource(injector, resource.getResourceClass()));
}
}
Aggregations