public class SiteStructureTool
extends java.lang.Object
implements com.sun.mirror.apt.AnnotationProcessor, com.sun.mirror.apt.AnnotationProcessorFactory
A tool for extracting and documenting information related to the site structure of a Stripes application. SiteStructureTool is an AnnotationProcessor (and it's own factory) for use with apt, the Annotation Processing Tool. It is capable of processing several of the annotations used with Stripes to extract information about what bean is bound to which URL, the set of events handled and the possible resolutions. This information can then be printed to the screen, or output to a file in either text or xml format.
The SiteStructureTool can be run through the command line, though it is somewhat awkward with a large number of files, or a large classpath - it's command line is extremely similar to javac. A command line might look like this:
apt -classpath $CLASSPATH -nocompile \ -factory net.sourceforge.stripes.tools.SiteStructureTool \ -Astripes.output.file=sitemap.txt \ -Astripes.output.format=text \ src/net/sourceforge/stripes/examples/bugzooky/web/*.java
SiteStructureTool modifies its behaviour based on two options. (Custom options are always passed to apt prefixed with -A). The first is stripes.output.file. This names the file into which the output will be written. If this option is omitted then the output is simply printed to the screen. The second option is stripes.output.format which controls (not surprisingly) the output format. Valid values are 'text' and 'xml'. If this value is omitted the default format is 'text' unless a filename is supplied which ends in '.xml', in which case xml output will be produced.
The easiest way to run the SiteStructureTool is with ant. Unfortunately the latest release of ant at the time of writing does not yet include an apt task. When it does, running apt through ant should become much simpler. Until then, you can run apt using an ant target like the example below:
<target name="apt" depends="compile"> <pathconvert property="cp" refid="build.class.path"/> <path id="srcfiles"> <fileset dir="${src.dir}" includes="**/*.java"/> </path> <pathconvert property="srcfiles" refid="srcfiles" pathsep=" "/> <exec executable="apt"> <arg line="-classpath ${cp} -nocompile"/> <arg line="-factory net.sourceforge.stripes.tools.SiteStructureTool"/> <arg line="-Astripes.output.file=sitemap.xml"/> <arg line="${srcfiles}"/> </exec> </target>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FILE_PARAM
Option name that controls the file to which output is written.
|
static java.lang.String |
FORMAT_PARAM
Option name that controls the output format of the annotation processor.
|
protected static java.util.regex.Pattern |
RETURN_PATTERN
Regular expression used to parse out return statements from a chunk of java source.
|
Constructor and Description |
---|
SiteStructureTool() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getOption(java.lang.String name)
For the named option to apt, returns the value of the option if it was supplied, or
null if the option was not supplied.
|
com.sun.mirror.apt.AnnotationProcessor |
getProcessorFor(java.util.Set<com.sun.mirror.declaration.AnnotationTypeDeclaration> set,
com.sun.mirror.apt.AnnotationProcessorEnvironment env)
AnnotationProcessorFactory interface method that returns the SiteStructure annotation
processor.
|
protected void |
printTextEvent(java.io.PrintStream out,
EventInfo event)
Prints out a single event mapping in text format.
|
protected void |
printTextFormat(java.io.PrintStream out)
Prints out the accumulated information in text format to the supplied print stream.
|
protected void |
printXmlEvent(java.io.PrintStream out,
EventInfo event) |
protected void |
printXmlFormat(java.io.PrintStream out)
Prints out the accumulated information in XML format.
|
void |
process()
AnnotationProcessor interface method that is invoked to perform the processing of the
annotations discovered.
|
protected void |
processHandlerAnnotations(java.util.Collection<com.sun.mirror.declaration.Declaration> declarations)
Responsible for iterating through the collection of declarations annotated with
either @DefaultHandler, @HandlesEvent or both.
|
protected void |
processUrlBindings(java.util.Collection<com.sun.mirror.declaration.Declaration> declarations)
Responsible for iterating through the collection of UrlBinding annotations and
adding information to the instance level map of class names to ActionBeanInfo objects.
|
java.util.Collection<java.lang.String> |
supportedAnnotationTypes()
AnnotationProcessorFactory interface method that returns the set of annotation class
names that are supported.
|
java.util.Collection<java.lang.String> |
supportedOptions()
AnnotationProcessorFactory interface method that returns the set of custom options
that are supported.
|
public static final java.lang.String FORMAT_PARAM
public static final java.lang.String FILE_PARAM
protected static final java.util.regex.Pattern RETURN_PATTERN
public java.util.Collection<java.lang.String> supportedOptions()
supportedOptions
in interface com.sun.mirror.apt.AnnotationProcessorFactory
public java.util.Collection<java.lang.String> supportedAnnotationTypes()
supportedAnnotationTypes
in interface com.sun.mirror.apt.AnnotationProcessorFactory
public com.sun.mirror.apt.AnnotationProcessor getProcessorFor(java.util.Set<com.sun.mirror.declaration.AnnotationTypeDeclaration> set, com.sun.mirror.apt.AnnotationProcessorEnvironment env)
getProcessorFor
in interface com.sun.mirror.apt.AnnotationProcessorFactory
public void process()
process
in interface com.sun.mirror.apt.AnnotationProcessor
protected java.lang.String getOption(java.lang.String name)
protected void processUrlBindings(java.util.Collection<com.sun.mirror.declaration.Declaration> declarations)
declarations
- a collection of Declarations annotated with UrlBinding.protected void processHandlerAnnotations(java.util.Collection<com.sun.mirror.declaration.Declaration> declarations)
declarations
- a collection of Declarations annotated with handler annotations.protected void printTextFormat(java.io.PrintStream out)
protected void printTextEvent(java.io.PrintStream out, EventInfo event)
protected void printXmlFormat(java.io.PrintStream out)
protected void printXmlEvent(java.io.PrintStream out, EventInfo event)
? Copyright 2005-2006, Stripes Development Team.