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

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


                                         List<SubResourceInstance> subResources,
                                         MessageContext context,
                                         HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();
        SubResourceRecord subResourceRecord = subResourceInstance.getRecord();
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();
        String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
        // dispatch to one of the sub-resource methods.
        SubResourceInstance method = null;
View Full Code Here


            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
        result.setFound(false);
View Full Code Here

    private static final Logger logger = LoggerFactory.getLogger(FindResourceMethodHandler.class);

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {

        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        // resource method
        if (resource.isExactMatch()) {
            logger
                .debug("Root resource @Path matches exactly so finding root resource method in {}", //$NON-NLS-1$
                       resource.getResourceClass().getName());
            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = templateMatcher.getTail(false);
        if (tail == null) {
            tail = ""; //$NON-NLS-1$
        }
        if (tail.startsWith("/")) { //$NON-NLS-1$
            tail = tail.substring(1);
        }
        logger.debug("Unmatched tail to the URI: {}", tail); //$NON-NLS-1$

        // get a sorted list of all the sub-resources (methods and locators)
        List<SubResourceInstance> subResources = resource.getRecord().getMatchingSubResources(tail);
        logger.debug("Possible subresources found: {}", subResources); //$NON-NLS-1$
        if (subResources.size() == 0) {
            result.setError(new WebApplicationException(Response.Status.NOT_FOUND));
            return;
        }
View Full Code Here

        // and we need to find the dispatch method.
        // if no method is found then a RequestMatchingException exception is
        // thrown
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        MethodRecord method = null;
        try {
            // if no method is found then a RequestMatchingException exception
            // is thrown
View Full Code Here

                                         List<SubResourceInstance> subResources,
                                         MessageContext context,
                                         HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();
        SubResourceRecord subResourceRecord = subResourceInstance.getRecord();
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();
        String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
        // dispatch to one of the sub-resource methods.
        SubResourceInstance method = null;
View Full Code Here

            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
        result.setFound(false);
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

    }

    @Override
    public List<ResourceInstance> getMatchingRootResources(String arg0,
        boolean arg1) {
      ResourceInstance threadLocaleInstance = getThreadLocalResourceInstance();
      if (threadLocaleInstance == null) {
        return wrapped.getMatchingRootResources(arg0, arg1);
      } else {
        return Collections.singletonList(threadLocaleInstance);
      }
View Full Code Here

    private static final Logger logger = LoggerFactory.getLogger(FindResourceMethodHandler.class);

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {

        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        // resource method
        if (resource.isExactMatch()) {
            logger
                .trace("Root resource @Path matches exactly so finding root resource method in {}", //$NON-NLS-1$
                       resource.getResourceClass().getName());
            handleResourceMethod(context, chain);
            return;
        }

        // sub-resource method or locator
        UriTemplateMatcher templateMatcher = resource.getMatcher();
        String tail = templateMatcher.getTail(false);
        if (tail == null) {
            tail = ""; //$NON-NLS-1$
        }
        if (tail.startsWith("/")) { //$NON-NLS-1$
            tail = tail.substring(1);
        }
        logger.trace("Unmatched tail to the URI: {}", tail); //$NON-NLS-1$

        // get a sorted list of all the sub-resources (methods and locators)
        List<SubResourceInstance> subResources = resource.getRecord().getMatchingSubResources(tail);
        logger.trace("Possible subresources found: {}", subResources); //$NON-NLS-1$
        if (subResources.size() == 0) {
            result.setError(new WebApplicationException(Response.Status.NOT_FOUND));
            return;
        }
View Full Code Here

        // and we need to find the dispatch method.
        // if no method is found then a RequestMatchingException exception is
        // thrown
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        ResourceInstance resource = result.getResource();

        MethodRecord method = null;
        try {
            // if no method is found then a RequestMatchingException exception
            // is thrown
View Full Code Here

TOP

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

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.