Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jersey.api.wadl.config
Class WadlGeneratorConfig

    java.lang.Object
      com.sun.jersey.api.wadl.config.WadlGeneratorConfig

    public abstract class WadlGeneratorConfig

extends java.lang.Object

Provides a configured `WadlGenerator` with all decorations (the default wadl generator decorated by other generators).

Creating a WadlGeneratorConfig
If you want to create an instance at runtime you have two options:

- Configure the WadlGenerator class and property names/values
- Create your `WadlGenerator` instances by yourself

The first option would look like this:

    WadlGeneratorConfig config = WadlGeneratorConfig
              .generator( MyWadlGenerator.class )
                .prop( "someProperty", "someValue" )
              .generator( MyWadlGenerator2.class )
                .prop( "someProperty", "someValue" )
                .prop( "anotherProperty", "anotherValue" )
              .build();

The second option, creating the `WadlGenerator`s by yourself, would look like the following:

    WadlGeneratorConfig config = WadlGeneratorConfig
                .generator( generator )
                .generator( generator2 )
                .build();

If you want to specify the `WadlGeneratorConfig` in the web.xml you have to subclass it and set the servlet init-param `ResourceConfig.PROPERTY_WADL_GENERATOR_CONFIG` to the name of your subclass. This class might look like this:

    class MyWadlGeneratorConfig extends WadlGeneratorConfig {

            public List configure() {
                return generator( MyWadlGenerator.class )
                    .prop( "foo", propValue )
                  .generator( MyWadlGenerator2.class )
                    .prop( "bar", propValue2 )
                  .descriptions();
            }

        }

Configuring the WadlGenerator
The `WadlGenerator` properties will be populated with the provided properties like this:

- The types match exactly:
  if the WadlGenerator property is of type `org.example.Foo` and the provided property value is of type `org.example.Foo`
- Types that provide a constructor for the provided type (mostly java.lang.String)
- java.io.InputStream: The `InputStream` can e.g. represent a file. The stream is loaded from the property value (provided by the `WadlGeneratorDescription`) via `ClassLoader.getResourceAsStream(String)`. It will be closed after `WadlGenerator.init()` was called.
- Deprected, will be removed in future versions:
  The WadlGenerator property is of type `File` and the provided property value is a `String`:
  the provided property value can contain the prefix classpath: to denote, that the path to the file is relative to the classpath. In this case, the property value is stripped by the prefix classpath: and the `File` is created via

      new File( generator.getClass().getResource( strippedFilename ).toURI() )

  Notice that the filename is loaded from the classpath in this case, e.g. classpath:test.xml refers to a file in the package of the class (`WadlGeneratorDescription.getGeneratorClass()`). The file reference classpath:/test.xml refers to a file that is in the root of the classpath.

Existing `WadlGenerator` implementations:

- `WadlGeneratorApplicationDoc`
- `WadlGeneratorGrammarsSupport`
- `WadlGeneratorResourceDocSupport`

A common example for a `WadlGeneratorConfig` would be this:

    class MyWadlGeneratorConfig extends WadlGeneratorConfig {

            public List configure() {
                return generator( WadlGeneratorApplicationDoc.class )
                    .prop( "applicationDocsStream", "application-doc.xml" )
                  .generator( WadlGeneratorGrammarsSupport.class )
                    .prop( "grammarsStream", "application-grammars.xml" )
                  .generator( WadlGeneratorResourceDocSupport.class )
                    .prop( "resourceDocStream", "resourcedoc.xml" )
                  .descriptions();
            }

        }

Version:
  $Id: WadlGeneratorConfig.java 4584 2011-02-10 09:12:27Z pavel_bucek $
Author:
  Martin Grotzke

Nested Class Summary
`static class` | `WadlGeneratorConfig.WadlGeneratorConfigBuilder`
`static class` | `WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder`

Constructor Summary
`WadlGeneratorConfig()`
`WadlGeneratorConfig(WadlGenerator wadlGenerator)` Creates a new WadlGeneratorConfig from the provided wadlGenerator (must already be initialized).

Method Summary
`abstract java.util.List<WadlGeneratorDescription>` | `configure()`
`static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder` | `generator(java.lang.Class<? extends WadlGenerator> generatorClass)` Start to build an instance of `WadlGeneratorConfig`:
`static WadlGeneratorConfig.WadlGeneratorConfigBuilder` | `generator(WadlGenerator generator)` Start to build an instance of `WadlGeneratorConfig`:
`WadlGenerator` | `getWadlGenerator()` Get or load the initialized `WadlGenerator`, based on the `WadlGeneratorDescription`s provided by `configure()`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WadlGeneratorConfig

    public WadlGeneratorConfig()

### WadlGeneratorConfig

    public WadlGeneratorConfig(WadlGenerator wadlGenerator)

  Creates a new WadlGeneratorConfig from the provided wadlGenerator (must already be initialized).

  Parameters:
    `wadlGenerator` - the wadl generator to provide, must not be null.

Method Detail

### configure

    public abstract java.util.List<WadlGeneratorDescription> configure()

### getWadlGenerator

    public WadlGenerator getWadlGenerator()

  Get or load the initialized `WadlGenerator`, based on the `WadlGeneratorDescription`s provided by `configure()`.

  Returns:
    the initialized `WadlGenerator`.

### generator

    public static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder generator(java.lang.Class<? extends WadlGenerator> generatorClass)

  Start to build an instance of `WadlGeneratorConfig`:

      generator(<class>)
            .prop(<name>, <value>)
            .prop(<name>, <value>)
       .generator(<class>)
            .prop(<name>, <value>)
            .prop(<name>, <value>)
            .build()

  Parameters:
    `generatorClass` - the class of the wadl generator to configure
  Returns:
    an instance of `WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder`.

### generator

    public static WadlGeneratorConfig.WadlGeneratorConfigBuilder generator(WadlGenerator generator)

  Start to build an instance of `WadlGeneratorConfig`:

      generator(<generator>).generator(<generator>).build()

  Parameters:
    `generator` - the configured wadl generator
  Returns:
    an instance of `WadlGeneratorConfig.WadlGeneratorConfigBuilder`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011 Oracle Corporation. All Rights Reserved.