|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.stripes.tools.SiteStructureTool
public class SiteStructureTool
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>
Field Summary | |
---|---|
static String |
FILE_PARAM
Option name that controls the file to which output is written. |
static String |
FORMAT_PARAM
Option name that controls the output format of the annotation processor. |
protected static Pattern |
RETURN_PATTERN
Regular expression used to parse out return statements from a chunk of java source. |
Constructor Summary | |
---|---|
SiteStructureTool()
|
Method Summary | |
---|---|
protected String |
getOption(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. |
AnnotationProcessor |
getProcessorFor(Set<AnnotationTypeDeclaration> set,
AnnotationProcessorEnvironment env)
AnnotationProcessorFactory interface method that returns the SiteStructure annotation processor. |
protected void |
printTextEvent(PrintStream out,
EventInfo event)
Prints out a single event mapping in text format. |
protected void |
printTextFormat(PrintStream out)
Prints out the accumulated information in text format to the supplied print stream. |
protected void |
printXmlEvent(PrintStream out,
EventInfo event)
|
protected void |
printXmlFormat(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(Collection<Declaration> declarations)
Responsible for iterating through the collection of declarations annotated with either @DefaultHandler, @HandlesEvent or both. |
protected void |
processUrlBindings(Collection<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. |
Collection<String> |
supportedAnnotationTypes()
AnnotationProcessorFactory interface method that returns the set of annotation class names that are supported. |
Collection<String> |
supportedOptions()
AnnotationProcessorFactory interface method that returns the set of custom options that are supported. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FORMAT_PARAM
public static final String FILE_PARAM
protected static final Pattern RETURN_PATTERN
Constructor Detail |
---|
public SiteStructureTool()
Method Detail |
---|
public Collection<String> supportedOptions()
supportedOptions
in interface AnnotationProcessorFactory
public Collection<String> supportedAnnotationTypes()
supportedAnnotationTypes
in interface AnnotationProcessorFactory
public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> set, AnnotationProcessorEnvironment env)
getProcessorFor
in interface AnnotationProcessorFactory
public void process()
process
in interface AnnotationProcessor
protected String getOption(String name)
protected void processUrlBindings(Collection<Declaration> declarations)
declarations
- a collection of Declarations annotated with UrlBinding.protected void processHandlerAnnotations(Collection<Declaration> declarations)
declarations
- a collection of Declarations annotated with handler annotations.protected void printTextFormat(PrintStream out)
protected void printTextEvent(PrintStream out, EventInfo event)
protected void printXmlFormat(PrintStream out)
protected void printXmlEvent(PrintStream out, EventInfo event)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |