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

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


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

        // test for sub-resource
        Dummy dummy = new Dummy();
        ResourceRecord dummyRecord = factory.getResourceRecord(dummy, false);
        Object o = dummyRecord.getObjectFactory().getInstance(null);
        assertTrue(o instanceof Dummy);
        assertTrue(o == dummy);

        Dummy dummy2 = new Dummy();
        ResourceRecord dummyRecord2 = factory.getResourceRecord(dummy2, false);
        Object o2 = dummyRecord2.getObjectFactory().getInstance(null);
        assertTrue(o2 instanceof Dummy);
        assertTrue(dummyRecord2 != dummyRecord);

        try {
            factory.getResourceRecord(new Dummy());
View Full Code Here


    };
    processor.compile("{.*}");
    final UriTemplateMatcher uriTemplateMatcher = processor.matcher();
    uriTemplateMatcher.match("foo");
    return new ResourceInstance(rootResource,
        new ResourceRecord(metadata, objectFactory, processor), uriTemplateMatcher);
  }
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

        if (categories.getHref() != null) {
            // Nothing to do. Href was set explicitly.
            return;
        } else if (categories.getHandlingClass() != null) {
            ResourceRecord record = resourceRegistry.getRecord(categories.getHandlingClass());
            categoriesDocUri = getCategoriesDocBaseUri(categories, record);
        } else if (categories.getHandlingInstance() != null) {
            ResourceRecord record = resourceRegistry.getRecord(categories.getHandlingInstance());
            categoriesDocUri = getCategoriesDocBaseUri(categories, record);
        }

        // Update Categories href with resolved value
        if (categoriesDocUri != null) {
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

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.