JAX-WS 2.1.1 | Users Guide | Tools | JAXWS RI Extensions | Samples | JAXWS Community |
The
apt
tool provides a facility for programmatically processing the annotations added to Java by
JSR 175,
Metadata Facility for the Java
TM
Programming Language. In brief, JSR 175 allows programmers to declare new kinds of structured modifiers that can be associated with program elements, fields, methods, classes, etc.
The
apt
tool generates the portable artifacts used in JAX-WS services.
To run on JDK 6 follow these
instructions.
apt <apt and javac options> <source files>
The following table lists the
apt
options.
Option |
Description |
---|---|
|
Specifies where to find user class files and annotation processor factories |
|
Same as
|
|
Specifies where to place processor and
|
|
Specifies where to place processor generated source files |
|
Provide source compatibility with the specified release |
|
Version information |
|
Print a synopsis of standard options; use
|
|
Print a synopsis of non-standard options |
|
Pass <flag> directly to the runtime system |
|
Options to pass to annotation processors |
|
Do not compile source files to class files |
|
Print out a textual representation of the specified types |
|
Specify where to find annotation processor factories |
|
Name of
|
|
Generate all debugging info |
|
Generate no debugging info |
|
Generate only some debugging info |
|
Generate no warnings |
|
Output messages about what
|
|
Output source locations where deprecated APIs are used |
|
Specify where to find input source files |
|
Override location of bootstrap class files |
|
Override location of endorsed standards path |
|
Specify character encoding used by source files |
|
Generate class files for a specific virtual machine version |
It is important when using
apt
with JAX-WSto specify all of the JAR files in the distributed JAX-WS bundle in the classpath passed to
apt
. The
-sourcepath <path>
option must also be provided so that
apt
and the JAX-WS annotation processor can find all types referenced by a web service endpoint implementation class.
For more information on apt please refer to the
apt
documentation
here.
An Ant task for the
apt
tool is provided with JAX-WS 2.1.1 . The attributes and elements supported by the Ant task are listed below:
<apt verbose="true|false" classpath="classpath" destdir="directory for generated class files" sourcedestdir="directory for generated source files" nocompile="true|false" print="true|false" factorypath="<path>" factory="name of AnnotationProcessorFactory to use" xlistannotationtypes="true|false" xlistdeclarations="true|false" xprintaptrounds="true|false" xprintfactoryinfo="true|false" xclassesasdecls="true|false" debug="true|false" debuglevel="lines|vars|source" nowarn="true|false" deprecaption="true|false" bootclasspath="<path>" extdirs="<path>" endorseddirs="<path>" sourcepath="<path>" encoding="specify character encoding used by source files" target="generate class files for specific virtual machine version"> <option key="keyname" value="keyvalue"/> <source ... > ... </source> <classpath ... > ... </classpath> </apt>
Attribute |
Description |
Command line |
|
Output messages about what the compiler is doing |
|
|
Specify where to find user class files and annotation processor factories |
|
|
Specify where to place processor and
|
|
|
Specify where to place processor generated source files |
|
|
Do not compile source files to class files |
|
|
Print out a textual representation of the specified types |
|
|
Specify where to find annotation processor factories |
|
|
Name of the
|
|
|
List the found annotation types |
|
|
List specified and included declarations |
|
|
Print information about initial and recursive
|
|
|
Print information about which annotations a factory is asked to process |
|
|
Treat both class and source files as declarations to process |
|
|
Generate all debugging info |
|
|
Debug level: lines, vars, sources |
|
|
Generate no warnings |
|
|
Output source locations where deprecated APIs are used |
|
|
Override location of bootstrap class files |
|
|
Override location of installed extensions |
|
|
Override location of endorsed standards path |
|
|
Specify where to find input source files |
|
|
Specify character encoding used by source files |
|
|
Generate class files for a specific virtual machine version |
|
|
Specify options to pass to annotation processors |
|
The list of source files to be processed are specified via a nested
<source>
element. That is, a
path-like structure. The classpath attribute is a
path-like structure and can also be set via nested
<classpath>
elements. Before this task can be used, a
<taskdef>
element needs to be added to the project as given below:
<taskdef name="apt" classname="com.sun.tools.ws.ant.Apt">
<classpath refid="jaxws.classpath"/>
</taskdef>
where
jaxws.classpath
is a reference to a
path-like structure, defined elsewhere in the build environment, and contains the list of classes required by the JAX-WS tools.
<apt destdir="" sourcedestdir="" sourcepath="/builddir/build/BUILD/jaxws-ri/src"> <classpath refid="jaxws.classpath"/> <source dir="/builddir/build/BUILD/jaxws-ri/src" includes="*.java"/> </source> </apt>
The above example processes the Java source files in the
/builddir/build/BUILD/jaxws-ri/src
directory and generates the source and class files in
.
/builddir/build/BUILD/jaxws-ri/src
is directory used to search for source files for multiple
apt
rounds. The classpath is a reference to a
path-like structure
jaxws.classpath
, defined elsewhere in the build environment.
<apt debug="true" verbose="true" destdir="" sourcedestdir="" sourcepath="/builddir/build/BUILD/jaxws-ri/src"> <classpath refid="jaxws.classpath"/> <option key="r" value="/builddir/build/BUILD/jaxws-ri/build"/> <source dir="/builddir/build/BUILD/jaxws-ri/src"> <include name="**/server/*.java"/> </source> </apt>
The above example processes the Java source files in
/builddir/build/BUILD/jaxws-ri/src/**/server
, generates the source and class files in
, compiles with debug information on, prints a message about what the compiler is doing, and passes the
-Dr=/builddir/build/BUILD/jaxws-ri/build
option to the annotation processor(s).
/builddir/build/BUILD/jaxws-ri/src
is the directory used to search for source files for multiple
apt
rounds. The classpath is a reference to a
path-like structure
jaxws.classpath
, defined elsewhere in the build environment. This will also fork off the
apt
process using the default
java
executable.