org.teatrove.tea.compiler
Class TemplateRepository

java.lang.Object
  extended by org.teatrove.tea.compiler.TemplateRepository

public class TemplateRepository
extends Object

Author:
Guy A. Molinari The TemplateRepository class manages metadata pertaining to the caller/callee hierarchy. This information is derived from the template class files and does not rely on tea source code. In order to reduce the repository spin-up time, this data is stored in a file named .templates.info and is updated as templates are successfully compiled. This file is located in the root directory where template classes are stored.

Nested Class Summary
 class TemplateRepository.TemplateInfo
          Template metadata container object.
 
Field Summary
static String REPOSITORY_FILENAME
           
 
Method Summary
 void createRepositoryFile()
          Persist the current state of the repository to disk.
static String formatTypeDesc(TypeDesc d)
          Type desc format beautifier
 TemplateRepository.TemplateInfo[] getCallers(String templateName)
          Retrieve the metadata for all templates that call the named template.
 String[] getCallersNeedingRecompile(String[] names, Compiler compiler)
          Retrieve the callers of a list of given template names where the source file can be located (delegated to the compiler), and the signature of given template(s) has changed since the last call to update.
static TemplateRepository getInstance()
          Get repository instance.
 TemplateRepository.TemplateInfo[] getMethodCallers(MethodDescriptor methodDesc)
          Retrieve the metadata for all templates that call the specified method.
 TemplateRepository.TemplateInfo getTemplateInfo(String templateName)
          Retrieve the metadata for a given template.
 TemplateRepository.TemplateInfo getTemplateInfoForClassFile(File f)
          Retrieves template metadata for a class file.
 TemplateRepository.TemplateInfo[] getTemplateInfos()
          Retrieve the metadata for all templates.
static void init(File rootClassesDir, String rootPackage)
          Initalizes and loads the repository.
static boolean isInitialized()
          Check to see if the repository was initialized (singleton instance create).
 void update(String[] templatesChanged)
          Synchronize the repository state with respect to the named template class file(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPOSITORY_FILENAME

public static final String REPOSITORY_FILENAME
See Also:
Constant Field Values
Method Detail

init

public static void init(File rootClassesDir,
                        String rootPackage)
Initalizes and loads the repository. Note: call this method instead of a constructor to initialize the singleton instance.

Parameters:
rootClassesDir - The root template classes directory.
rootPackage - The root package name (org.teatrove.teaservlet.template).

isInitialized

public static boolean isInitialized()
Check to see if the repository was initialized (singleton instance create).


getInstance

public static TemplateRepository getInstance()
Get repository instance. Accessor method (GoF Singleton pattern).


getTemplateInfoForClassFile

public TemplateRepository.TemplateInfo getTemplateInfoForClassFile(File f)
                                                            throws IOException
Retrieves template metadata for a class file.

Parameters:
f - The class file object.
Returns:
TemplateInfo The template metadata.
Throws:
IOException

createRepositoryFile

public void createRepositoryFile()
                          throws IOException
Persist the current state of the repository to disk.

Throws:
IOException

getCallers

public TemplateRepository.TemplateInfo[] getCallers(String templateName)
Retrieve the metadata for all templates that call the named template. The template name can be the short form, long form and use either '.' or '/' separators.

Parameters:
templateName - The name of the template.
Returns:
TemplateInfo[] The callers (consumers).

getMethodCallers

public TemplateRepository.TemplateInfo[] getMethodCallers(MethodDescriptor methodDesc)
Retrieve the metadata for all templates that call the specified method.

Parameters:
methodDesc - The method descriptor to find.
Returns:
TemplateInfo[] The callers (consumers).

getTemplateInfo

public TemplateRepository.TemplateInfo getTemplateInfo(String templateName)
Retrieve the metadata for a given template. The template name can be the short form, long form and use either '.' or '/' separators.

Parameters:
templateName - The name of the template.
Returns:
TemplateInfo The metadata.

getTemplateInfos

public TemplateRepository.TemplateInfo[] getTemplateInfos()
Retrieve the metadata for all templates.

Returns:
TemplateInfo[] The metadata.

getCallersNeedingRecompile

public String[] getCallersNeedingRecompile(String[] names,
                                           Compiler compiler)
                                    throws IOException
Retrieve the callers of a list of given template names where the source file can be located (delegated to the compiler), and the signature of given template(s) has changed since the last call to update. The class file(s) of the corresponding template names returned are removed.

Parameters:
names - The names of the templates to check.
compiler - The compiler instance.
Returns:
String[] The caller templates needing recompilation.
Throws:
IOException

update

public void update(String[] templatesChanged)
            throws IOException
Synchronize the repository state with respect to the named template class file(s). The dependency lists will be updated an the new repository file will be written to disk.

Parameters:
templatesChanged - The templates to update.
Throws:
IOException

formatTypeDesc

public static String formatTypeDesc(TypeDesc d)
Type desc format beautifier



Copyright © 1997-2012 TeaTrove.org. All Rights Reserved.