org.codehaus.mojo.appfuse.mojo
Class PojoMojoBase

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.appfuse.mojo.MojoBase
          extended by org.codehaus.mojo.appfuse.mojo.PojoMojoBase
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
GenerateDaoMojo, GenerateHibernateContextMojo, GenerateHibernateDaoMojo, GenerateManagerContextMojo, GenerateManagerImplMojo, GenerateManagerMojo, GenerateModelMojo

public abstract class PojoMojoBase
extends MojoBase

This class will serve as a base class for all mojos that process java objects using freemarker and the hbm.xml file.

Version:
$Id: $
Author:
Scott Ryan

Field Summary
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
protected PojoMojoBase()
          Creates a new PojoMojoBase object.
 
Method Summary
 java.lang.String augmentFilePattern(java.lang.String inFilePattern)
          This method takes the ant based file pattern and adds the proper suffix onto it for the type of processing the mojo needs to do.
 java.lang.String buildOutputPattern(java.lang.String inDefaultOutputPattern, java.lang.String inOutputPatternPropertyKey, java.lang.String inPackageName)
          This method will build up the output pattern for a generated artifact.
 java.lang.String buildPackageName(java.lang.String inDefaultPackageExtension, java.lang.String inPackageExtensionPropertyKey)
          This method will create a full package name for an artifact based on the base package name and an extension and will return the full package name for the artifact.
 void execute()
          This method will run the database conversion to hbm file mojo task.
 java.util.List getListOfFilesToProcess()
          This method will use the file pattern or a default file pattern appended with a suffix specific to the mojo to locate all the files that need to be processed by the mojo.
abstract  java.lang.String getOutputPattern()
          Getter for the file output pattern to be used when generating output files.
 java.lang.String getTemplateHelperClassName()
          This class will locate the helper class to be used to provide additional support inside the template environment.
protected abstract  java.lang.String getTemplateName()
          Getter for property template name to be used in processing the mojo.
 java.lang.String locateTemplate(java.lang.String inDefaultTemplateName, java.lang.String inTemplatePropertyKey)
          This method will look in the mojo properties to see if the user passed in a new template name and if so pass that back otherwise it passes the default back to the caller.
 java.lang.String toString()
          toString methode: creates a String representation of the object
protected abstract  void validateProperties(java.util.Properties inProperties)
          This method is called before properties are sent to the exporter for processing.
 
Methods inherited from class org.codehaus.mojo.appfuse.mojo.MojoBase
getBasePackageName, getCopyOverWrite, getFilePattern, getModelDirectory, getModelPackageName, getMojoName, getOutputDirectory, getProcessingProperties, getSourceDirectory, setBasePackageName, setCopyOverWrite, setFilePattern, setModelDirectory, setMojoName, setOutputDirectory, setProcessingProperties, setSourceDirectory
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PojoMojoBase

protected PojoMojoBase()
Creates a new PojoMojoBase object.

Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException
This method will run the database conversion to hbm file mojo task.

Specified by:
execute in interface org.apache.maven.plugin.Mojo
Overrides:
execute in class MojoBase
Throws:
org.apache.maven.plugin.MojoExecutionException - Thrown if we fail to obtain an appfuse resource.

validateProperties

protected abstract void validateProperties(java.util.Properties inProperties)
This method is called before properties are sent to the exporter for processing. This gives the class a chance to review the properties that were passed in by the user and modify, delete or update them to match what is required by the particular mojo. These properties are passed in to the generator and are accessable within the processing templates. The new property list is handed back so the original one is still intact.

Parameters:
inProperties - The project properties that already have been populated.

getTemplateName

protected abstract java.lang.String getTemplateName()
Getter for property template name to be used in processing the mojo. An example might be appfusepojo/Pojo.ftl. By implementing this getter the mojo can use a unique name to indentify their template in the configuration file without intefereing with this generic method.

Returns:
The value of template name.

getOutputPattern

public abstract java.lang.String getOutputPattern()
Getter for the file output pattern to be used when generating output files. An example might be like com/appfuse/servicekit/manager/{class-name}Manager.java. By implementing this getter the mojo can use a unique name to indentify their template in the configuration file without intefereing with this generic method.

Returns:
The value of output pattern.

locateTemplate

public java.lang.String locateTemplate(java.lang.String inDefaultTemplateName,
                                       java.lang.String inTemplatePropertyKey)
This method will look in the mojo properties to see if the user passed in a new template name and if so pass that back otherwise it passes the default back to the caller.

Parameters:
inDefaultTemplateName - The name of the default template.
inTemplatePropertyKey - The key in the property map to look for a new template name possibly passed in by the user on the maven properties.
Returns:
The name of the template to use.

buildOutputPattern

public java.lang.String buildOutputPattern(java.lang.String inDefaultOutputPattern,
                                           java.lang.String inOutputPatternPropertyKey,
                                           java.lang.String inPackageName)
This method will build up the output pattern for a generated artifact. It will locate the output pattern and combine that with the package name to build up a location (dot notation) and then convert that location to a file location and pass that back to the caller.

Parameters:
inDefaultOutputPattern - The default output pattern for the artifact in question.
inOutputPatternPropertyKey - The property key to use to see if the user passed it in with the maven properties for the project.
inPackageName - The package name to prepend to the output pattern to construct the full location.
Returns:
The file location of the output for this set of artifacts.

buildPackageName

public java.lang.String buildPackageName(java.lang.String inDefaultPackageExtension,
                                         java.lang.String inPackageExtensionPropertyKey)
This method will create a full package name for an artifact based on the base package name and an extension and will return the full package name for the artifact.

Parameters:
inDefaultPackageExtension - The default package extension to use for this artifact.
inPackageExtensionPropertyKey - The key in the maven properties file where a user can override the default value.
Returns:
The full package name for the artifact.

getTemplateHelperClassName

public java.lang.String getTemplateHelperClassName()
This class will locate the helper class to be used to provide additional support inside the template environment. This clas has a default that can be overriden by the user but the class must always extend the appfuse base class.

Returns:
The name of the template helper class.

augmentFilePattern

public java.lang.String augmentFilePattern(java.lang.String inFilePattern)
This method takes the ant based file pattern and adds the proper suffix onto it for the type of processing the mojo needs to do. The default is to add hbm.xml to the end however if you need a different suffix or need to manipulate the pattern in some way you can overload this method.

Parameters:
inFilePattern - The initial file pattern requested for processing.
Returns:
An augmented file pattern with the type hbm.xml added to it.

getListOfFilesToProcess

public java.util.List getListOfFilesToProcess()
This method will use the file pattern or a default file pattern appended with a suffix specific to the mojo to locate all the files that need to be processed by the mojo.

Returns:
A list of fully qualified filename strings to be processed based on the file pattern and suffix.

toString

public java.lang.String toString()
toString methode: creates a String representation of the object

Overrides:
toString in class MojoBase
Returns:
the String representation


Copyright © 2006-2009. All Rights Reserved.