org.codehaus.enunciate.apt
Class EnunciateAnnotationProcessor

java.lang.Object
  extended by net.sf.jelly.apt.freemarker.FreemarkerProcessor
      extended by org.codehaus.enunciate.apt.EnunciateAnnotationProcessor
All Implemented Interfaces:
com.sun.mirror.apt.AnnotationProcessor

public class EnunciateAnnotationProcessor
extends net.sf.jelly.apt.freemarker.FreemarkerProcessor

Root annotation processor for enunciate. Initializes the model and signals the modules to generate.

Even though it extends FreemarkerProcessor, it does not process any Freemarker templates directly. It extends FreemarkerProcessor only to inherit certain functionality.

Author:
Ryan Heaton

Constructor Summary
EnunciateAnnotationProcessor(Enunciate enunciate, java.lang.String... additionalApiClasses)
           
 
Method Summary
 RootElementDeclaration createRootElementDeclaration(com.sun.mirror.declaration.ClassDeclaration declaration, TypeDefinition typeDefinition)
          Find or create the root element declaration for the specified type definition.
 TypeDefinition createTypeDefinition(com.sun.mirror.declaration.ClassDeclaration declaration, EnunciateFreemarkerModel model)
          Find the type definition for a class given the class's declaration, or null if the class is xml transient.
 void debug(java.lang.String message, java.lang.Object... formatArgs)
          Handle a debug-level message.
protected  com.sun.mirror.apt.Messager getMessager()
          Get the messager for the current environment.
