Class WadlGeneratorResourceDocSupport
- java.lang.Object
-
- org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.WadlGeneratorResourceDocSupport
-
- All Implemented Interfaces:
WadlGenerator
public class WadlGeneratorResourceDocSupport extends java.lang.Object implements WadlGenerator
AWadlGenerator
implementation that enhances the generated wadl by information read from a resourcedoc (containing javadoc information about resource classes).The resourcedoc information can either be provided via a
File
(setResourceDocFile(File)
) reference or via anInputStream
(setResourceDocStream(InputStream)
).The
File
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 ResourceDocAccessor
resourceDoc
private java.io.File
resourceDocFile
private java.io.InputStream
resourceDocStream
private javax.inject.Provider<javax.xml.parsers.SAXParserFactory>
saxFactoryProvider
-
Constructor Summary
Constructors Constructor Description WadlGeneratorResourceDocSupport()
WadlGeneratorResourceDocSupport(WadlGenerator wadlGenerator, ResourceDocType resourceDoc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addDoc(java.util.List<Doc> docs, java.lang.String text)
private void
addDocForExample(java.util.List<Doc> docs, java.lang.String example)
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 resource, ResourceMethod resourceMethod)
Param
createParam(Resource r, ResourceMethod m, Parameter p)
Request
createRequest(Resource r, ResourceMethod m)
Representation
createRequestRepresentation(Resource r, ResourceMethod m, javax.ws.rs.core.MediaType mediaType)
Resource
createResource(Resource r, java.lang.String path)
Resources
createResources()
java.util.List<Response>
createResponses(Resource r, ResourceMethod m)
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.private boolean
isEmpty(java.lang.String text)
void
setResourceDocFile(java.io.File resourceDocFile)
Set theresourceDocFile
to the given file.void
setResourceDocStream(java.io.InputStream resourceDocStream)
Set theresourceDocStream
to the given file.void
setWadlGeneratorDelegate(WadlGenerator delegate)
Sets the delegate that is decorated by this wadl generator.
-
-
-
Field Detail
-
delegate
private WadlGenerator delegate
-
resourceDocFile
private java.io.File resourceDocFile
-
resourceDocStream
private java.io.InputStream resourceDocStream
-
resourceDoc
private ResourceDocAccessor resourceDoc
-
saxFactoryProvider
@Context private javax.inject.Provider<javax.xml.parsers.SAXParserFactory> saxFactoryProvider
-
-
Constructor Detail
-
WadlGeneratorResourceDocSupport
public WadlGeneratorResourceDocSupport()
-
WadlGeneratorResourceDocSupport
public WadlGeneratorResourceDocSupport(WadlGenerator wadlGenerator, ResourceDocType resourceDoc)
-
-
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
-
setResourceDocFile
public void setResourceDocFile(java.io.File resourceDocFile)
Set theresourceDocFile
to the given file. Invoking this method is only allowed, as long as theresourceDocStream
is not set, otherwise anIllegalStateException
will be thrown.- Parameters:
resourceDocFile
- the resourcedoc file to set.
-
setResourceDocStream
public void setResourceDocStream(java.io.InputStream resourceDocStream)
Set theresourceDocStream
to the given file. Invoking this method is only allowed, as long as theresourceDocFile
is not set, otherwise anIllegalStateException
will be thrown.The resourcedoc stream must be closed by the client providing the stream.
- Parameters:
resourceDocStream
- the resourcedoc stream to set.
-
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
-
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}
.
-
createApplication
public Application createApplication()
- Specified by:
createApplication
in interfaceWadlGenerator
- Returns:
- the
Application
created by the delegate. - See Also:
WadlGenerator.createApplication()
-
createResource
public Resource createResource(Resource r, java.lang.String path)
- Specified by:
createResource
in interfaceWadlGenerator
- Parameters:
r
- Jersey resource component for which the WADL reource is to be created.path
- path where the resource is exposed.- Returns:
- the enhanced
Resource
. - See Also:
WadlGenerator.createResource(org.glassfish.jersey.server.model.Resource, String)
-
createMethod
public Method createMethod(Resource resource, ResourceMethod resourceMethod)
- Specified by:
createMethod
in interfaceWadlGenerator
- Parameters:
resource
- Jersey resource component.resourceMethod
- resource method.- Returns:
- the enhanced
Method
. - See Also:
WadlGenerator.createMethod(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
createRequestRepresentation
public Representation createRequestRepresentation(Resource r, ResourceMethod m, javax.ws.rs.core.MediaType mediaType)
- Specified by:
createRequestRepresentation
in interfaceWadlGenerator
- Parameters:
r
- Jersey resource component.m
- resource method.mediaType
- media type.- Returns:
- the enhanced
Representation
. - See Also:
WadlGenerator.createRequestRepresentation(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod, javax.ws.rs.core.MediaType)
-
createRequest
public Request createRequest(Resource r, ResourceMethod m)
- Specified by:
createRequest
in interfaceWadlGenerator
- Parameters:
r
- Jersey resource component.m
- resource method.- Returns:
- the enhanced
Request
. - See Also:
WadlGenerator.createRequest(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
createResponses
public java.util.List<Response> createResponses(Resource r, ResourceMethod m)
- Specified by:
createResponses
in interfaceWadlGenerator
- Parameters:
r
- Jersey resource component.m
- resource method.- Returns:
- the enhanced
Response
. - See Also:
WadlGenerator.createResponses(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod)
-
addDocForExample
private void addDocForExample(java.util.List<Doc> docs, java.lang.String example)
-
addDoc
private void addDoc(java.util.List<Doc> docs, java.lang.String text)
-
createParam
public Param createParam(Resource r, ResourceMethod m, Parameter p)
- Specified by:
createParam
in interfaceWadlGenerator
- Parameters:
r
- Jersey resource component.m
- resource method.p
- method parameter.- Returns:
- the enhanced
Param
. - See Also:
WadlGenerator.createParam(org.glassfish.jersey.server.model.Resource, org.glassfish.jersey.server.model.ResourceMethod, org.glassfish.jersey.server.model.Parameter)
-
createResources
public Resources createResources()
- Specified by:
createResources
in interfaceWadlGenerator
- Returns:
- the
Resources
created by the delegate. - See Also:
WadlGenerator.createResources()
-
isEmpty
private boolean isEmpty(java.lang.String text)
-
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
-
-