Package org.apache.wink.common.internal.uritemplate

Examples of org.apache.wink.common.internal.uritemplate.UriTemplateProcessor$Variable


    private Resource buildResource(ResourceRecord record) {

        Resource newResource = resourcesObjectFactory.createResource();

        // Add dispatched URIs
        UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
        newResource.setUri(SLASH + uriTemplate.getTemplate());

        // Add Collection/Workspace data
        newResource.setWorkspace(record.getMetadata().getWorkspaceName());
        newResource.setCollection(record.getMetadata().getCollectionTitle());
View Full Code Here


    }

    private ResourceRecord createStaticResourceRecord(Class<? extends Object> cls,
                                                      ObjectFactory<?> of) {
        ClassMetadata metadata = createMetadata(cls);
        UriTemplateProcessor processor = createUriTemplateProcessor(metadata);
        ResourceRecord record = new ResourceRecord(metadata, of, processor);
        writersLock.lock();
        try {
            // double check so as not to put the same resource twice
            if (cacheByClass.get(cls) == null) {
View Full Code Here

    private ResourceRecord createDynamicResourceRecord(DynamicResource instance, ObjectFactory<?> of) {
        Class<? extends Object> cls = instance.getClass();
        ClassMetadata metadata = createMetadata(cls);
        metadata = fixInstanceMetadata(metadata, instance);
        UriTemplateProcessor processor = createUriTemplateProcessor(metadata);
        return new ResourceRecord(metadata, of, processor);
    }
View Full Code Here

                    // Drop through and look for @Path annotation.
                }
            }
        }

        UriTemplateProcessor processor = JaxRsUriTemplateProcessor.newNormalizedInstance(path);
        String pathStr = processor.getTemplate();
        for (String var : processor.getVariableNames()) {
            pathStr = pathStr.replaceAll("\\{(\\s)*" + var + "(\\s)*:.*\\}", "{" + var + "}");
        }
        r.setPath(pathStr);

        List<Object> methodOrSubresource = r.getMethodOrResource();
View Full Code Here

                    // Drop through and look for @Path annotation.
                }
            }
        }

        UriTemplateProcessor processor = JaxRsUriTemplateProcessor.newNormalizedInstance(path);
        String pathStr = processor.getTemplate();
        for (String var : processor.getVariableNames()) {
            pathStr = pathStr.replaceAll("\\{(\\s)*" + var + "(\\s)*:.*\\}", "{" + var + "}");
        }
        r.setPath(pathStr);

        List<Object> methodOrSubresource = r.getMethodOrResource();
View Full Code Here

            }
        };

    final ClassMetadata metadata = ResourceMetadataCollector.collectMetadata(rootResource.getClass());
    //for some reason we need a UriTemplateMatcher with a successful last match
    final UriTemplateProcessor processor = new UriTemplateProcessor() {

      @Override
      public void compile(String arg0) {
        pattern = Pattern.compile(".*");
      }
     
    };
    processor.compile("{.*}");
    final UriTemplateMatcher uriTemplateMatcher = processor.matcher();
    uriTemplateMatcher.match("foo");
    return new ResourceInstance(rootResource,
        new ResourceRecord(metadata, objectFactory, processor), uriTemplateMatcher);
  }
View Full Code Here

                                   List<MethodMetadata> subResourceLocators,
                                   SubResources subResources,
                                   boolean isLocator) {
        for (MethodMetadata subResourceLocator : subResourceLocators) {
            SubResource subResource = resourcesObjectFactory.createSubResource();
            UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
            subResource.setUri(SLASH + uriTemplate.getTemplate() + subResourceLocator.getPath());
            if (isLocator) {
                subResource.setType("Locator"); //$NON-NLS-1$
            } else {
                subResource.setType("Method"); //$NON-NLS-1$
                subResource.setMethod(subResourceLocator.getHttpMethod().toString());
View Full Code Here

        Map<String, Resource> uri2ResourceMap = new HashMap<String, Resource>();

        for (MethodMetadata subResourceLocator : subResourceLocators) {

            UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
            String uri = SLASH + uriTemplate.getTemplate() + subResourceLocator.getPath();
            org.apache.wink.common.internal.model.admin.Methods xmlSRL =
                createXMLSubResourceLocatorMethod(subResourceLocator);
            addResourceMethods(uri2ResourceMap, uri, xmlSRL);
        }

        // Add all Sub Resource Locators as resources
        resources.getResource().addAll(uri2ResourceMap.values());

        uri2ResourceMap.clear();
        for (MethodMetadata subResourceMethod : subResourceMethods) {
            UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
            String uri = SLASH + uriTemplate.getTemplate() + SLASH + subResourceMethod.getPath();
            org.apache.wink.common.internal.model.admin.Methods xmlSRM =
                createXMLSubResourceMethod(subResourceMethod);
            addResourceMethods(uri2ResourceMap, uri, xmlSRM);
        }
View Full Code Here

    private Resource buildResource(ResourceRecord record) {

        Resource newResource = resourcesObjectFactory.createResource();

        // Add dispatched URIs
        UriTemplateProcessor uriTemplate = record.getTemplateProcessor();
        newResource.setUri(SLASH + uriTemplate.getTemplate());

        // Add Collection/Workspace data
        newResource.setWorkspace(record.getMetadata().getWorkspaceName());
        newResource.setCollection(record.getMetadata().getCollectionTitle());
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
    }

    public void testGetVariableNames() {
        UriTemplateProcessor template =
            new BitWorkingUriTemplateProcessor(
                                               "/prefix/{varA}/root/{variableB}/suffix/{Variable345}");
        Set<String> expectedResult = new HashSet<String>();
        expectedResult.add("varA");
        expectedResult.add("variableB");
        expectedResult.add("Variable345");
        assertEquals("variable name", expectedResult, template.getVariableNames());
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.common.internal.uritemplate.UriTemplateProcessor$Variable

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.