org.rythmengine.extension
Interface ISourceCodeEnhancer


public interface ISourceCodeEnhancer

Allow user application or more probably a framework plugin based on rythm to inject common import statements, render arguments and source code into generated java source code


Nested Class Summary
static class ISourceCodeEnhancer.INSTS
          This is used by RythmConfiguration and user application should not use this static member
 
Method Summary
 Map<String,?> getRenderArgDescriptions()
          Return implicit render args type information indexed by render arg name.
 List<String> imports()
          Return a list of import statement to be injected into the generated java source code.
 void setRenderArgs(ITemplate template)
          Set implicit render arg values to a template instance.
 String sourceCode()
          Return source code to be added to template class.
 

Method Detail

imports

List<String> imports()
Return a list of import statement to be injected into the generated java source code.

Note, only package declaration part needs to be put inside the Strings. the import directive is not required. E.g.


 List ls = new ArrayList();
 ls.put("models.*");
 ls.put("controllers.*);
 

This method is called by rythm when generating java source code out from a template souce code

Returns:
list of imports

sourceCode

String sourceCode()
Return source code to be added to template class. This method is called during code generation to inject customized source code into final generated template source. The string returned will be injected into the generated template source code class body directly

Returns:
the added source code

getRenderArgDescriptions

Map<String,?> getRenderArgDescriptions()
Return implicit render args type information indexed by render arg name. The type info could be either a Class instance or a String of the class name. E.g, if the implicit render args are


 Map descs = new HashMap();
 descs.put("_play", play.Play.class); // arg type with Class instance
 descs.put("request", "play.mvc.Request"); // arg type with class name
 

The method is called when code builder generating the java source out from the template source

Returns:
render arg types mapped by name

setRenderArgs

void setRenderArgs(ITemplate template)
Set implicit render arg values to a template instance. Usually inside this method, the implicit arguments to be set should be corresponding to the render args described in getRenderArgDescriptions() method. E.g.


 template.__setRenderArg("_play", new play.Play());
 template.__setRenderArg("request", play.mvc.Request.current());
 

This method is called before rythm engine start to execute a template instance

Parameters:
template -


Copyright © 2013. All Rights Reserved.