InfraRED ships with an Ant task that can be used for preparing an application. This is useful largely to use InfraRED with offline (compile-time) weaving. It is recommended that you try using this only after you have sucessfully used it with AspectWerkz load-time weaving as described in the installation page.
The usage of the ant task might look like:
<project ..> .. <taskdef name="infrared" classname="net.sf.infrared.tools.ant.InfraRedTask"> <classpath> <pathelement location="infrared-ant-XX.jar"/> </classpath> </taskdef> <infrared system="aw" offline="true" server="tomcat" agentConfiguration="infrared-agent.properties"> <war src="my.war" dest="my.instrumented.war"> <include name="WEB-INF/classes/**"/> <exclude name="WEB-INF/classes/do/not/instrument/**"/> </war> <ear src="my.ear" dest="my.instrumented.ear"> <module name="ejb-module" type="ejb"> <include name="**/*.class"/> <exclude name="do/not/instrument/**"/> </module> <module name="web-module" type="war"> <include name="WEB-INF/classes/**"/> <exclude name="WEB-INF/classes/do/not/instrument/**"/> </module> </ear> <aspectpath> <pathelement location="${myaspects.dir}"/> </aspectpath> <extraclasspath> <pathelement location="${j2ee.jar}"/> </extraclasspath> </infrared> .. </project>
The task supports the following configuration attributes:
Attribue | Description | Default Value |
---|---|---|
system | aj|aw|aspectwerkz|aspectj. Specifies what aspect system to use. | aspectwerkz |
offline | true|false. Specifies whether aspects should be weaved into the classes prior to deployment or at load-time. | true |
server | tomcat|jboss|weblogic. Specifies which server the application is to be deployed on. Mandatory attribute. | - |
agentConfiguration | The location of the properties file that would be used to configure InfraRED. The name of this file should be infrared-agent.properties. Mandatory attribute. | - |
applicationName | The name of the application. Is needed only when server is Jboss | unknown-app |
applicationPort | The port of the application. Is needed only when server is Jboss. | 0 |
The ant task can take additional inputs using nested war, ear,
aspectpath
and extraclasspath
tags. These are described in the
subsequent sections.
The ant task can take nested war
and ear
tags which
specifies the applications to instrument. Their attributes are desribed below.
<war>
tag specifies a WAR web application. It can take
nested includes
and excludes
tags which specify
what portion of the war needs instrumentation. If neither
includes
or excludes
is specified nothing gets
instrumented. Attributes of the war
tag are
described below:
Attribue | Description | Default Value |
---|---|---|
src | Specifies the source of the war application. This can be file or a directory (exploded wars).Mandatory attribute. | - |
dest | Specifies the destination of the instrumented war application. If 'src' was an exploded war, the output would be an exploded war, else it would be a compressed war file. Mandatory attribute. | - |
<war src="my.war" dest="my.instrumented.war"> <include name="WEB-INF/classes/**"/> <exclude name="WEB-INF/classes/do/not/instrument/**"/> <include name="WEB-INF/lib/*.jar"/> <exclude name="WEB-INF/lib/log4j*.jar"/> </war>
<ear>
tag specifies an EAR application.
It can take nested <module>
tags which specify
which portions of the archive should be instrumented.
If no module
s are specified nothing gets
instrumented. Attributes of the ear
tag are
described below:
Attribue | Description | Default Value |
---|---|---|
src | Specifies the source of the ear application. This can be file or a directory (exploded wars).Mandatory attribute. | - |
dest | Specifies the destination of the instrumented ear application. If 'src' was an exploded ear, the output would be an exploded ear, else it would be a compressed war file. Mandatory attribute. | - |
The <module>
tag identifies a module with an ear,
and is very similar to <war>
tag
name
attribute instead of src
and dest
attributes which
<war>
has. The name
attribute identifies
the name of the module within an ear. <module>
tag
also supports a type
attribute, the legal values of which are
ejb, java, war, classes
and jar
.
Attribue | Description | Default Value |
---|---|---|
name | Specifies the name of the module within an ear. Mandatory attribute. | - |
type | ejb|java|war|classes|jar. Specifies the type of the module. ejb = ejb module java = java module war = web module classes = directory of classes jar = a jar file Mandatory attribute. | - |
<war>
, you can provide nested
includes
and excludes
tags which specify
what portion of a moudle needs instrumentation
<ear src="my.ear" dest="my.instrumented.ear"> <module name="ejb-module" type="ejb"> <include name="**/*.class"/> <exclude name="do/not/instrument/**"/> </module> <module name="web-module" type="war"> <include name="WEB-INF/classes/**"/> <exclude name="WEB-INF/classes/do/not/instrument/**"/> </module> <module name="APP-INF/classes" type="classes"> <include name="**/*.class"/> </module> </war>
Aspects are specified using the <aspectpath>
tag.
This is a regular Ant <path>
tag.
This path should refer to the compiled aspect classes. When using AspectWerkz
system, you might need to have a META-INF/aop.xml file also in this path.
The aspect classes specified by this path would be copied into the appropriate
location within the application.
Often you might needs some classes that is needed for compilation, but are not
packaged withing the application itself - for example, the jars containing
J2EE classes. These needs to be specified using the
<extraclasspath>
tag. The classes in this path will be
used for aspect compilation, but will not be copied
into the application.
The aspects that are shipped with InfraRED are packaged in
INFRARED_HOME/infrared-agent-all-servlet-2.4.1.BETA.jar. If you need offline process you
application to using these, add them
as part of the <extraclasspath>
. We dont need to copy these
into the application because they are available in the server's classpath.
The Ant task uncompresses your application archive into a working
directory, and deletes this directory when the task finishes execution. Sometimes
you might want to inspect this directory to debug issues you might run into with the Ant
task. In that case, enabling the system propery infrared.dont.clean
preserves the working directory.
After the Infrared integrated ear/war is created, the following steps need to be done before you start the server and deploy the applicaton.
<local-tx-datasource>
<jndi-name>jndi-name</jndi-name>
<connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
<driver-class>com.p6spy.engine.spy.P6SpyDriver</driver-class>
<user-name>user-name</user-name>
<password>pswd</password>
<exception-sorter-class-name> fully-qualified-class-name</exception-sorter-class-name>
</local-tx-datasource>