Package org.apache.wink.server.internal.registry

Examples of org.apache.wink.server.internal.registry.ResourceRecord


        Object subResource = context.getResponseEntity();
        if (subResource == null) {
            result.setError(new WebApplicationException(Status.NOT_FOUND));
            return;
        }
        ResourceRecord record = registry.getRecord(subResource, false);
        ResourceInstance resourceInstance = new ResourceInstance(subResource, record, matcher);
        // save the resource for UriInfo
        result.getData().getMatchedResources().addFirst(resourceInstance);

        // call recursively to search in the sub-resource
View Full Code Here


            List<ResourceInstance> rootResources = registry.getMatchingRootResources(path);
            // go over all the root matching resources and generate links for
            // them
            for (ResourceInstance rootResource : rootResources) {
                UriBuilder uriBuilder = initUriBuilder(path);
                ResourceRecord record = rootResource.getRecord();
                build(set, uriBuilder, record);
            }
        } else {
            // generate links just for this one resource
            UriBuilder uriBuilder = initUriBuilder();
View Full Code Here

        if (subResource == null) {
            logger.debug("Subresource returned was null so returning a 404 Not Found");
            result.setError(new WebApplicationException(Status.NOT_FOUND));
            return;
        }
        ResourceRecord record = registry.getRecord(subResource, false);
        ResourceInstance resourceInstance = new ResourceInstance(subResource, record, matcher);
        // save the resource for UriInfo
        result.getData().getMatchedResources().addFirst(resourceInstance);

        // call recursively to search in the sub-resource
View Full Code Here

            List<ResourceInstance> rootResources = registry.getMatchingRootResources(path);
            // go over all the root matching resources and generate links for
            // them
            for (ResourceInstance rootResource : rootResources) {
                UriBuilder uriBuilder = initUriBuilder(path);
                ResourceRecord record = rootResource.getRecord();
                build(set, uriBuilder, record);
            }
        } else {
            // generate links just for this one resource
            UriBuilder uriBuilder = initUriBuilder();
View Full Code Here

    private synchronized void fixMediaTypes(DeploymentConfiguration config) {
        if (fixed) {
            return;
        }
        // FIXME: A hacky workaround for https://issues.apache.org/jira/browse/TUSCANY-3572
        ResourceRecord record = config.getResourceRegistry().getRecord(resourceClass);

        for (MethodMetadata methodMetadata : record.getMetadata().getResourceMethods()) {
            String method = methodMetadata.getHttpMethod();
            if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
                methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
                methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
            }
            if (HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
                methodMetadata.addProduces(MediaType.APPLICATION_OCTET_STREAM_TYPE);
                methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
            }
        }
        for (MethodMetadata methodMetadata : record.getMetadata().getSubResourceMethods()) {
            String method = methodMetadata.getHttpMethod();
            if (HttpMethod.GET.equals(method) || HttpMethod.HEAD.equals(method) || HttpMethod.DELETE.equals(method)) {
                methodMetadata.addConsumes(MediaType.APPLICATION_OCTET_STREAM_TYPE);
                methodMetadata.addConsumes(MediaType.WILDCARD_TYPE);
            }
View Full Code Here

        if (subResource == null) {
            logger.trace("Subresource returned was null so returning a 404 Not Found"); //$NON-NLS-1$
            result.setError(new WebApplicationException(Status.NOT_FOUND));
            return;
        }
        ResourceRecord record = registry.getRecord(subResource, false);
        ResourceInstance resourceInstance = new ResourceInstance(subResource, record, matcher);
        // save the resource for UriInfo
        result.getData().getMatchedResources().addFirst(resourceInstance);

        // call recursively to search in the sub-resource
View Full Code Here

            List<ResourceInstance> rootResources = registry.getMatchingRootResources(path);
            // go over all the root matching resources and generate links for
            // them
            for (ResourceInstance rootResource : rootResources) {
                UriBuilder uriBuilder = initUriBuilder(path);
                ResourceRecord record = rootResource.getRecord();
                build(set, uriBuilder, record);
            }
        } else {
            // generate links just for this one resource
            UriBuilder uriBuilder = initUriBuilder();
View Full Code Here

        if (subResource == null) {
            logger.debug("Subresource returned was null so returning a 404 Not Found"); //$NON-NLS-1$
            result.setError(new WebApplicationException(Status.NOT_FOUND));
            return;
        }
        ResourceRecord record = registry.getRecord(subResource, false);
        ResourceInstance resourceInstance = new ResourceInstance(subResource, record, matcher);
        // save the resource for UriInfo
        result.getData().getMatchedResources().addFirst(resourceInstance);

        // call recursively to search in the sub-resource
View Full Code Here

    }

    public void testStaticResource() {
        ResourceRecordFactory factory = new ResourceRecordFactory(new LifecycleManagersRegistry());

        ResourceRecord record = factory.getResourceRecord(Resource1.class);
        assertEquals("/path1", record.getMetadata().getPath());
        record = factory.getResourceRecord(Resource2.class);
        assertEquals("/path2", record.getMetadata().getPath());

        Resource1 r1 = new Resource1();
        ResourceRecord record1 = factory.getResourceRecord(r1);
        assertEquals("/path1", record1.getMetadata().getPath());
        Object o = record1.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource1);
        record = factory.getResourceRecord(Resource1.class);
        assertTrue(record == record1);
        o = record.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource1);

        Resource2 r2 = new Resource2();
        ResourceRecord record2 = factory.getResourceRecord(r2);
        assertEquals("/path2", record2.getMetadata().getPath());
        o = record2.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource2);
        record = factory.getResourceRecord(Resource2.class);
        assertTrue(record == record2);
        o = record.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Resource2);
View Full Code Here

    public void testDynamicResource() {
        ResourceRecordFactory factory = new ResourceRecordFactory(new LifecycleManagersRegistry());
        Dynamic dynamic = new Dynamic();
        dynamic.setPath("/pathDyna");

        ResourceRecord dynamicRecord = factory.getResourceRecord(dynamic);
        assertEquals("/pathDyna", dynamicRecord.getMetadata().getPath());
        Object o = dynamicRecord.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Dynamic);
        assertTrue(o == dynamic);

        Dynamic dynamic2 = new Dynamic();
        dynamic2.setPath("/pathDyna2");
        ResourceRecord dynamicRecord2 = factory.getResourceRecord(dynamic2);
        assertEquals("/pathDyna2", dynamicRecord2.getMetadata().getPath());
        Object o2 = dynamicRecord2.getObjectFactory().getInstance(null);
        assertTrue(o2 instanceof Dynamic);
        assertTrue(dynamicRecord2 != dynamicRecord);

        try {
            factory.getResourceRecord(Dynamic.class);
View Full Code Here

TOP

Related Classes of org.apache.wink.server.internal.registry.ResourceRecord

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.