From 04dfafe19f0d3687d0f0b3e51d2d5bf3d19b58bf Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 07 Mar 2007 23:38:55 +0000
Subject: [PATCH] Enable AspectJ weaving for the new debug logging framework: - This commit does not allow for configuring the debug logger over protocol. It can only be configured on server startup using properties. - The settings specified during startup will remain in effect for the duration of the server. - All messages are printed to standard out. - Weaving could be turned off with the -DDEBUG_BUILD=false property when building the server. - By default, the debug logger is off on server startup. It could be enabled by using the -Dorg.opends.server.debug.enabled=true. - Debug targets may be defined with the -Dorg.opends.server.debug.target property. The syntax of this property can be found on the opends.dev.java.net documentation section. - Debug logging is turned on by default on unit tests and printed on test failure.  - Default debug target for unit tests could be changed by using the -Dorg.opends.test.debug.target property.

---
 opends/build.xml |   62 ++++++++++++++++++++++++++++---
 1 files changed, 56 insertions(+), 6 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index 13a470a..2d45b20 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -100,6 +100,10 @@
   <!-- Properties for the EMMA code coverage tool.                 -->
   <property name="emma.dir" location="${ext.dir}/emma/lib"          />
 
+  <!-- Properties for the AspectJ tools                            -->
+  <property name="aj.dir" location="${ext.dir}/aspectj"             />
+  <property name="aj.lib.dir" location="${aj.dir}/lib"              />
+
   <!-- Properties for the TestNG unit testing  tool.               -->
   <property name="testng.dir" location="${ext.dir}/testng"          />
   <property name="testng.lib.dir" location="${testng.dir}/lib"      />
@@ -183,12 +187,16 @@
       <format property="timestamp" pattern="yyyyMMddHHmmss" />
     </tstamp>
 
-    <condition property="DEBUG_BUILD" value="false">
+    <condition property="DEBUG_BUILD" value="true">
       <not>
         <isset property="DEBUG_BUILD" />
       </not>
     </condition>
 
+    <condition property="weave.enabled" value="true">
+      <equals arg1="${DEBUG_BUILD}" arg2="true" />
+    </condition>
+
     <condition property="MEM" value="128M">
       <not>
         <isset property="MEM" />
@@ -367,7 +375,7 @@
 
   <!-- Compile the Directory Server source files. -->
   <target name="cleancompile"
-       depends="cleaninit,compile,compilequicksetup,compilestatuspanel"
+       depends="cleaninit,weave,compilequicksetup,compilestatuspanel"
        description="Recompile the Directory Server source files.">
   </target>
 
@@ -380,7 +388,7 @@
 
     <javac srcdir="${src.dir}" destdir="${classes.dir}" optimize="true"
          excludes="**/package-info.java"
-         debug="on" debuglevel="lines,source" source="1.5" target="1.5"
+         debug="on" debuglevel="lines,vars,source" source="1.5" target="1.5"
          deprecation="true" fork="true" memoryInitialSize="${MEM}"
          memoryMaximumSize="${MEM}">
       <compilerarg value="-Xlint:all" />
@@ -393,8 +401,27 @@
     </javac>
   </target>
 
+  <target name="weave" if="weave.enabled" depends="compile">
+    <taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
+      <classpath>
+        <pathelement location="${aj.lib.dir}/aspectjtools.jar" />
+      </classpath>
+    </taskdef>
+
+    <iajc inpath="${classes.dir}" destdir="${classes.dir}"
+          debug="true" debuglevel="lines,source" source="1.5" target="1.5"
+          deprecation="true" fork="true" maxmem="${MEM}">
+      <classpath>
+        <fileset dir="${lib.dir}">
+          <include name="*.jar" />
+        </fileset>
+      </classpath>
+    </iajc>
+  </target>
+
+
   <!-- Compile the Quick Setup source files. -->
-  <target name="compilequicksetup" depends="buildtools,compile"
+  <target name="compilequicksetup" depends="buildtools,weave"
           description="Compile the Quick Setup source files.">
 
     <mkdir dir="${quicksetup.classes.dir}" />
@@ -780,7 +807,7 @@
 
 
   <!-- Prepare to execute the Directory Server TestNG unit tests. -->
-  <target name="testinit" depends="buildtools,compile"
+  <target name="testinit" depends="buildtools,weave"
          description="Prepare to execute the Directory Server TestNG unit tests.">
 
     <!-- If we are to perform coverage tests, then set that up. -->
@@ -994,6 +1021,19 @@
     <echo message="  -Dtest.failed=true"/>
     <echo message="      runs only the tests that failed last time"/>
     <echo message=""/>
+    <echo message="  -DDEBUG_BUILD=false" />
+    <echo message="      builds the server without the debug logging facility." />
+    <echo message="      No debug logging messages will be included on test failures." />
+    <echo message=""/>
+    <echo message="  -Dtest.debug.target=org.opends.server.core:level=verbose,category=data_access"/>
+    <echo message="      for example only include debug messages in the core"/>
+    <echo message="      package that are related to data access and at the" />
+    <echo message="      verbose level or higher. The syntax of this target" />
+    <echo message="      definition is the same as the org.opends.server.debug.target.x" />
+    <echo message="      property when starting OpenDS. " />
+    <echo message="      Default debug target:"/>
+    <echo message="      org.opends.server:level=verbose,category=caught|data|database_access|message|protocol" />
+    <echo message=""/>
     <echo message="  -Dtest.packages=org.opends.server.api"/>
     <echo message="      for example runs only the tests in the api package"/>
     <echo message="      For multiple packages, separate them with a ',' and "/>
@@ -1047,7 +1087,16 @@
       </not>
     </condition>
 
-    <!-- Cleanout the old reports.  Otherwise, the old testng-failed.xml 
+    <!-- This sets org.opends.test.debug.target if and only if its's not
+         alreadly set. -->
+    <condition property="org.opends.test.debug.target"
+               value="org.opends.server:level=verbose,category=caught|data|database_access|message|protocol">
+      <not>
+        <isset property="org.opends.test.debug.target" />
+      </not>
+    </condition>
+
+    <!-- Cleanout the old reports.  Otherwise, the old testng-failed.xml
          will hang around even if all of the tests pass. -->
     <delete>
       <fileset dir="${unittest.report.dir}" includes="*"/>
@@ -1084,6 +1133,7 @@
       <jvmarg value="-Demma.coverage.out.merge=false" />
       <jvmarg value="-Dorg.opends.server.BuildRoot=${basedir}" />
       <jvmarg value="-Dorg.opends.test.suppressOutput=${org.opends.test.suppressOutput}" />
+      <jvmarg value="-Dorg.opends.test.debug.target=${org.opends.test.debug.target}" />
       <jvmarg value="-Xms${MEM}" />
       <jvmarg value="-Xmx${MEM}" />
       <xmlfileset dir="${unittest.resource.dir}" includes="testng.xml" />

--
Gitblit v1.10.0