Class WadlGeneratorConfig
- java.lang.Object
-
- org.glassfish.jersey.server.wadl.config.WadlGeneratorConfig
-
public abstract class WadlGeneratorConfig extends Object
Provides a configuredWadlGeneratorwith all decorations (the default wadl generator decorated by other generators).Creating a WadlGeneratorConfig
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
WadlGeneratorConfigin the web.xml you have to subclass it and set the servlet init-paramServerProperties.WADL_GENERATOR_CONFIGto 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(); } }Configuring the WadlGenerator
The
WadlGeneratorproperties will be populated with the provided properties like this:- The types match exactly:
if the WadlGenerator property is of typeorg.example.Fooand the provided property value is of typeorg.example.Foo - Types that provide a constructor for the provided type (mostly java.lang.String)
- java.io.InputStream: The
InputStreamcan e.g. represent a file. The stream is loaded from the property value (provided by theWadlGeneratorDescription) viaClassLoader.getResourceAsStream(String). It will be closed afterWadlGenerator.init()was called. - Deprecated, will be removed in future versions:
The WadlGenerator property is of typeFileand the provided property value is aString:
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 theFileis created vianew 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
WadlGeneratorimplementations:WadlGeneratorApplicationDocWadlGeneratorGrammarsSupportWadlGeneratorJAXBGrammarGeneratorWadlGeneratorResourceDocSupport
A common example for a
WadlGeneratorConfigwould 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(); } }- Author:
- Martin Grotzke (martin.grotzke at freiheit.com)
- The types match exactly:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder
-
Constructor Summary
Constructors Constructor Description WadlGeneratorConfig()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Listconfigure()WadlGeneratorcreateWadlGenerator(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)Create a new instance ofWadlGenerator, based on theWadlGeneratorDescriptions provided byconfigure().static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuildergenerator(Class<? extends WadlGenerator> generatorClass)Start to build an instance ofWadlGeneratorConfig:
-
-
-
Method Detail
-
configure
public abstract List configure()
-
createWadlGenerator
public WadlGenerator createWadlGenerator(org.glassfish.jersey.internal.inject.InjectionManager injectionManager)
Create a new instance ofWadlGenerator, based on theWadlGeneratorDescriptions provided byconfigure().- Returns:
- the initialized
WadlGenerator
-
generator
public static WadlGeneratorConfig.WadlGeneratorConfigDescriptionBuilder generator(Class<? extends WadlGenerator> generatorClass)
Start to build an instance ofWadlGeneratorConfig: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.
-
-