com.sun.jersey.server.wadl.generators
Class AbstractWadlGeneratorGrammarGenerator<T>

java.lang.Object
  extended by com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator<T>
All Implemented Interfaces:
WadlGenerator
Direct Known Subclasses:
WadlGeneratorJAXBGrammarGenerator

public abstract class AbstractWadlGeneratorGrammarGenerator<T>
extends java.lang.Object
implements WadlGenerator

This WadlGenerator generates a grammar based on the referenced elements. This is a template class designed to be overridden by specific implementations, for example XML Schema and JSON Schema

Created on: Sept 17, 2012

Version:
$Id: AbstractWadlGeneratorGrammarGenerator.java $
Author:
Gerard Davison

Nested Class Summary
protected static interface AbstractWadlGeneratorGrammarGenerator.HasType
           
protected  class AbstractWadlGeneratorGrammarGenerator.Pair
           
protected static interface AbstractWadlGeneratorGrammarGenerator.WantsName<T>
           
 
Nested classes/interfaces inherited from interface com.sun.jersey.server.wadl.WadlGenerator
WadlGenerator.Environment, WadlGenerator.ExternalGrammarDefinition, WadlGenerator.Resolver
 
Field Summary
protected  FeaturesAndProperties _fap
           
protected  java.util.List<AbstractWadlGeneratorGrammarGenerator.Pair> _hasTypeWantsName
           
protected  Providers _providers
           
protected  java.lang.Class<T> _resolvedType
           
protected  java.net.URI _root
           
protected  java.util.Set<java.lang.Class> _seeAlso
           
protected  java.net.URI _wadl
           
static java.util.Set<java.lang.Class> SPECIAL_GENERIC_TYPES
           
 
Constructor Summary
protected AbstractWadlGeneratorGrammarGenerator(WadlGenerator delegate, java.lang.Class<T> resolvedType)
           
 
Method Summary
abstract  boolean acceptMediaType(MediaType type)
           
 void attachTypes(ApplicationDescription introspector)
          Process the elements in the WADL definition to attach schema types as required.
protected abstract  WadlGenerator.Resolver buildModelAndSchemas(java.util.Map<java.lang.String,ApplicationDescription.ExternalGrammar> extraFiles)
          Build the the external schema files and generate a suitable resolver
 com.sun.research.ws.wadl.Application createApplication(UriInfo requestInfo)
           
 WadlGenerator.ExternalGrammarDefinition createExternalGrammar()
          Perform any post create functions such as generating grammars.
 com.sun.research.ws.wadl.Method createMethod(AbstractResource ar, AbstractResourceMethod arm)
           
 com.sun.research.ws.wadl.Param createParam(AbstractResource ar, AbstractMethod am, Parameter p)
           
protected abstract  AbstractWadlGeneratorGrammarGenerator.WantsName<T> createParmWantsName(com.sun.research.ws.wadl.Param param)
           
protected abstract  AbstractWadlGeneratorGrammarGenerator.WantsName<T> createRepresentationWantsName(com.sun.research.ws.wadl.Representation rt)
           
 com.sun.research.ws.wadl.Request createRequest(AbstractResource ar, AbstractResourceMethod arm)
           
 com.sun.research.ws.wadl.Representation createRequestRepresentation(AbstractResource ar, AbstractResourceMethod arm, MediaType mt)
           
 com.sun.research.ws.wadl.Resource createResource(AbstractResource ar, java.lang.String path)
           
 com.sun.research.ws.wadl.Resources createResources()
           
 java.util.List<com.sun.research.ws.wadl.Response> createResponses(AbstractResource ar, AbstractResourceMethod arm)
           
 java.lang.String getRequiredJaxbContextPath()
          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 by WadlGenerator.setWadlGeneratorDelegate(WadlGenerator).
If you do not use custom jaxb beans, then simply return _delegate.getRequiredJaxbContextPath(), otherwise return the delegate's WadlGenerator.getRequiredJaxbContextPath() together with your required context path (separated by a colon):
 void init()
          Invoked before all methods related to wadl-building are invoked.
protected static AbstractWadlGeneratorGrammarGenerator.HasType parameter(Parameter param, MediaType mt)
           
 void setEnvironment(WadlGenerator.Environment env)
          Provides the WadlGenerator with the current generating environment.
 void setWadlGeneratorDelegate(WadlGenerator delegate)
          Sets the delegate that is decorated by this wadl generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPECIAL_GENERIC_TYPES

public static final java.util.Set<java.lang.Class> SPECIAL_GENERIC_TYPES

_seeAlso

protected java.util.Set<java.lang.Class> _seeAlso

_hasTypeWantsName

protected java.util.List<AbstractWadlGeneratorGrammarGenerator.Pair> _hasTypeWantsName

_root

protected java.net.URI _root

_wadl

protected java.net.URI _wadl

_providers

protected Providers _providers

_fap

protected FeaturesAndProperties _fap

_resolvedType

protected java.lang.Class<T> _resolvedType
Constructor Detail

AbstractWadlGeneratorGrammarGenerator

protected AbstractWadlGeneratorGrammarGenerator(WadlGenerator delegate,
                                                java.lang.Class<T> resolvedType)
Method Detail

parameter

protected static AbstractWadlGeneratorGrammarGenerator.HasType parameter(Parameter param,
                                                                         MediaType mt)
Parameters:
param - parameter.
Returns:
An adapter for Parameter

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 before WadlGenerator.init() or any setter method is invoked.

