Package org.glassfish.jersey.server.model

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


        Class<?> resourceClass = HelloWorldResource.class;
        Resource result = Resource.builder(resourceClass).build();
        final List<ResourceMethod> resourceMethods = result.getResourceMethods();
        assertEquals("Unexpected number of resource methods in the resource model.", 2, resourceMethods.size());

        ResourceMethod resourceMethod;
        resourceMethod = find(resourceMethods, "postA");
        assertEquals("Unexpected number of produced media types in the resource method model",
                3, resourceMethod.getProducedTypes().size());
        assertEquals("Unexpected number of consumed media types in the resource method model",
                2, resourceMethod.getConsumedTypes().size());

        resourceMethod = find(resourceMethods, "postB");
        assertEquals("Unexpected number of inherited produced media types in the resource method model",
                2, resourceMethod.getProducedTypes().size());
        assertEquals("Unexpected number of inherited consumed media types in the resource method model",
                3, resourceMethod.getConsumedTypes().size());
    }
View Full Code Here


        final Resource.Builder resourceBuilder = Resource.builder();
        resourceBuilder.addMethod("GET").handledBy(MyInflector.class);
        resourceBuilder.addMethod("POST").handledBy(MyInflector.class);
        final Resource res = resourceBuilder.build();
        ResourceMethod getMethod;
        ResourceMethod postMethod;
        if (res.getResourceMethods().get(0).getHttpMethod().equals("GET")) {
            getMethod = res.getResourceMethods().get(0);
            postMethod = res.getResourceMethods().get(1);
        } else {
            getMethod = res.getResourceMethods().get(1);
            postMethod = res.getResourceMethods().get(0);
        }

        statBuilder.addExecution("/new/elefant", getMethod, 10, 5, 8, 8);
        statBuilder.addExecution("/new/elefant", getMethod, 20, 12, 18, 10);
        statBuilder.addExecution("/new/elefant", postMethod, 30, 2, 28, 4);

        final MonitoringStatisticsImpl stat = statBuilder.build();
        final Iterator<Map.Entry<String, ResourceStatistics>> it = stat.getUriStatistics().entrySet().iterator();

        check(it, "/hello", 2);
        check(it, "/hello/world", 1);
        check(it, "/new/elefant", 2);
        check(it, "/prog", 1);
        check(it, "/test-resource", 1);
        check(it, "/test-resource/child", 3);
        check(it, "/test-resource/prog-child", 1);

        final Map<ResourceMethod, ResourceMethodStatistics> resourceMethodStatistics
                = stat.getUriStatistics().get("/new/elefant").getResourceMethodStatistics();
        for (ResourceMethodStatistics methodStatistics : resourceMethodStatistics.values()) {
            final ResourceMethod method = methodStatistics.getResourceMethod();
            final ExecutionStatistics st = methodStatistics.getMethodStatistics();
            if (method.getHttpMethod().equals("GET")) {
                Assert.assertEquals(20, st.getLastStartTime().getTime());
            } else if (method.getHttpMethod().equals("POST")) {
                Assert.assertEquals(30, st.getLastStartTime().getTime());
            } else {
                Assert.fail();
            }
        }
View Full Code Here

            if (method.getInvocable().getHandlingMethod().getName().equals(javaName)) {
                return method;
            }
        }
        for (Resource child : resource.getChildResources()) {
            final ResourceMethod childMethod = getMethod(child, javaName);
            if (childMethod != null) {
                return childMethod;
            }
        }
        return null;
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:
                    exceptionMapperEvents.add(event);
                    break;
View Full Code Here

            statisticsBuilder.getRequestStatisticsBuilder().addExecution(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

    }

    private void addAllConsumesProducesCombinations(List<ConsumesProducesAcceptor> list,
                                                    MethodAcceptorPair methodAcceptorPair) {
        final Set<MediaType> effectiveInputTypes = new LinkedHashSet<MediaType>();
        ResourceMethod resourceMethod = methodAcceptorPair.model;

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

        for (MediaType consumes : effectiveInputTypes) {
            for (MediaType produces : effectiveOutputTypes) {
                list.add(new ConsumesProducesAcceptor(new CombinedClientServerMediaType.EffectiveMediaType(consumes,
View Full Code Here

            }


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

                    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

      Configuration configuration = project.getConfiguration();

      if (configuration != null)
      {
        Data data = configuration.getData();

        if (data != null)
        {
          ModuleDependencies moduleDependencies = data.getModuleDependencies();

          if (moduleDependencies != null)
          {
            dependencies = moduleDependencies.getDependency();
          }
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.