Examples of ResourceMethod


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

            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

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

     *
     * @return an error template annotation or {@code null} if the method is not annotated.
     */
    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();

View Full Code Here

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

            }


            // if the resource contains subresource locator create new resource for this locator and return it instead
            // of this resource
            final ResourceMethod locator = resource.getResourceLocator();
            if (locator != null) {
                try {
                    org.glassfish.jersey.server.model.Resource.Builder builder = org.glassfish.jersey.server.model.Resource
                            .builder(locator.getInvocable().getRawResponseType());
                    if (builder == null) {
                        // for example in the case the return type of the sub resource locator is Object
                        builder = org.glassfish.jersey.server.model.Resource.builder().path(resource.getPath());
                    }
                    org.glassfish.jersey.server.model.Resource subResource = builder.build();

                    Resource wadlSubResource = generateResource(subResource,
                            resource.getPath(), visitedResources);
                    if (wadlSubResource == null) {
                        return null;
                    }
                    if (locator.isExtended()) {
                        wadlSubResource.getAny().add(WadlApplicationContextImpl.extendedElement);
                    }

                    for (Parameter param : locator.getInvocable().getParameters()) {
                        Param wadlParam = generateParam(resource, locator, param);

                        if (wadlParam != null && wadlParam.getStyle() == ParamStyle.TEMPLATE) {
                            wadlSubResource.getParam().add(wadlParam);
                        }
View Full Code Here

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

            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

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

        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

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

        // 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

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

        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

Examples of org.jboss.resteasy.core.ResourceMethod

      List<ResourceInvoker> invokers = entry.getValue();
      for (ResourceInvoker invoker : invokers)
      {
        if (invoker instanceof ResourceMethod)
        {
          ResourceMethod resourceMethod = (ResourceMethod)invoker;
          Method method = resourceMethod.getMethod();
          results.add(method);
        } else
        {
          // TODO: fix this?
        }
View Full Code Here

Examples of org.jboss.resteasy.core.ResourceMethod

            Iterator<ResourceMethod> it = node.methods.iterator();
            try
            {
               while (it.hasNext())
               {
                  ResourceMethod invoker = it.next();
                  if (invoker.getMethod().equals(method))
                  {
                     it.remove();
                     return invoker;
                  }

               }
            }
            finally
            {
               if (node.isEmpty())
               {
                  PathParamSegment seg = resourceExpressions.remove(expression);
                  if (seg != null) sortedResourceExpressions.remove(seg);
               }
            }
         }
      }
      else
      {
         SimpleSegment segmentNode = simpleSegments.get(segment);
         if (segmentNode == null)
         {
            return null;
         }
         if (segments.length > index + 1)
         {
            try
            {
               return segmentNode.removePath(segments, index + 1, method);
            }
            finally
            {
               if (segmentNode.isEmpty()) simpleSegments.remove(segment);
            }
         }
         else
         {
            try
            {
               if (isLocator(method))
               {
                  ResourceLocator loc = segmentNode.locator;
                  segmentNode.locator = null;
                  return loc;
               }
               else
               {
                  Iterator<ResourceMethod> it = segmentNode.methods.iterator();
                  while (it.hasNext())
                  {
                     ResourceMethod invoker = it.next();
                     if (invoker.getMethod().equals(method))
                     {
                        it.remove();
                        return invoker;
                     }
View Full Code Here

Examples of org.jboss.resteasy.core.ResourceMethod

         ResourceInvoker removed = null;
         for (ResourceInvoker invoker : list)
         {
            if (invoker instanceof ResourceMethod)
            {
               ResourceMethod rm = (ResourceMethod) invoker;
               if (rm.getMethod().equals(method))
               {
                  removed = rm;
                  break;
               }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.