public abstract class WadlGeneratorConfig extends Object
WadlGenerator
with all decorations (the default
wadl generator decorated by other generators).
If you want to create an instance at runtime you can configure the WadlGenerator class and property names/values. A new instance of the Generator is created for each generation action. 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();
If you want to specify the WadlGeneratorConfig
in the web.xml you have
to subclass it and set the servlet init-param ServerProperties.WADL_GENERATOR_CONFIG
to the name of your subclass. This class might look like this:
class MyWadlGeneratorConfig extends WadlGeneratorConfig { public List<WadlGeneratorDescription> configure() { return generator( MyWadlGenerator.class ) .prop( "foo", propValue ) .generator( MyWadlGenerator2.class ) .prop( "bar", propValue2 ) .descriptions(); } }
The WadlGenerator
properties will be populated with the provided properties like this:
org.example.Foo
and the
provided property value is of type org.example.Foo
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.
File
and the provided property value is a String
: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.
WadlGenerator
implementations:
WadlGeneratorApplicationDoc
WadlGeneratorGrammarsSupport
WadlGeneratorJAXBGrammarGenerator
WadlGeneratorResourceDocSupport
A common example for a WadlGeneratorConfig
would be this:
class MyWadlGeneratorConfig extends WadlGeneratorConfig { public List<WadlGeneratorDescription> 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(); .descriptions(); } }
Modifier and Type | Class and Description |
---|---|
static class |
WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder |
Constructor and Description |
---|
WadlGeneratorConfig() |
Modifier and Type | Method and Description |
---|---|
abstract List |
configure() |
WadlGenerator |
createWadlGenerator(InjectionManager injectionManager)
Create a new instance of
WadlGenerator , based on the WadlGeneratorDescription s
provided by configure() . |
static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder |
generator(Class<? extends WadlGenerator> generatorClass)
Start to build an instance of
WadlGeneratorConfig : |
public abstract List configure()
public WadlGenerator createWadlGenerator(InjectionManager injectionManager)
WadlGenerator
, based on the WadlGeneratorDescription
s
provided by configure()
.WadlGenerator
public static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder generator(Class<? extends WadlGenerator> generatorClass)
WadlGeneratorConfig
:
generator(<class>)
.prop(<name>, <value>)
.prop(<name>, <value>)
.generator(<class>)
.prop(<name>, <value>)
.prop(<name>, <value>)
.build()
generatorClass
- the class of the wadl generator to configureWadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder
.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.