Package org.glassfish.jersey.server.model

Examples of org.glassfish.jersey.server.model.Invocable


    private ErrorTemplate getErrorTemplate() {
        final ExtendedUriInfo uriInfo = uriInfoProvider.get();
        final ResourceMethod matchedResourceMethod = uriInfo.getMatchedResourceMethod();

        if (matchedResourceMethod != null) {
            final Invocable invocable = matchedResourceMethod.getInvocable();

            ErrorTemplate errorTemplate = invocable.getHandlingMethod().getAnnotation(ErrorTemplate.class);
            if (errorTemplate == null) {
                Class<?> handlerClass = invocable.getHandler().getHandlerClass();

                if (invocable.isInflector() && TemplateInflector.class.isAssignableFrom(invocable.getHandler().getHandlerClass
                        ())) {

                    handlerClass = ((TemplateInflector) invocable.getHandler().getInstance(null)).getModelClass();
                }

                errorTemplate = handlerClass.getAnnotation(ErrorTemplate.class);
            }
View Full Code Here


            effectiveTypes.addAll(methodTypes);
        }

        boolean mediaTypesFromWorkers = effectiveTypes.isEmpty();
        if (workers != null && mediaTypesFromWorkers) {
            final Invocable invocableMethod = resourceMethod.getInvocable();

            // If not predefined from method - get it from workers.
            if (inputTypes) {
                fillInputTypesFromWorkers(effectiveTypes, invocableMethod);
            } else {
                fillOutputTypesFromWorkers(effectiveTypes, invocableMethod.getRawResponseType());
            }
            mediaTypesFromWorkers = !effectiveTypes.isEmpty();

            // If still empty - get all available.
            if (!mediaTypesFromWorkers) {
View Full Code Here

        if (usePreSelectedMediaType(selectedMethod, acceptableMediaTypes)) {
            return selectedMethod.produces.getCombinedMediaType();
        }

        final ResourceMethod resourceMethod = selectedMethod.methodAcceptorPair.model;
        final Invocable invocable = resourceMethod.getInvocable();

        // Entity class can be null when considering HEAD method || empty entity.
        final Class<?> responseEntityClass = entityClass == null ? invocable.getRawRoutingResponseType() : entityClass;
        final Method handlingMethod = invocable.getHandlingMethod();

        CombinedClientServerMediaType selected = null;

        for (final MediaType acceptableMediaType : acceptableMediaTypes) {
            // Use writers suitable for entity class to determine the media type.
View Full Code Here

        // so it can be written.
        return selectedMethod.produces.getCombinedMediaType();
    }

    private boolean isWriteable(final RequestSpecificConsumesProducesAcceptor candidate) {
        final Invocable invocable = candidate.methodAcceptorPair.model.getInvocable();
        final Class<?> responseType = Primitives.wrap(invocable.getRawRoutingResponseType());

        if (Response.class.isAssignableFrom(responseType)
                || Void.class.isAssignableFrom(responseType)) {
            return true;
        }

        final Type genericType = invocable.getRoutingResponseType();

        final Type genericReturnType = genericType instanceof GenericType ?
                ((GenericType) genericType).getType() : genericType;

        for (final MessageBodyWriter writer : workers.getMessageBodyWritersForType(responseType)) {
            if (writer.isWriteable(responseType, genericReturnType,
                    invocable.getHandlingMethod().getDeclaredAnnotations(),
                    candidate.produces.getCombinedMediaType())) {
                return true;
            }
        }
View Full Code Here

        return false;
    }

    private boolean isReadable(final RequestSpecificConsumesProducesAcceptor candidate) {
        final Invocable invocable = candidate.methodAcceptorPair.model.getInvocable();
        final Method handlingMethod = invocable.getHandlingMethod();
        final Parameter entityParam = getEntityParam(invocable);

        if (entityParam == null) {
            return true;
        } else {
View Full Code Here

            if (uriToContexts.containsKey(path)) {
                return uriToContexts.get(path);
            }

            for (final ResourceMethod method : ServerScopeProvider.getMatchedMethods(uriInfo)) {
                final Invocable invocable = method.getInvocable();

                mergeFilteringScopes(filteringScope,
                        getFilteringScopes(invocable.getHandlingMethod(), invocable.getHandler().getHandlerClass()));

                if (!filteringScope.isEmpty()) {
                    uriToContexts.putIfAbsent(path, filteringScope);
                    return filteringScope;
                }
View Full Code Here

                    return;
                }
               
                if (ResourceMethod.JaxrsType.SUB_RESOURCE_LOCATOR.equals(resourceMethod.getType())) {
                    if (resourceMethod.getInvocable()!=null) {
                        Invocable i = resourceMethod.getInvocable();
                       
                        final Type type = i.getResponseType();
                        final StringBuilder template = getTemplate();
                       
                        mappings.put((Class)type, getMapping(template));

                        // Process sub resources ?
                       
                        try {
                            Resource.Builder builder = Resource
                                    .builder(i.getRawResponseType());
                            if (builder == null) {
                                // for example in the case the return type of the sub resource locator is Object
                                builder = Resource.builder().path(resourceMethod.getParent().getPath());
                            }
                            Resource subResource = builder.build();
View Full Code Here

            effectiveTypes.addAll(methodTypes);
        }

        boolean mediaTypesFromWorkers = effectiveTypes.isEmpty();
        if (workers != null && mediaTypesFromWorkers) {
            final Invocable invocableMethod = resourceMethod.getInvocable();

            // If not predefined from method - get it from workers.
            if (inputTypes) {
                fillInputTypesFromWorkers(effectiveTypes, invocableMethod);
            } else {
                fillOutputTypesFromWorkers(effectiveTypes, invocableMethod.getRawResponseType());
            }
            mediaTypesFromWorkers = !effectiveTypes.isEmpty();

            // If still empty - get all available.
            if (!mediaTypesFromWorkers) {
View Full Code Here

        if (usePreSelectedMediaType(selectedMethod, acceptableMediaTypes)) {
            return selectedMethod.produces.getCombinedMediaType();
        }

        final ResourceMethod resourceMethod = selectedMethod.methodAcceptorPair.model;
        final Invocable invocable = resourceMethod.getInvocable();

        // Entity class can be null when considering HEAD method || empty entity.
        final Class<?> responseEntityClass = entityClass == null ? invocable.getRawRoutingResponseType() : entityClass;
        final Method handlingMethod = invocable.getHandlingMethod();

        CombinedClientServerMediaType selected = null;

        for (final MediaType acceptableMediaType : acceptableMediaTypes) {
            // Use writers suitable for entity class to determine the media type.
View Full Code Here

        // so it can be written.
        return selectedMethod.produces.getCombinedMediaType();
    }

    private boolean isWriteable(final RequestSpecificConsumesProducesAcceptor candidate) {
        final Invocable invocable = candidate.methodAcceptorPair.model.getInvocable();
        final Class<?> responseType = Primitives.wrap(invocable.getRawRoutingResponseType());

        if (Response.class.isAssignableFrom(responseType)
                || Void.class.isAssignableFrom(responseType)) {
            return true;
        }

        final Type genericType = invocable.getRoutingResponseType();

        final Type genericReturnType = genericType instanceof GenericType ?
                ((GenericType) genericType).getType() : genericType;

        for (final MessageBodyWriter<?> writer : workers.getMessageBodyWritersForType(responseType)) {
            if (writer.isWriteable(responseType, genericReturnType,
                    invocable.getHandlingMethod().getDeclaredAnnotations(),
                    candidate.produces.getCombinedMediaType())) {
                return true;
            }
        }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.model.Invocable

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.