protected  EnunciateFreemarkerModel getRootModel()
          Getting the root model pulls all endpoint interfaces and schema types out of the source base, adds the classes specified to be included, and adds them to the model, then validates the model.
 java.util.Collection<net.sf.jelly.apt.freemarker.FreemarkerTransform> getTransforms()
           
 void info(java.lang.String message, java.lang.Object... formatArgs)
          Handle an info-level message.
 boolean isEndpointInterface(com.sun.mirror.declaration.TypeDeclaration declaration)
          A quick check to see if a declaration is an endpoint interface.
 boolean isJAXRSRootResource(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified type is a JAX-RS root resource.
 boolean isJAXRSSupport(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified type is a JAX-RS support class (resource and/or provider).
protected  boolean isPotentialJsonSchemaType(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified declaration is a potential schema type for JSON data.
protected  boolean isPotentialXmlSchemaType(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified declaration is a potential schema type.
protected  boolean isRegistry(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified declaration is a registry.
protected  boolean isRootSchemaElement(com.sun.mirror.declaration.TypeDeclaration declaration)
          A quick check to see if a declaration defines a root schema element.
protected  boolean isThrowable(com.sun.mirror.declaration.TypeDeclaration declaration)
          Whether the specified declaration is throwable.
protected  com.sun.mirror.declaration.TypeDeclaration[] loadAdditionalApiDefinitions()
          Loads the type declarations for the additional API definitions.
protected  void loadJsonTypeDef(JsonTypeDefinition typeDefinition, EnunciateFreemarkerModel model)
          Loads the specified type definition into the specified model.
protected  void loadTypeDef(TypeDefinition typeDef, EnunciateFreemarkerModel model)
          Loads the specified type definition into the specified model.
protected  net.sf.jelly.apt.freemarker.FreemarkerModel newRootModel()
           
protected  void onUnhandledDeclaration(EnunciateFreemarkerModel model, com.sun.mirror.declaration.TypeDeclaration declaration)
           
 void process()
           
protected  void process(EnunciateException e)
           
protected  void process(java.io.IOException e)
           
protected  void process(java.lang.RuntimeException e)
           
protected  void process(freemarker.template.TemplateException e)
           
protected  void removeExcludedClasses(java.util.Collection<com.sun.mirror.declaration.TypeDeclaration> typeDeclarations)
          Remove any classes that are explicitly exluded from this (presumably modifiable) collection.
 void throwAnyErrors()
          Throws any errors that occurred during processing.
protected  void trimNotIncludedClasses(java.util.Collection<com.sun.mirror.declaration.TypeDeclaration> typeDeclarations)
          Trim any classes that are not explicitly included from this (presumably modifiable) collection.
protected  void validate(EnunciateFreemarkerModel model)
          Validate the model.
protected  ValidationResult validate(EnunciateFreemarkerModel model, Validator validator)
          Validates the model given a validator.
 void warn(java.lang.String message, java.lang.Object... formatArgs)
          Handle a warn-level message.
 
Methods inherited from class net.sf.jelly.apt.freemarker.FreemarkerProcessor
getConfiguration, getObjectWrapper, getTemplateLoader, getTemplateURL, getVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnunciateAnnotationProcessor

public EnunciateAnnotationProcessor(Enunciate enunciate,
                                    java.lang.String... additionalApiClasses)
                             throws EnunciateException
Throws:
EnunciateException
Method Detail

process

public void process()
Specified by:
process in interface com.sun.mirror.apt.AnnotationProcessor
Overrides:
process in class net.sf.jelly.apt.freemarker.FreemarkerProcessor

getRootModel

protected EnunciateFreemarkerModel getRootModel()
                                         throws freemarker.template.TemplateModelException
Getting the root model pulls all endpoint interfaces and schema types out of the source base, adds the classes specified to be included, and adds them to the model, then validates the model.

Overrides:
getRootModel in class net.sf.jelly.apt.freemarker.FreemarkerProcessor
Returns:
The root model.
Throws:
freemarker.template.TemplateModelException

onUnhandledDeclaration

protected void onUnhandledDeclaration(EnunciateFreemarkerModel model,
                                      com.sun.mirror.declaration.TypeDeclaration declaration)

removeExcludedClasses

protected void removeExcludedClasses(java.util.Collection<com.sun.mirror.declaration.TypeDeclaration> typeDeclarations)
Remove any classes that are explicitly exluded from this (presumably modifiable) collection.

Parameters:
typeDeclarations - the declarations.

trimNotIncludedClasses

protected void trimNotIncludedClasses(java.util.Collection<com.sun.mirror.declaration.TypeDeclaration> typeDeclarations)
Trim any classes that are not explicitly included from this (presumably modifiable) collection.

Parameters:
typeDeclarations - The declarations.

loadAdditionalApiDefinitions

protected com.sun.mirror.declaration.TypeDeclaration[] loadAdditionalApiDefinitions()
Loads the type declarations for the additional API definitions.

Returns:
The type declarations.

loadJsonTypeDef

protected void loadJsonTypeDef(JsonTypeDefinition typeDefinition,
                               EnunciateFreemarkerModel model)
Loads the specified type definition into the specified model.

Parameters:
typeDefinition - The type definition to load.
model - The model into which to load the type definition.

loadTypeDef

protected void loadTypeDef(TypeDefinition typeDef,
                           EnunciateFreemarkerModel model)
Loads the specified type definition into the specified model.

Parameters:
typeDef - The type definition to load.
model - The model into which to load the type definition.

validate

protected void validate(EnunciateFreemarkerModel model)
                 throws ModelValidationException
Validate the model. This action uses the validator specified in the config as well as any module-specific validators. Errors and warnings are printed using the APT messager.

Parameters:
model - The model to validate.
Throws:
ModelValidationException - If any validation errors are encountered.

getMessager

protected com.sun.mirror.apt.Messager getMessager()
Get the messager for the current environment.

Returns:
The messager.

newRootModel

protected net.sf.jelly.apt.freemarker.FreemarkerModel newRootModel()
Overrides:
newRootModel in class net.sf.jelly.apt.freemarker.FreemarkerProcessor

isRegistry

protected boolean isRegistry(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified declaration is a registry.

Parameters:
declaration - The declaration.
Returns:
Whether the specified declaration is a registry.

isPotentialJsonSchemaType

protected boolean isPotentialJsonSchemaType(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified declaration is a potential schema type for JSON data.

Parameters:
declaration - The declaration to determine whether it's a potential schema type for JSON data.
Returns:
Whether the specified declaration is a potential schema type for JSON data.

isPotentialXmlSchemaType

protected boolean isPotentialXmlSchemaType(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified declaration is a potential schema type.

Parameters:
declaration - The declaration to determine whether it's a potential schema type.
Returns:
Whether the specified declaration is a potential schema type.

isThrowable

protected boolean isThrowable(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified declaration is throwable.

Parameters:
declaration - The declaration to determine whether it is throwable.
Returns:
Whether the specified declaration is throwable.

isEndpointInterface

public boolean isEndpointInterface(com.sun.mirror.declaration.TypeDeclaration declaration)
A quick check to see if a declaration is an endpoint interface.


isJAXRSRootResource

public boolean isJAXRSRootResource(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified type is a JAX-RS root resource.

Parameters:
declaration - The declaration.
Returns:
Whether the specified type is a JAX-RS root resource.

isJAXRSSupport

public boolean isJAXRSSupport(com.sun.mirror.declaration.TypeDeclaration declaration)
Whether the specified type is a JAX-RS support class (resource and/or provider).

Parameters:
declaration - The declaration.
Returns:
Whether the specified type is a JAX-RS support class.

createTypeDefinition

public TypeDefinition createTypeDefinition(com.sun.mirror.declaration.ClassDeclaration declaration,
                                           EnunciateFreemarkerModel model)
Find the type definition for a class given the class's declaration, or null if the class is xml transient.

Parameters:
declaration - The declaration.
model - The model to use to create the type declaration.
Returns:
The type definition.

createRootElementDeclaration

public RootElementDeclaration createRootElementDeclaration(com.sun.mirror.declaration.ClassDeclaration declaration,
                                                           TypeDefinition typeDefinition)
Find or create the root element declaration for the specified type definition.

Parameters:
declaration - The class declaration
typeDefinition - The specified type definition.
Returns:
The root element declaration.

isRootSchemaElement

protected boolean isRootSchemaElement(com.sun.mirror.declaration.TypeDeclaration declaration)
A quick check to see if a declaration defines a root schema element.


getTransforms

public java.util.Collection<net.sf.jelly.apt.freemarker.FreemarkerTransform> getTransforms()
Overrides:
getTransforms in class net.sf.jelly.apt.freemarker.FreemarkerProcessor

validate

protected ValidationResult validate(EnunciateFreemarkerModel model,
                                    Validator validator)
Validates the model given a validator.

Parameters:
model - The model to validate.
validator - The validator.
Returns:
The results of the validation.

process

protected void process(freemarker.template.TemplateException e)
Overrides:
process in class net.sf.jelly.apt.freemarker.FreemarkerProcessor

process

protected void process(EnunciateException e)

process

protected void process(java.io.IOException e)
Overrides:
process in class net.sf.jelly.apt.freemarker.FreemarkerProcessor

process

protected void process(java.lang.RuntimeException e)

throwAnyErrors

public void throwAnyErrors()
                    throws EnunciateException,
                           java.io.IOException
Throws any errors that occurred during processing.

Throws:
EnunciateException
java.io.IOException

info

public void info(java.lang.String message,
                 java.lang.Object... formatArgs)
Handle an info-level message.

Parameters:
message - The info message.
formatArgs - The format args of the message.

debug

public void debug(java.lang.String message,
                  java.lang.Object... formatArgs)
Handle a debug-level message.

Parameters:
message - The debug message.
formatArgs - The format args of the message.

warn

public void warn(java.lang.String message,
                 java.lang.Object... formatArgs)
Handle a warn-level message.

Parameters:
message - The warn message.
formatArgs - The format args of the message.