Package org.glassfish.jersey.server.model

Examples of org.glassfish.jersey.server.model.ResourceMethod$Data


        return router.apply(requestContext);
    }

    private void addAllConsumesProducesCombinations(final List<ConsumesProducesAcceptor> acceptors,
                                                    final MethodAcceptorPair methodAcceptorPair) {
        final ResourceMethod resourceMethod = methodAcceptorPair.model;

        final Set<MediaType> effectiveInputTypes = new LinkedHashSet<>();
        boolean consumesFromWorkers = fillMediaTypes(effectiveInputTypes, resourceMethod,
                resourceMethod.getConsumedTypes(), true);

        final Set<MediaType> effectiveOutputTypes = new LinkedHashSet<>();
        boolean producesFromWorkers = fillMediaTypes(effectiveOutputTypes, resourceMethod,
                resourceMethod.getProducedTypes(), false);

        final Set<ConsumesProducesAcceptor> acceptorSet = Sets.newHashSet();
        for (MediaType consumes : effectiveInputTypes) {
            for (MediaType produces : effectiveOutputTypes) {
View Full Code Here


        // Return pre-selected MediaType.
        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.
            for (final MessageBodyWriter writer : workers.getMessageBodyWritersForType(responseEntityClass)) {
                for (final MediaType writerProduces : MediaTypes.createFrom(writer.getClass().getAnnotation(Produces.class))) {

                    if (writerProduces.isCompatible(acceptableMediaType)) {
                        // Media types producible by method.
                        final List<MediaType> methodProducesTypes = !resourceMethod.getProducedTypes().isEmpty() ?
                                resourceMethod.getProducedTypes() : Lists.newArrayList(MediaType.WILDCARD_TYPE);

                        for (final MediaType methodProducesType : methodProducesTypes) {
                            if (methodProducesType.isCompatible(writerProduces)) {

                                final CombinedClientServerMediaType.EffectiveMediaType effectiveProduces = new
View Full Code Here

        this.requestExecutionStatisticsBean.updateExecutionStatistics(resourceStatistics.getRequestExecutionStatistics());

        for (Map.Entry<ResourceMethod, ResourceMethodStatistics> entry
                : resourceStatistics.getResourceMethodStatistics().entrySet()) {
            final ResourceMethodStatistics methodStats = entry.getValue();
            final ResourceMethod method = entry.getKey();

            final String methodId = MonitoringUtils.getMethodUniqueId(method);

            ResourceMethodMXBeanImpl methodMXBean = this.resourceMethods.get(methodId);
            if (methodMXBean == null) {
View Full Code Here

    private void prepareAppEvent(String resourceMethodName) throws NoSuchMethodException {
        final Resource.Builder builder = Resource.builder();
        final MockResource mockResource = new MockResource();
        final Method method = mockResource.getClass().getMethod(resourceMethodName);
        final ResourceMethod resourceMethod = builder.addMethod()
                .handlingMethod(method)
                .handledBy(mockResource, method).build();
        final Resource resource = builder.build();
        final ResourceModel model = new ResourceModel.Builder(false).addResource(resource).build();
View Full Code Here

            Collections.sort(consumesProducesAcceptors.get(httpMethod), new Comparator<ConsumesProducesAcceptor>() {

                @Override
                public int compare(final ConsumesProducesAcceptor o1, final ConsumesProducesAcceptor o2) {
                    // Make sure that annotated (@Consumes, @Produces) goes first.
                    final ResourceMethod model1 = o1.methodAcceptorPair.model;
                    final ResourceMethod model2 = o2.methodAcceptorPair.model;

                    // @Consumes on method.
                    int compared = compare(model2.getConsumedTypes(), model1.getConsumedTypes());

                    if (compared == 0) {
                        // @Produces on method.
                        compared = compare(model2.getProducedTypes(), model1.getProducedTypes());

                        if (compared == 0) {
                            // Consumes media type of the acceptor.
                            compared = MediaTypes.MEDIA_TYPE_COMPARATOR.compare(o1.consumes.getMediaType(),
                                    o2.consumes.getMediaType());
View Full Code Here

        return router.apply(requestContext);
    }

    private void addAllConsumesProducesCombinations(final List<ConsumesProducesAcceptor> acceptors,
                                                    final MethodAcceptorPair methodAcceptorPair) {
        final ResourceMethod resourceMethod = methodAcceptorPair.model;

        final Set<MediaType> effectiveInputTypes = new LinkedHashSet<>();
        boolean consumesFromWorkers = fillMediaTypes(effectiveInputTypes, resourceMethod,
                resourceMethod.getConsumedTypes(), true);

        final Set<MediaType> effectiveOutputTypes = new LinkedHashSet<>();
        boolean producesFromWorkers = fillMediaTypes(effectiveOutputTypes, resourceMethod,
                resourceMethod.getProducedTypes(), false);

        final Set<ConsumesProducesAcceptor> acceptorSet = Sets.newHashSet();
        for (MediaType consumes : effectiveInputTypes) {
            for (MediaType produces : effectiveOutputTypes) {
View Full Code Here

        // Return pre-selected MediaType.
        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.
            for (final MessageBodyWriter<?> writer : workers.getMessageBodyWritersForType(responseEntityClass)) {
                for (final MediaType writerProduces : MediaTypes.createFrom(writer.getClass().getAnnotation(Produces.class))) {

                    if (writerProduces.isCompatible(acceptableMediaType)) {
                        // Media types producible by method.
                        final List<MediaType> methodProducesTypes = !resourceMethod.getProducedTypes().isEmpty() ?
                                resourceMethod.getProducedTypes() : Lists.newArrayList(MediaType.WILDCARD_TYPE);

                        for (final MediaType methodProducesType : methodProducesTypes) {
                            if (methodProducesType.isCompatible(writerProduces)) {

                                final CombinedClientServerMediaType.EffectiveMediaType effectiveProduces = new
View Full Code Here

            switch (event.getType()) {
                case RESOURCE_METHOD_START:
                    this.methodTimeStart = now;
                    break;
                case RESOURCE_METHOD_FINISHED:
                    final ResourceMethod method = event.getUriInfo().getMatchedResourceMethod();
                    methodStats = new MethodStats(method, methodTimeStart, now - methodTimeStart);
                    break;
                case EXCEPTION_MAPPING_FINISHED:
                    if (!exceptionMapperEvents.offer(event)) {
                        LOGGER.warning(LocalizationMessages.ERROR_MONITORING_QUEUE_MAPPER());
View Full Code Here

            final MonitoringEventListener.TimeStats requestStats = event.getRequestStats();
            statisticsBuilder.addRequestExecution(requestStats.getStartTime(), requestStats.getDuration());

            final MonitoringEventListener.MethodStats methodStat = event.getMethodStats();
            if (methodStat != null) {
                final ResourceMethod method = methodStat.getMethod();
                statisticsBuilder.addExecution(event.getRequestUri(), method,
                        methodStat.getStartTime(), methodStat.getDuration(),
                        requestStats.getStartTime(), requestStats.getDuration());
            }
        }
View Full Code Here

                    eventData.add("R.MATCHED_SUB_RESOURCE.order", String.valueOf(index++));
                    break;
                case RESOURCE_METHOD_START:
                    eventData.add("R.RESOURCE_METHOD_START.order", String.valueOf(index++));
                    this.appEventListener.resourceMethodEventCount++;
                    final ResourceMethod resourceMethod = event.getUriInfo().getMatchedResourceMethod();
                    eventData.add("R.RESOURCE_METHOD_START.method", resourceMethod
                            .getInvocable().getHandlingMethod().getName());
                    break;
                case RESOURCE_METHOD_FINISHED:
                    eventData.add("R.RESOURCE_METHOD_FINISHED.order", String.valueOf(index++));
                    eventData.add("R.RESOURCE_METHOD_FINISHED", "ok");
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.model.ResourceMethod$Data

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.