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

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


            ofFactoryRegistry = new LifecycleManagersRegistry();
            ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
        }
        ApplicationValidator applicationValidator = new ApplicationValidator();
        providersRegistry = new ProvidersRegistry(ofFactoryRegistry, applicationValidator);
        resourceRegistry = new ResourceRegistry(ofFactoryRegistry, applicationValidator);
    }
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();
        UriTemplateMatcher matcher = subResourceInstance.getMatcher();
        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.isDebugEnabled()) {
            MethodMetadata metadata =
                (subResourceInstance == null) ? null : subResourceInstance.getMetadata();
            logger.debug("Found subresource locator to invoke: {} ", metadata);
        }
        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");
            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);
        String strippedPath = buildPathForMatching(segments);
        logger.debug("Getting stripped path from segments: {}", strippedPath);
        // 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);
        if (matchedResources.size() == 0) {
            logger.debug("No resource found matching {}", context.getUriInfo().getPath(false));
            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",
                       searchResult.getResource(),
                       httpMethods);
            if (httpMethods.size() > 0) {
View Full Code Here

        RequestProcessor requestProcessor = getRequestProcessor();
        if (requestProcessor == null) {
            throw new ServletException(Messages
                .getMessage("adminServletRequestProcessorInitBeforeAdmin")); //$NON-NLS-1$
        }
        ResourceRegistry registry = requestProcessor.getConfiguration().getResourceRegistry();

        String[] parameterValues = request.getParameterValues(DOCUMENT_TYPE);
        if (parameterValues == null || parameterValues.length == 0) {
            buildAdminHome(response);
            return;
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

            ofFactoryRegistry = new LifecycleManagersRegistry();
            ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager<Object>());
        }
        ApplicationValidator applicationValidator = new ApplicationValidator();
        providersRegistry = new ProvidersRegistry(ofFactoryRegistry, applicationValidator);
        resourceRegistry = new ResourceRegistry(ofFactoryRegistry, applicationValidator);
    }
View Full Code Here

                Messages
                    .getMessage("exceptionOccurredDuringInvocation", t.getClass().getSimpleName(), t.getMessage(), requestMethod, requestString); //$NON-NLS-1$
        }
        if (logger.isDebugEnabled()) {
            logger.debug(messageFormat, t);
            ResourceRegistry rr = this.configuration.getResourceRegistry();
            List<ResourceRecord> resourceRecords = rr.getRecords();
            StringBuffer sb = new StringBuffer();
            String newLine = System.getProperty("line.separator"); //$NON-NLS-1$
            for (ResourceRecord record : resourceRecords) {
                sb.append(newLine + "  " + record.toString()); //$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.