use of org.glassfish.jersey.server.mvc.spi.ViewableContext in project jersey by jersey.
the class ViewableMessageBodyWriter method resolve.
/**
* Resolve the given {@link org.glassfish.jersey.server.mvc.Viewable viewable} using
* {@link org.glassfish.jersey.server.mvc.spi.ViewableContext}.
*
* @param viewable viewable to be resolved.
* @return resolved viewable or {@code null}, if the viewable cannot be resolved.
*/
private ResolvedViewable resolve(final Viewable viewable) {
if (viewable instanceof ResolvedViewable) {
return (ResolvedViewable) viewable;
} else {
final ViewableContext viewableContext = getViewableContext();
final Set<TemplateProcessor> templateProcessors = getTemplateProcessors();
final List<MediaType> producibleMediaTypes = TemplateHelper.getProducibleMediaTypes(requestProvider.get(), extendedUriInfoProvider.get(), null);
final Class<?> resourceClass = resourceInfoProvider.get().getResourceClass();
if (viewable instanceof ImplicitViewable) {
// Template Names.
final ImplicitViewable implicitViewable = (ImplicitViewable) viewable;
for (final String templateName : implicitViewable.getTemplateNames()) {
final Viewable simpleViewable = new Viewable(templateName, viewable.getModel());
final ResolvedViewable resolvedViewable = resolve(simpleViewable, producibleMediaTypes, implicitViewable.getResolvingClass(), viewableContext, templateProcessors);
if (resolvedViewable != null) {
return resolvedViewable;
}
}
} else {
return resolve(viewable, producibleMediaTypes, resourceClass, viewableContext, templateProcessors);
}
return null;
}
}
Aggregations