Specified by:
setWadlGeneratorDelegate in interface WadlGenerator
Parameters:
delegate - the wadl generator to decorate

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 by WadlGenerator.setWadlGeneratorDelegate(WadlGenerator).
If you do not use custom jaxb beans, then simply return _delegate.getRequiredJaxbContextPath(), otherwise return the delegate's WadlGenerator.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 with XmlRegistry) to this package.

Specified by:
getRequiredJaxbContextPath in interface WadlGenerator
Returns:
simply the WadlGenerator.getRequiredJaxbContextPath() of the delegate or the WadlGenerator.getRequiredJaxbContextPath() + ":" + ${yourContextPath}.

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 invoke this.delegate.init().

Specified by:
init in interface WadlGenerator
Throws:
java.lang.Exception

setEnvironment

public void setEnvironment(WadlGenerator.Environment env)
Provides the WadlGenerator with the current generating environment. This method is used in a decorator like manner, and therefore has to invoke this.delegate.setEnvironment(env).

Specified by:
setEnvironment in interface WadlGenerator

acceptMediaType

public abstract boolean acceptMediaType(MediaType type)
Parameters:
type -
Returns:
Whether we want to acceptMediaType this element, for example the grammar generator wouldn't necessarily want to selector for JAX-B or vice versa.

createApplication

public com.sun.research.ws.wadl.Application createApplication(UriInfo requestInfo)
Specified by:
createApplication in interface WadlGenerator
Returns:
application
See Also:
com.sun.jersey.server.wadl.WadlGenerator#createApplication()

createMethod

public com.sun.research.ws.wadl.Method createMethod(AbstractResource ar,
                                                    AbstractResourceMethod arm)
Specified by:
createMethod in interface WadlGenerator
Parameters:
ar - abstract resource
arm - abstract resource method
Returns:
method
See Also:
WadlGenerator.createMethod(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)

createRequest

public com.sun.research.ws.wadl.Request createRequest(AbstractResource ar,
                                                      AbstractResourceMethod arm)
Specified by:
createRequest in interface WadlGenerator
Parameters:
ar - abstract resource
arm - abstract resource method
Returns:
request
See Also:
WadlGenerator.createRequest(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)

createParam

public com.sun.research.ws.wadl.Param createParam(AbstractResource ar,
                                                  AbstractMethod am,
                                                  Parameter p)
Specified by:
createParam in interface WadlGenerator
Parameters:
ar - abstract resource
am - abstract method
p - parameter
Returns:
parameter
See Also:
WadlGenerator.createParam(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractMethod, com.sun.jersey.api.model.Parameter)

createRequestRepresentation

public com.sun.research.ws.wadl.Representation createRequestRepresentation(AbstractResource ar,
                                                                           AbstractResourceMethod arm,
                                                                           MediaType mt)
Specified by:
createRequestRepresentation in interface WadlGenerator
Parameters:
ar - abstract resource
arm - abstract resource method
mt - media type
Returns:
respresentation type
See Also:
WadlGenerator.createRequestRepresentation(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod, javax.ws.rs.core.MediaType)

createResource

public com.sun.research.ws.wadl.Resource createResource(AbstractResource ar,
                                                        java.lang.String path)
Specified by:
createResource in interface WadlGenerator
Parameters:
ar - abstract resource
path - resources path
Returns:
resource
See Also:
WadlGenerator.createResource(com.sun.jersey.api.model.AbstractResource, java.lang.String)

createResources

public com.sun.research.ws.wadl.Resources createResources()
Specified by:
createResources in interface WadlGenerator
Returns:
resources
See Also:
WadlGenerator.createResources()

createResponses

public java.util.List<com.sun.research.ws.wadl.Response> createResponses(AbstractResource ar,
                                                                         AbstractResourceMethod arm)
Specified by:
createResponses in interface WadlGenerator
Parameters:
ar - abstract resource
arm - abstract resource method
Returns:
response
See Also:
WadlGenerator.createResponses(com.sun.jersey.api.model.AbstractResource, com.sun.jersey.api.model.AbstractResourceMethod)

createExternalGrammar

public WadlGenerator.ExternalGrammarDefinition createExternalGrammar()
Description copied from interface: WadlGenerator
Perform any post create functions such as generating grammars.

Specified by:
createExternalGrammar in interface WadlGenerator
Returns:
A map of extra files to the content of those file encoded in UTF-8

buildModelAndSchemas

protected abstract WadlGenerator.Resolver buildModelAndSchemas(java.util.Map<java.lang.String,ApplicationDescription.ExternalGrammar> extraFiles)
Build the the external schema files and generate a suitable resolver

Parameters:
extraFiles -

attachTypes

public void attachTypes(ApplicationDescription introspector)
Description copied from interface: WadlGenerator
Process the elements in the WADL definition to attach schema types as required.

Specified by:
attachTypes in interface WadlGenerator
Parameters:
introspector - The root description used to resolve these entries

createParmWantsName

protected abstract AbstractWadlGeneratorGrammarGenerator.WantsName<T> createParmWantsName(com.sun.research.ws.wadl.Param param)

createRepresentationWantsName

protected abstract AbstractWadlGeneratorGrammarGenerator.WantsName<T> createRepresentationWantsName(com.sun.research.ws.wadl.Representation rt)


Copyright © 2014 Oracle Corporation. All Rights Reserved.