Class WadlGeneratorGrammarsSupport
- java.lang.Object
-
- org.glassfish.jersey.server.wadl.internal.generators.WadlGeneratorGrammarsSupport
-
- All Implemented Interfaces:
WadlGenerator
public class WadlGeneratorGrammarsSupport extends java.lang.Object implements WadlGenerator
ThisWadlGenerator
adds the providedGrammars
element to the generated wadl-file.The
Grammars
content can either be provided via aFile
(setGrammarsFile(File)
) reference or via anInputStream
(setGrammarsStream(InputStream)
).The
Created on: Jun 24, 2008File
should be used when using the maven-wadl-plugin for generating wadl offline, theInputStream
should be used when the extended wadl is generated by jersey at runtime, e.g. using theWadlGeneratorConfig
for configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.wadl.WadlGenerator
WadlGenerator.ExternalGrammarDefinition, WadlGenerator.Resolver
-
-
Field Summary
Fields Modifier and Type Field Description private WadlGenerator
_delegate
private Grammars
_grammars
private java.io.File
_grammarsFile
private java.io.InputStream
_grammarsStream
private static java.util.logging.Logger
LOG
private java.lang.Boolean
overrideGrammars
private javax.inject.Provider<javax.xml.parsers.SAXParserFactory>
saxFactoryProvider
-
Constructor Summary
Constructors Constructor Description WadlGeneratorGrammarsSupport()
WadlGeneratorGrammarsSupport(WadlGenerator delegate, Grammars grammars)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
attachTypes(ApplicationDescription egd)
Process the elements in the WADL definition to attach schema types as required.Application
createApplication()
WadlGenerator.ExternalGrammarDefinition
createExternalGrammar()
Perform any post create functions such as generating grammars.Method
createMethod(Resource ar, ResourceMethod arm)
Param
createParam(Resource ar, ResourceMethod am, Parameter p)
Request
createRequest(Resource ar, ResourceMethod arm)
Representation
createRequestRepresentation(Resource ar, ResourceMethod arm, javax.ws.rs.core.MediaType mt)
Resource
createResource(Resource ar, java.lang.String path)
Resources
createResources()
java.util.List<Response>
createResponses(Resource ar, ResourceMethod arm)
java.lang.String
getRequiredJaxbContextPath()
The jaxb context path that is used when the generated wadl application is marshalled to a file.void
init()
Invoked before all methods related to wadl-building are invoked.void
setGrammarsFile(java.io.File grammarsFile)
void
setGrammarsStream(java.io.InputStream grammarsStream)
void
setOverrideGrammars(java.lang.Boolean overrideGrammars)
void
setWadlGeneratorDelegate(WadlGenerator delegate)
Sets the delegate that is decorated by this wadl generator.
-
-
-
Field Detail
-
LOG
private static final java.util.logging.Logger LOG
-
_delegate
private WadlGenerator _delegate
-
_grammarsFile
private java.io.File _grammarsFile
-
_grammarsStream
private java.io.InputStream _grammarsStream
-
_grammars
private Grammars _grammars
-
overrideGrammars
private java.lang.Boolean overrideGrammars
-
saxFactoryProvider
@Context private javax.inject.Provider<javax.xml.parsers.SAXParserFactory> saxFactoryProvider
-
-
Constructor Detail
-
WadlGeneratorGrammarsSupport
public WadlGeneratorGrammarsSupport()
-
WadlGeneratorGrammarsSupport
public WadlGeneratorGrammarsSupport(WadlGenerator delegate, Grammars grammars)
-
-
Method Detail
-
setWadlGeneratorDelegate
public void setWadlGeneratorDelegate(WadlGenerator delegate)
Description copied from interface:WadlGenerator
Sets the delegate that is decorated by this wadl generator. Is invoked directly after this generator is instantiated beforeWadlGenerator.init()
or any setter method is invoked.- Specified by:
setWadlGeneratorDelegate
in interfaceWadlGenerator
- Parameters:
delegate
- the wadl generator to decorate
-
setOverrideGrammars
public void setOverrideGrammars(java.lang.Boolean overrideGrammars)
-
getRequiredJaxbContextPath
public java.lang.String getRequiredJaxbContextPath()
Description copied from interface:WadlGenerator
The jaxb context path that is used when the generated wadl application is marshalled to a file. This method is used in a decorator like manner. The result return the path (or a colon-separated list of package names) containing jaxb-beans that are added to wadl elements by this WadlGenerator, additionally to the context path of the decorated WadlGenerator (set byWadlGenerator.setWadlGeneratorDelegate(WadlGenerator)
.
If you do not use custom jaxb beans, then simply return_delegate.getRequiredJaxbContextPath()
, otherwise return the delegate's #getRequiredJaxbContextPath() together with your required context path (separated by a colon):
_delegate.getRequiredJaxbContextPath() == null ? ${yourContextPath} : _delegate.getRequiredJaxbContextPath() + ":" + ${yourContextPath};
If you add the path for your custom jaxb beans, don't forget to add an ObjectFactory (annotated withXmlRegistry
) to this package.- Specified by:
getRequiredJaxbContextPath
in interfaceWadlGenerator
- Returns:
- simply the
getRequiredJaxbContextPath()
of the delegate or thegetRequiredJaxbContextPath() + ":" + ${yourContextPath}
.
-
setGrammarsFile
public void setGrammarsFile(java.io.File grammarsFile)
-
setGrammarsStream
public void setGrammarsStream(java.io.InputStream grammarsStream)
-
init
public void init() throws java.lang.Exception
Description copied from interface:WadlGenerator
Invoked before all methods related to wadl-building are invoked. This method is used in a decorator like manner, and therefore has to invokethis.delegate.init()
.- Specified by:
init
in interfaceWadlGenerator
- Throws:
java.lang.IllegalStateException
javax.xml.bind.JAXBException
java.lang.Exception
-
createApplication
public Application createApplication()
- Specified by:
createApplication
in interfaceWadlGenerator
- Returns:
- application
- See Also:
WadlGenerator.createApplication()
-
createMethod
public Method createMethod(Resource ar, ResourceMethod arm)
- Specified by:
createMethod
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourcearm
- abstract resource method- Returns:
- method
- See Also:
WadlGenerator.createMethod(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
createRequest
public Request createRequest(Resource ar, ResourceMethod arm)
- Specified by:
createRequest
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourcearm
- abstract resource method- Returns:
- request
- See Also:
WadlGenerator.createRequest(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
createParam
public Param createParam(Resource ar, ResourceMethod am, Parameter p)
- Specified by:
createParam
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourceam
- abstract methodp
- parameter- Returns:
- parameter
- See Also:
WadlGenerator.createParam(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod, org.glassfish.jersey.server.model.Parameter)
-
createRequestRepresentation
public Representation createRequestRepresentation(Resource ar, ResourceMethod arm, javax.ws.rs.core.MediaType mt)
- Specified by:
createRequestRepresentation
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourcearm
- abstract resource methodmt
- media type- Returns:
- respresentation type
- See Also:
WadlGenerator.createRequestRepresentation(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod, javax.ws.rs.core.MediaType)
-
createResource
public Resource createResource(Resource ar, java.lang.String path)
- Specified by:
createResource
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourcepath
- resource path- Returns:
- resource
- See Also:
WadlGenerator.createResource(org.glassfish.jersey.server.model.Resource, String)
-
createResources
public Resources createResources()
- Specified by:
createResources
in interfaceWadlGenerator
- Returns:
- resources
- See Also:
WadlGenerator.createResources()
-
createResponses
public java.util.List<Response> createResponses(Resource ar, ResourceMethod arm)
- Specified by:
createResponses
in interfaceWadlGenerator
- Parameters:
ar
- abstract resourcearm
- abstract resource method- Returns:
- response
- See Also:
WadlGenerator.createResponses(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
createExternalGrammar
public WadlGenerator.ExternalGrammarDefinition createExternalGrammar()
Description copied from interface:WadlGenerator
Perform any post create functions such as generating grammars.- Specified by:
createExternalGrammar
in interfaceWadlGenerator
- Returns:
- A map of extra files to the content of those file encoded in UTF-8
-
attachTypes
public void attachTypes(ApplicationDescription egd)
Description copied from interface:WadlGenerator
Process the elements in the WADL definition to attach schema types as required.- Specified by:
attachTypes
in interfaceWadlGenerator
- Parameters:
egd
- The root description used to resolve these entries
-
-