Class WadlGeneratorResourceDocSupport
- java.lang.Object
-
- org.glassfish.jersey.server.wadl.internal.generators.resourcedoc.WadlGeneratorResourceDocSupport
-
- All Implemented Interfaces:
WadlGenerator
public class WadlGeneratorResourceDocSupport extends Object implements WadlGenerator
AWadlGeneratorimplementation 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
Fileshould be used when using the maven-wadl-plugin for generating wadl offline, theInputStreamshould be used when the extended wadl is generated by jersey at runtime, e.g. using theWadlGeneratorConfigfor configuration.- Author:
- Martin Grotzke (martin.grotzke at freiheit.com), Miroslav Fuksa
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.wadl.WadlGenerator
WadlGenerator.ExternalGrammarDefinition, WadlGenerator.Resolver
-
-
Constructor Summary
Constructors Constructor Description WadlGeneratorResourceDocSupport()WadlGeneratorResourceDocSupport(WadlGenerator wadlGenerator, ResourceDocType resourceDoc)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachTypes(ApplicationDescription egd)Process the elements in the WADL definition to attach schema types as required.ApplicationcreateApplication()WadlGenerator.ExternalGrammarDefinitioncreateExternalGrammar()Perform any post create functions such as generating grammars.MethodcreateMethod(Resource resource, ResourceMethod resourceMethod)ParamcreateParam(Resource r, ResourceMethod m, Parameter p)RequestcreateRequest(Resource r, ResourceMethod m)RepresentationcreateRequestRepresentation(Resource r, ResourceMethod m, MediaType mediaType)ResourcecreateResource(Resource r, String path)ResourcescreateResources()List<Response>createResponses(Resource r, ResourceMethod m)StringgetRequiredJaxbContextPath()The jaxb context path that is used when the generated wadl application is marshalled to a file.voidinit()Invoked before all methods related to wadl-building are invoked.voidsetResourceDocFile(File resourceDocFile)Set theresourceDocFileto the given file.voidsetResourceDocStream(InputStream resourceDocStream)Set theresourceDocStreamto the given file.voidsetWadlGeneratorDelegate(WadlGenerator delegate)Sets the delegate that is decorated by this wadl generator.
-
-
-
Constructor Detail
-
WadlGeneratorResourceDocSupport
public WadlGeneratorResourceDocSupport()
-
WadlGeneratorResourceDocSupport
public WadlGeneratorResourceDocSupport(WadlGenerator wadlGenerator, ResourceDocType resourceDoc)
-
-
Method Detail
-
setWadlGeneratorDelegate
public void setWadlGeneratorDelegate(WadlGenerator delegate)
Description copied from interface:WadlGeneratorSets 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:
setWadlGeneratorDelegatein interfaceWadlGenerator- Parameters:
delegate- the wadl generator to decorate
-
setResourceDocFile
public void setResourceDocFile(File resourceDocFile)
Set theresourceDocFileto the given file. Invoking this method is only allowed, as long as theresourceDocStreamis not set, otherwise anIllegalStateExceptionwill be thrown.- Parameters:
resourceDocFile- the resourcedoc file to set.
-
setResourceDocStream
public void setResourceDocStream(InputStream resourceDocStream)
Set theresourceDocStreamto the given file. Invoking this method is only allowed, as long as theresourceDocFileis not set, otherwise anIllegalStateExceptionwill 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 ExceptionDescription copied from interface:WadlGeneratorInvoked 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:
initin interfaceWadlGenerator- Throws:
IllegalStateExceptionjakarta.xml.bind.JAXBExceptionException
-
getRequiredJaxbContextPath
public String getRequiredJaxbContextPath()
Description copied from interface:WadlGeneratorThe 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:
getRequiredJaxbContextPathin interfaceWadlGenerator- Returns:
- simply the
getRequiredJaxbContextPath()of the delegate or thegetRequiredJaxbContextPath() + ":" + ${yourContextPath}.
-
createApplication
public Application createApplication()
- Specified by:
createApplicationin interfaceWadlGenerator- Returns:
- the
Applicationcreated by the delegate. - See Also:
WadlGenerator.createApplication()
-
createResource
public Resource createResource(Resource r, String path)
- Specified by:
createResourcein 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:
createMethodin 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, MediaType mediaType)
- Specified by:
createRequestRepresentationin 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, jakarta.ws.rs.core.MediaType)
-
createRequest
public Request createRequest(Resource r, ResourceMethod m)
- Specified by:
createRequestin 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 List<Response> createResponses(Resource r, ResourceMethod m)
- Specified by:
createResponsesin 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)
-
createParam
public Param createParam(Resource r, ResourceMethod m, Parameter p)
- Specified by:
createParamin 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:
createResourcesin interfaceWadlGenerator- Returns:
- the
Resourcescreated by the delegate. - See Also:
WadlGenerator.createResources()
-
createExternalGrammar
public WadlGenerator.ExternalGrammarDefinition createExternalGrammar()
Description copied from interface:WadlGeneratorPerform any post create functions such as generating grammars.- Specified by:
createExternalGrammarin 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:WadlGeneratorProcess the elements in the WADL definition to attach schema types as required.- Specified by:
attachTypesin interfaceWadlGenerator- Parameters:
egd- The root description used to resolve these entries
-
-