Package org.glassfish.jersey.server.model

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


                return builder.build();
            }

            @Override
            public ResourceModel processSubResource(ResourceModel subResource, Configuration configuration) {
                final Resource resource = Resource.builder().mergeWith(Resource.from(EnhancedSubResourceSingleton.class))
                        .mergeWith(Resource.from(EnhancedSubResource.class)).mergeWith(subResource.getResources().get(0)).build();

                return new ResourceModel.Builder(true).addResource(resource).build();
            }
View Full Code Here


                return resBuilder.build();
            }

            @Override
            public ResourceModel processSubResource(ResourceModel subResource, Configuration configuration) {
                final Resource resource = enhanceResource(subResource.getResources().get(0));
                return new ResourceModel.Builder(true).addResource(resource).build();
            }
View Full Code Here

        });
        rootBuilder.addChildResource(anotherChildBuilder.build());



        Resource resource = rootBuilder.build();
        ResourceConfig resourceConfig = new ResourceConfig().registerResources(resource);

        return new ApplicationHandler(resourceConfig);
    }
View Full Code Here

        private static class SimpleModelProcessor implements ModelProcessor {

            @Override
            public ResourceModel processResourceModel(ResourceModel resourceModel, Configuration configuration) {
                ResourceModel.Builder modelBuilder = new ResourceModel.Builder(false);
                final Resource modelResource = Resource.from(ModelResource.class);
                modelBuilder.addResource(modelResource);

                for (final Resource resource : resourceModel.getRootResources()) {
                    Resource newResource = enhanceResource(resource);
                    modelBuilder.addResource(newResource);
                }

                return modelBuilder.build();
            }
View Full Code Here

     * Test of createResource method, of class IntrospectionModeller.
     */
    @Test
    public void testCreateResource() {
        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",
View Full Code Here

        /* Generate WADL for that class */
        WadlGenerator wg = new WadlGeneratorResourceDocSupport(new WadlGeneratorImpl(), rdt);

        WadlBuilder wb = new WadlBuilder(wg, false, null);
        Resource resource = Resource.from(TestResource.class);
        ApplicationDescription app = wb.generate(Lists.newArrayList(resource));


        /* Confirm that it can be marshalled without error */
        StringWriter sw = new StringWriter();
View Full Code Here

        final MonitoringStatisticsImpl.Builder statBuilder = getProgStats();

        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);
View Full Code Here

    }


    @Test
    public void testGetMethodUniqueId() {
        final Resource resource = Resource.builder(MyResource.class).build();
        Assert.assertEquals("[]|[]|GET|null|get", MonitoringUtils.getMethodUniqueId(getMethod(resource, "get")));
        Assert.assertEquals("[text/html]|[]|GET|sub|subGet", MonitoringUtils.getMethodUniqueId(getMethod(resource, "subGet")));
        Assert.assertEquals("[text/html]|[]|GET|sub|subGet", MonitoringUtils.getMethodUniqueId(getMethod(resource, "subGet")));
        Assert.assertEquals("[text/xml]|[text/plain]|POST|null|post", MonitoringUtils.getMethodUniqueId(getMethod(resource, "post")));
View Full Code Here

        }

        @Path("child")
        @GET
        public String child() {
            final Resource resource = extendedUriInfo.getMatchedModelResource();
            assertEquals("child", resource.getPath());
            final List<RuntimeResource> runtimeResources = extendedUriInfo.getMatchedRuntimeResources();
            assertEquals("root", resource.getParent().getPath());
            assertEquals(2, runtimeResources.size());
            assertEquals("/child;/root", convertToString(runtimeResources));
            assertEquals("/child", runtimeResources.get(0).getRegex());
            assertEquals("/root", runtimeResources.get(1).getRegex());
            return "child";
View Full Code Here

    @Test
    public void testResourceMerge() {
        final List<Resource> rootResources = createRootResources();
        assertEquals(2, rootResources.size());

        final Resource resourceC = ResourceTestUtils.getResource(rootResources, "different-path");
        ResourceTestUtils.containsExactMethods(resourceC, false, "POST");

        final Resource resourceAB = ResourceTestUtils.getResource(rootResources, "a");
        ResourceTestUtils.containsExactMethods(resourceAB, false, "POST", "GET");
    }
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.server.model.Resource$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.