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

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


    private void handleSubResourceLocator(SubResourceInstance subResourceInstance,
                                          List<SubResourceInstance> subResources,
                                          MessageContext context,
                                          HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();

        // // dispatch to the sub-resource locator.
        // result.setFound(true);
        // result.setMethod(subResourceInstance);
        // // save the matched template variables for UriInfo
        // matcher.storeVariables(result.getData().getMatchedVariables(),
        // false);
        // // save the matched uri for UriInfo
        // result.getData().addMatchedUri(matcher.getHead(false));
        saveFoundMethod(result, matcher, subResourceInstance, context);

        // continue the chain to invoke the locator
        if (logger.isDebugEnabled()) {
            MethodMetadata metadata =
                (subResourceInstance == null) ? null : subResourceInstance.getMetadata();
            logger.debug("Found subresource locator to invoke: {} ", metadata); //$NON-NLS-1$
        }
        chain.doChain(context);

        // the object returned from the locator is a sub-resource so we must
        // continue the search in it
        Object subResource = context.getResponseEntity();
        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


                                                                           .getLogger(FindRootResourceHandler.class);

    private boolean             isContinuedSearchPolicy;

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);

        // create a path stripped from all matrix parameters to use for matching
        List<PathSegment> segments = context.getUriInfo().getPathSegments(false);
        logger.debug("Getting URI Info path segments: {}", segments); //$NON-NLS-1$
        String strippedPath = buildPathForMatching(segments);
        logger.debug("Getting stripped path from segments: {}", strippedPath); //$NON-NLS-1$
        // get a list of root resources that can handle the request

        // JAX-RS specification requires to search only the first matching
        // resource,
        // but the continued search behavior is to continue searching in all
        // matching resources
        List<ResourceInstance> matchedResources =
            registry.getMatchingRootResources(strippedPath, isContinuedSearchPolicy);
        logger.debug("Found resource instances: {}", matchedResources); //$NON-NLS-1$
        if (matchedResources.size() == 0) {
            logger.debug("No resource found matching {}", context.getUriInfo().getPath(false)); //$NON-NLS-1$
            SearchResult result =
                new SearchResult(new WebApplicationException(Response.Status.NOT_FOUND));
View Full Code Here

        SearchResult searchResult = context.getAttribute(SearchResult.class);
        if (searchResult.isError() && searchResult.getError().getResponse().getStatus() == HttpStatus.METHOD_NOT_ALLOWED
            .getCode()
            && context.getHttpMethod().equalsIgnoreCase(HttpMethodEx.OPTIONS)) {
            // get supported HTTP methods
            ResourceRegistry resourceRegistry = context.getAttribute(ResourceRegistry.class);
            Set<String> httpMethods = resourceRegistry.getOptions(searchResult.getResource());
            logger
                .debug("Invoking OPTIONS request handled by runtime with {} resource and {} HTTP methods", //$NON-NLS-1$
                       searchResult.getResource(),
                       httpMethods);
            if (httpMethods.size() > 0) {
View Full Code Here



  private boolean accepts(HttpServletRequest request) {
    DeploymentConfiguration deploymentConfiguration = winkProvider.getRequestProcessor().getConfiguration();
    ResourceRegistry resourceRegistry = deploymentConfiguration.getResourceRegistry();
    //FIXME: fix this to comply with externalization requirements
    //log.info("Checking acceptance of {}.", request.getRequestURI());
    return resourceRegistry.getMatchingRootResources(request.getRequestURI()).size() > 0;
  }
View Full Code Here

     * @return
     */
    public static Response getOptions(UriInfo info) {
        List<ResourceInstance> matchedResourceInstances =
            ((UriInfoImpl)info).getMatchedResourceInstances();
        ResourceRegistry resourceRegistry =
            RuntimeContextTLS.getRuntimeContext().getAttribute(ResourceRegistry.class);
        Set<String> options = resourceRegistry.getOptions(matchedResourceInstances.get(0));
        String allowHeader = HeaderUtils.buildOptionsHeader(options);
        Response response =
            RuntimeDelegate.getInstance().createResponseBuilder().header(WebDAVHeaders.DAV, "1") //$NON-NLS-1$
                .header(WebDAVHeaders.MS_AUTHOR_VIA, "DAV") //$NON-NLS-1$
                .header(HttpHeadersEx.ALLOW, allowHeader).entity("").build(); //$NON-NLS-1$
View Full Code Here

     * @param msgContext
     * @param head append to this
     * @param baseUri base service uri
     */
    private void addOpenSearchLinks(StringBuilder htmlDocStrBldr, String baseUri) {
        ResourceRegistry registry =
            RuntimeContextTLS.getRuntimeContext().getAttribute(ResourceRegistry.class);

        for (ResourceRecord record : registry.getRecords()) {
            if (providesOpenSearch(record) && !collectionHasTemplateHref(record
                .getTemplateProcessor().getTemplate())) {

                htmlDocStrBldr.append(START_LINK).append(APOSTROPHE).append(OPEN_SEARCH_REL)
                    .append(APOSTROPHE).append(SPACE).append(TYPE).append(APOSTROPHE)
View Full Code Here

        // if the resource is an exact match to the uri, then this is the
        // handling resource,
        // 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
            method = registry.findMethod(resource, context);
        } catch (WebApplicationException e) {
            // couldn't find a method
            result.setError(e);
            return;
        }
View Full Code Here

    private void handleSubResourceMethod(SubResourceInstance subResourceInstance,
                                         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();
        String pattern = subResourceRecord.getTemplateProcessor().getPatternString();
        // dispatch to one of the sub-resource methods.
        SubResourceInstance method = null;
        try {
            // if no method is found then a RequestMatchingException exception
            // is thrown
            method = registry.findSubResourceMethod(pattern, subResources, resource, context);
        } catch (WebApplicationException e) {
            // couldn't find a method
            result.setError(e);
            return;
        }
View Full Code Here

    private void handleSubResourceLocator(SubResourceInstance subResourceInstance,
                                          List<SubResourceInstance> subResources,
                                          MessageContext context,
                                          HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);
        SearchResult result = context.getAttribute(SearchResult.class);
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();

        // // dispatch to the sub-resource locator.
        // result.setFound(true);
        // result.setMethod(subResourceInstance);
        // // save the matched template variables for UriInfo
        // matcher.storeVariables(result.getData().getMatchedVariables(),
        // false);
        // // save the matched uri for UriInfo
        // result.getData().addMatchedUri(matcher.getHead(false));
        saveFoundMethod(result, matcher, subResourceInstance, context);

        // continue the chain to invoke the locator
        if (logger.isTraceEnabled()) {
            MethodMetadata metadata =
                (subResourceInstance == null) ? null : subResourceInstance.getMetadata();
            logger.trace("Found subresource locator to invoke: {} ", metadata); //$NON-NLS-1$
        }
        chain.doChain(context);

        // the object returned from the locator is a sub-resource so we must
        // continue the search in it
        Object subResource = context.getResponseEntity();
        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

                                                                           .getLogger(FindRootResourceHandler.class);

    private boolean             isContinuedSearchPolicy;

    public void handleRequest(MessageContext context, HandlersChain chain) throws Throwable {
        ResourceRegistry registry = context.getAttribute(ResourceRegistry.class);

        // create a path stripped from all matrix parameters to use for matching
        List<PathSegment> segments = context.getUriInfo().getPathSegments(false);
        logger.trace("Getting URI Info path segments: {}", segments); //$NON-NLS-1$
        String strippedPath = buildPathForMatching(segments);
        logger.trace("Getting stripped path from segments: {}", strippedPath); //$NON-NLS-1$
        // get a list of root resources that can handle the request

        // JAX-RS specification requires to search only the first matching
        // resource,
        // but the continued search behavior is to continue searching in all
        // matching resources
        List<ResourceInstance> matchedResources =
            registry.getMatchingRootResources(strippedPath, isContinuedSearchPolicy);
        logger.trace("Found resource instances: {}", matchedResources); //$NON-NLS-1$
        if (matchedResources.size() == 0) {
            if(logger.isTraceEnabled()) {
                logger.trace("No resource found matching {}", context.getUriInfo().getPath(false)); //$NON-NLS-1$
            }
View Full Code Here

TOP

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

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.