Package org.glassfish.jersey.server.mvc

Examples of org.glassfish.jersey.server.mvc.Template


                        final Type genericType,
                        final Annotation[] annotations,
                        final MediaType mediaType,
                        final MultivaluedMap<String, Object> httpHeaders,
                        final OutputStream entityStream) throws IOException, WebApplicationException {
        final Template template = TemplateHelper.getTemplateAnnotation(annotations);

        try {
            final ResolvedViewable resolvedViewable = resolve(viewable, template);
            if (resolvedViewable == null) {
                throw new WebApplicationException(
View Full Code Here


     * @param resourceInstance resource instance for which enhancing methods should be created. May be {@code null}.
     * @param newMethods list to store new methods into.
     */
    private void createEnhancingMethods(final Class<?> resourceClass, final Object resourceInstance,
                                        final List<ModelProcessorUtil.Method> newMethods) {
        final Template template = resourceClass.getAnnotation(Template.class);

        if (template != null) {
            final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(resourceClass);

            final List<MediaType> produces = MediaTypes
                    .createQualitySourceMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
            final List<MediaType> consumes = MediaTypes.createFrom(annotatedResourceClass.getAnnotation(Consumes.class));

            final TemplateInflector inflector = new TemplateInflector(template.name(), template.resolvingClass(),
                    resourceClass, resourceInstance);

            newMethods.add(new ModelProcessorUtil.Method(HttpMethod.GET, consumes, produces, inflector));
            newMethods.add(new ModelProcessorUtil.Method(IMPLICIT_VIEW_PATH_PARAMETER_TEMPLATE, HttpMethod.GET,
                    consumes, produces, inflector));
View Full Code Here

@Priority(Priorities.ENTITY_CODER)
class TemplateMethodInterceptor implements WriterInterceptor {

    @Override
    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
        final Template template = TemplateHelper.getTemplateAnnotation(context.getAnnotations());
        final Object entity = context.getEntity();

        if (template != null && !(entity instanceof Viewable)) {
            context.setType(Viewable.class);
            context.setEntity(new Viewable(template.name(), entity,
                    Object.class.equals(template.resolvingClass()) ? null : template.resolvingClass()));
        }

        context.proceed();
    }
View Full Code Here

     * @param resourceInstance resource instance for which enhancing methods should be created. May be {@code null}.
     * @param newMethods list to store new methods into.
     */
    private void createEnhancingMethods(final Class<?> resourceClass, final Object resourceInstance,
                                        final List<ModelProcessorUtil.Method> newMethods) {
        final Template template = resourceClass.getAnnotation(Template.class);

        if (template != null) {
            final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(resourceClass);

            final List<MediaType> produces = MediaTypes
                    .createQualitySourceMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
            final List<MediaType> consumes = MediaTypes.createFrom(annotatedResourceClass.getAnnotation(Consumes.class));

            final TemplateInflectorImpl inflector = new TemplateInflectorImpl(template.name(),
                    resourceClass, resourceInstance);

            newMethods.add(new ModelProcessorUtil.Method(HttpMethod.GET, consumes, produces, inflector));
            newMethods.add(new ModelProcessorUtil.Method(IMPLICIT_VIEW_PATH_PARAMETER_TEMPLATE, HttpMethod.GET,
                    consumes, produces, inflector));
View Full Code Here

@Priority(Priorities.ENTITY_CODER)
class TemplateMethodInterceptor implements WriterInterceptor {

    @Override
    public void aroundWriteTo(final WriterInterceptorContext context) throws IOException, WebApplicationException {
        final Template template = TemplateHelper.getTemplateAnnotation(context.getAnnotations());
        final Object entity = context.getEntity();

        if (template != null && !(entity instanceof Viewable)) {
            context.setType(Viewable.class);
            context.setEntity(new Viewable(template.name(), entity));
        }

        context.proceed();
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.mvc.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.