Package com.sun.research.ws.wadl

Examples of com.sun.research.ws.wadl.Resource


        return wadlParam;
    }

    @Override
    public Resource createResource(org.glassfish.jersey.server.model.Resource resource, String path) {
        Resource wadlResource = new Resource();
        if (path != null) {
            wadlResource.setPath(path);
        } else if (resource.getPath() != null) {
            wadlResource.setPath(resource.getPath());
        }

        if (resource.isExtended()) {


            wadlResource.getAny().add(WadlApplicationContextImpl.extendedElement);
        }

        return wadlResource;
    }
View Full Code Here


        attachExternalGrammar(application, description,
                info.getRequestUri());

        for (Resources resources : application.getResources()) {
            final Resource r = resources.getResource().get(0);
            r.setPath(info.getBaseUri().relativize(info.getAbsolutePath()).toString());

            // remove path params since path is fixed at this point
            r.getParam().clear();
        }

        return application;
    }
View Full Code Here

        Application wadlApplication = _wadlGenerator.createApplication();
        Resources wadlResources = _wadlGenerator.createResources();

        // for each resource
        for (org.glassfish.jersey.server.model.Resource r : resources) {
            Resource wadlResource = generateResource(r, r.getPath());
            if (wadlResource == null) {
                continue;
            }
            wadlResources.getResource().add(wadlResource);
        }
View Full Code Here

            ApplicationDescription description,
            org.glassfish.jersey.server.model.Resource resource) {
        try {
            Application wadlApplication = _wadlGenerator.createApplication();
            Resources wadlResources = _wadlGenerator.createResources();
            Resource wadlResource = generateResource(resource, null);
            if (wadlResource == null) {
                return null;
            }
            wadlResources.getResource().add(wadlResource);
            wadlApplication.getResources().add(wadlResources);
View Full Code Here

        try {

            if (!detailedWadl && resource.isExtended()) {
                return null;
            }
            Resource wadlResource = _wadlGenerator.createResource(resource, path);

            // prevent infinite recursion
            if (visitedResources.contains(resource)) {
                return wadlResource;
            } else {
                visitedResources = new HashSet<org.glassfish.jersey.server.model.Resource>(visitedResources);
                visitedResources.add(resource);
            }


            // if the resource contains subresource locator create new resource for this locator and return it instead
            // of this resource
            final ResourceMethod locator = resource.getResourceLocator();
            if (locator != null) {
                try {
                    org.glassfish.jersey.server.model.Resource.Builder builder = org.glassfish.jersey.server.model.Resource
                            .builder(locator.getInvocable().getRawResponseType());
                    if (builder == null) {
                        // for example in the case the return type of the sub resource locator is Object
                        builder = org.glassfish.jersey.server.model.Resource.builder().path(resource.getPath());
                    }
                    org.glassfish.jersey.server.model.Resource subResource = builder.build();

                    Resource wadlSubResource = generateResource(subResource,
                            resource.getPath(), visitedResources);
                    if (wadlSubResource == null) {
                        return null;
                    }
                    if (locator.isExtended()) {
                        wadlSubResource.getAny().add(WadlApplicationContextImpl.extendedElement);
                    }

                    for (Parameter param : locator.getInvocable().getParameters()) {
                        Param wadlParam = generateParam(resource, locator, param);

                        if (wadlParam != null && wadlParam.getStyle() == ParamStyle.TEMPLATE) {
                            wadlSubResource.getParam().add(wadlParam);
                        }
                    }
                    return wadlSubResource;
                } catch (RuntimeException e) {
                    throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_RESOURCE_LOCATOR(locator,
                            resource), e);
                }
            }

            Map<String, Param> wadlResourceParams = new HashMap<String, Param>();
            // for each resource method
            for (org.glassfish.jersey.server.model.ResourceMethod method : resource.getResourceMethods()) {
                if (!detailedWadl && method.isExtended()) {
                    continue;
                }
                com.sun.research.ws.wadl.Method wadlMethod = generateMethod(resource, wadlResourceParams, method);
                wadlResource.getMethodOrResource().add(wadlMethod);

            }
            // add method parameters that are associated with the resource PATH template
            for (Param wadlParam : wadlResourceParams.values()) {
                wadlResource.getParam().add(wadlParam);
            }

            // for each sub-resource method
            Map<String, Resource> wadlSubResources = new HashMap<String, Resource>();
            Map<String, Map<String, Param>> wadlSubResourcesParams =
                    new HashMap<String, Map<String, Param>>();

            for (org.glassfish.jersey.server.model.Resource childResource : resource.getChildResources()) {
                Resource childWadlResource = generateResource(childResource, childResource.getPath(),
                        visitedResources);
                if (childWadlResource == null) {
                    continue;
                }
                wadlResource.getMethodOrResource().add(childWadlResource);
View Full Code Here

        return wadlParam;
    }

    @Override
    public Resource createResource( AbstractResource r, String path ) {
        Resource wadlResource = new Resource();
        if (path != null)
            wadlResource.setPath(path);
        else if (r.isRootResource())
            wadlResource.setPath(r.getPath().getValue());
        return wadlResource;
    }
View Full Code Here

        attachExternalGrammar(application, description,
                info.getRequestUri());

        for (final Resources resources : application.getResources()) {
            final Resource r = resources.getResource().get(0);
            r.setPath(info.getBaseUri().relativize(info.getAbsolutePath()).toString());

            // remove path params since path is fixed at this point
            r.getParam().clear();
        }

        return application;
    }
View Full Code Here

     * @param path path where the resource is exposed.
     * @return the enhanced {@link com.sun.research.ws.wadl.Resource}.
     * @see org.glassfish.jersey.server.wadl.WadlGenerator#createResource(org.glassfish.jersey.server.model.Resource, String)
     */
    public Resource createResource(final org.glassfish.jersey.server.model.Resource r, final String path) {
        final Resource result = delegate.createResource(r, path);
        for (final Class<?> resourceClass : r.getHandlerClasses()) {
            final ClassDocType classDoc = resourceDoc.getClassDoc(resourceClass);
            if (classDoc != null && !isEmpty(classDoc.getCommentText())) {
                final Doc doc = new Doc();
                doc.getContent().add(classDoc.getCommentText());
                result.getDoc().add(doc);
            }
        }
        return result;
    }
View Full Code Here

     * @param path
     * @return
     * @see com.sun.jersey.server.impl.wadl.WadlGenerator#createResource(com.sun.jersey.api.model.AbstractResource, java.lang.String)
     */
    public Resource createResource( AbstractResource r, String path ) {
        final Resource result = _delegate.createResource( r, path );
        final ClassDocType classDoc = _resourceDoc.getClassDoc( r.getResourceClass() );
        if ( classDoc != null && !isEmpty( classDoc.getCommentText() ) ) {
            final Doc doc = new Doc();
            doc.getContent().add( classDoc.getCommentText() );
            result.getDoc().add( doc );
        }
        return result;
    }
View Full Code Here

     * @param path
     * @return the enhanced {@link Resource}
     * @see com.sun.jersey.server.wadl.WadlGenerator#createResource(com.sun.jersey.api.model.AbstractResource, java.lang.String)
     */
    public Resource createResource( AbstractResource r, String path ) {
        final Resource result = _delegate.createResource( r, path );
        final ClassDocType classDoc = _resourceDoc.getClassDoc( r.getResourceClass() );
        if ( classDoc != null && !isEmpty( classDoc.getCommentText() ) ) {
            final Doc doc = new Doc();
            doc.getContent().add( classDoc.getCommentText() );
            result.getDoc().add( doc );
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of com.sun.research.ws.wadl.Resource

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.