Search in sources :

Example 1 with Resources

use of com.sun.research.ws.wadl.Resources in project jersey by jersey.

the class WadlBuilder method generate.

/**
     * Generate WADL for a resource.
     *
     * @param resource    the resource
     * @param description the overall application description so we can
     * @return the JAXB WADL application bean
     */
public Application generate(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);
        addVersion(wadlApplication);
        // Attach the data to the parts of the model
        _wadlGenerator.attachTypes(description);
        return wadlApplication;
    } catch (Exception e) {
        throw new ProcessingException(LocalizationMessages.ERROR_WADL_BUILDER_GENERATION_RESOURCE(resource), e);
    }
}
Also used : Resource(com.sun.research.ws.wadl.Resource) Resources(com.sun.research.ws.wadl.Resources) Application(com.sun.research.ws.wadl.Application) ProcessingException(javax.ws.rs.ProcessingException) ProcessingException(javax.ws.rs.ProcessingException)

Example 2 with Resources

use of com.sun.research.ws.wadl.Resources in project jersey by jersey.

the class WadlBuilder method generate.

/**
     * Generate WADL for a set of resources.
     *
     * @param resources the set of resources.
     * @return the JAXB WADL application bean.
     */
public ApplicationDescription generate(List<org.glassfish.jersey.server.model.Resource> resources) {
    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);
    }
    wadlApplication.getResources().add(wadlResources);
    addVersion(wadlApplication);
    addHint(wadlApplication);
    // Build any external grammars
    WadlGenerator.ExternalGrammarDefinition external = _wadlGenerator.createExternalGrammar();
    //
    ApplicationDescription description = new ApplicationDescription(wadlApplication, external);
    // Attach the data to the parts of the model
    _wadlGenerator.attachTypes(description);
    return description;
}
Also used : WadlGenerator(org.glassfish.jersey.server.wadl.WadlGenerator) Resource(com.sun.research.ws.wadl.Resource) Resources(com.sun.research.ws.wadl.Resources) Application(com.sun.research.ws.wadl.Application)

Example 3 with Resources

use of com.sun.research.ws.wadl.Resources in project jersey by jersey.

the class WadlApplicationContextImpl method getApplication.

@Override
public Application getApplication(final UriInfo info, final org.glassfish.jersey.server.model.Resource resource, final boolean detailedWadl) {
    // Get the root application description
    //
    final ApplicationDescription description = getApplication(info, detailedWadl);
    final WadlGenerator wadlGenerator = wadlGeneratorConfig.createWadlGenerator(injectionManager);
    final Application application = new WadlBuilder(wadlGenerator, detailedWadl, info).generate(description, resource);
    if (application == null) {
        return null;
    }
    for (final Resources resources : application.getResources()) {
        resources.setBase(info.getBaseUri().toString());
    }
    // Attach any grammar we may have
    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;
}
Also used : WadlGenerator(org.glassfish.jersey.server.wadl.WadlGenerator) Resource(com.sun.research.ws.wadl.Resource) Resources(com.sun.research.ws.wadl.Resources) Application(com.sun.research.ws.wadl.Application)

Example 4 with Resources

use of com.sun.research.ws.wadl.Resources in project jersey by jersey.

the class WadlApplicationContextImpl method getApplication.

@Override
public ApplicationDescription getApplication(final UriInfo uriInfo, final boolean detailedWadl) {
    final ApplicationDescription applicationDescription = getWadlBuilder(detailedWadl, uriInfo).generate(resourceContext.getResourceModel().getRootResources());
    final Application application = applicationDescription.getApplication();
    for (final Resources resources : application.getResources()) {
        if (resources.getBase() == null) {
            resources.setBase(uriInfo.getBaseUri().toString());
        }
    }
    attachExternalGrammar(application, applicationDescription, uriInfo.getRequestUri());
    return applicationDescription;
}
Also used : Resources(com.sun.research.ws.wadl.Resources) Application(com.sun.research.ws.wadl.Application)

Aggregations

Application (com.sun.research.ws.wadl.Application)4 Resources (com.sun.research.ws.wadl.Resources)4 Resource (com.sun.research.ws.wadl.Resource)3 WadlGenerator (org.glassfish.jersey.server.wadl.WadlGenerator)2 ProcessingException (javax.ws.rs.ProcessingException)1