com.edugility.jpa.maven.plugin
Class AbstractJPAMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.edugility.jpa.maven.plugin.AbstractJPAMojo
All Implemented Interfaces:
ContextEnabled, Mojo
Direct Known Subclasses:
ListEntityClassnamesMojo

public abstract class AbstractJPAMojo
extends AbstractMojo

An AbstractMojo that provides support for scanning a set of URLs and reporting back on the annotated classnames found there.

Since:
1.0-SNAPSHOT
Author:
Laird Nelson

Field Summary
private  AnnotationDB db
          The AnnotationDB that will be cloned for use by this AbstractJPAMojo.
private  org.apache.maven.project.MavenProject project
          The MavenProject usually injected by the Maven runtime.
private  URLFilter urlFilter
          A URLFilter that will be used to construct the Set of URLs that will be scanned by this AbstractJPAMojo.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
protected AbstractJPAMojo()
          Constructs a new AbstractJPAMojo.
 
Method Summary
 AnnotationDB cloneAnnotationDB()
          Returns a clone of this AbstractJPAMojo's associated AnnotationDB.
protected  AnnotationDB createAnnotationDB()
          Creates a new AnnotationDB in the (common) case where a user has not supplied this AbstractJPAMojo with a pre-configured AnnotationDB.
 org.apache.maven.project.MavenProject getProject()
          Returns the MavenProject that Maven customarily injects into this mojo, or null if no such MavenProject has been set.
 URLFilter getURLFilter()
          Returns this AbstractJPAMojo's associated URLFilter, or null if no such URLFilter exists.
private  AnnotationDB scan(AnnotationDB db, Set<URL> urls)
          Scans the supplied Set of URLs and as a convenience returns the supplied AnnotationDB that contains the scanned annotation information.
protected  AnnotationDB scan(Set<URL> urls)
          Scans the supplied Set of URLs and returns the AnnotationDB that contains the scanned annotation information.
 void setAnnotationDB(AnnotationDB db)
          Sets the AnnotationDB that will be used by this AbstractJPAMojo's cloneAnnotationDB() method.
 void setProject(org.apache.maven.project.MavenProject project)
          Installs the MavenProject for use by this mojo during its run.
 void setURLFilter(URLFilter filter)
          Sets this AbstractJPAMojo's associated URLFilter.
 
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, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute
 

Field Detail

project

private org.apache.maven.project.MavenProject project
The MavenProject usually injected by the Maven runtime. Used for the return value of its getTestClasspathElements() method and its associated Build's getTestOutputDirectory() method. This field may be null when this AbstractJPAMojo is not configured by Maven.

See Also:
Guide to Configuring Plug-ins
Plugin Parameter
default-value="${project}" property="project"
Read-Only Plugin Parameter
Required Plugin Parameter

db

private AnnotationDB db
The AnnotationDB that will be cloned for use by this AbstractJPAMojo. This field may be null at any point, and may be populated by either Maven, the setAnnotationDB(AnnotationDB) method or the createAnnotationDB() method.

See Also:
cloneAnnotationDB(), createAnnotationDB(), setAnnotationDB(AnnotationDB), Guide to Configuring Plug-ins
Plugin Parameter
alias="db" property="annotationDB"

urlFilter

private URLFilter urlFilter
A URLFilter that will be used to construct the Set of URLs that will be scanned by this AbstractJPAMojo. This field may be null at any point and may be populated by either Maven or the setURLFilter(URLFilter) method.

See Also:
getURLFilter(), setURLFilter(URLFilter), Guide to Configuring Plug-ins
Plugin Parameter
property="URLFilter"
Constructor Detail

AbstractJPAMojo

protected AbstractJPAMojo()
Constructs a new AbstractJPAMojo. No configuration automatic or otherwise will have taken place as a result of calling this constructor.

Method Detail

createAnnotationDB

protected AnnotationDB createAnnotationDB()
Creates a new AnnotationDB in the (common) case where a user has not supplied this AbstractJPAMojo with a pre-configured AnnotationDB.

This method never returns null. Subclasses overriding this method must ensure that their overridden implementation never returns null.

Returns:
a new AnnotationDB; never null
See Also:
AnnotationDB, AnnotationDB

getURLFilter

public URLFilter getURLFilter()
Returns this AbstractJPAMojo's associated URLFilter, or null if no such URLFilter exists.

This method may return null.

Returns:
the URLFilter used by this AbstractJPAMojo, or null
See Also:
setURLFilter(URLFilter), URLFilter

setURLFilter

public void setURLFilter(URLFilter filter)
Sets this AbstractJPAMojo's associated URLFilter. null is permitted as a parameter value.

Parameters:
filter - the URLFilter to set; may be null
See Also:
getURLFilter(), URLFilter

getProject

public org.apache.maven.project.MavenProject getProject()
Returns the MavenProject that Maven customarily injects into this mojo, or null if no such MavenProject has been set.

This method may return null.

Returns:
the MavenProject associated with this mojo, or null

setProject

public void setProject(org.apache.maven.project.MavenProject project)
Installs the MavenProject for use by this mojo during its run.

Parameters:
project - the MavenProject to use; may be null

cloneAnnotationDB

public final AnnotationDB cloneAnnotationDB()
Returns a clone of this AbstractJPAMojo's associated AnnotationDB.

A clone is returned because AnnotationDB retains state after scanning, and Maven plugins have no contractually defined lifecycle semantics. Consequently it is unknown how long-lived this AbstractJPAMojo's db reference might be.

This method may return null.

Returns:
a clone of this AbstractJPAMojo's associated AnnotationDB, or null if no such AnnotationDB could be cloned
See Also:
setAnnotationDB(AnnotationDB), AnnotationDB, AnnotationDB.clone(), AnnotationDB, AnnotationDB.annotationIndex, AnnotationDB.classIndex

setAnnotationDB

public void setAnnotationDB(AnnotationDB db)
Sets the AnnotationDB that will be used by this AbstractJPAMojo's cloneAnnotationDB() method. null is permitted as a parameter value.

Parameters:
db - the AnnotationDB to set; may be null
See Also:
cloneAnnotationDB(), AnnotationDB

scan

protected final AnnotationDB scan(Set<URL> urls)
                           throws IOException
Scans the supplied Set of URLs and returns the AnnotationDB that contains the scanned annotation information.

This method may return null in exceptional circumstances.

Parameters:
urls - the Set of URLs to scan; if null, then no scanning operation will take place
Returns:
the AnnotationDB that was used to perform the scan, or null if no AnnotationDB could be found
Throws:
IOException - if an error occurs during scanning
See Also:
cloneAnnotationDB(), AnnotationDB.scanArchives(URL[])

scan

private final AnnotationDB scan(AnnotationDB db,
                                Set<URL> urls)
                         throws IOException
Scans the supplied Set of URLs and as a convenience returns the supplied AnnotationDB that contains the scanned annotation information.

This method may return null if the supplied db is null.

Parameters:
db - the AnnotationDB used to perform the scan; if null then no scanning operation will take place
urls - the Set of URLs to scan; if null, then no scanning operation will take place
Returns:
the db parameter
Throws:
IOException - if an error occurs during scanning
See Also:
AnnotationDB.scanArchives(URL[])


Copyright © 2011-2013 Laird Nelson. All Rights Reserved.