[jboss-cvs] JBossAS SVN: r63065 - in projects/aop/trunk/aop/docs/examples: logging and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 15 19:22:43 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-05-15 19:22:43 -0400 (Tue, 15 May 2007)
New Revision: 63065

Added:
   projects/aop/trunk/aop/docs/examples/Non-standard examples.txt
   projects/aop/trunk/aop/docs/examples/logging/
   projects/aop/trunk/aop/docs/examples/logging/Driver.java
   projects/aop/trunk/aop/docs/examples/logging/POJO.java
   projects/aop/trunk/aop/docs/examples/logging/SimpleInterceptor.java
   projects/aop/trunk/aop/docs/examples/logging/build.xml
   projects/aop/trunk/aop/docs/examples/logging/jboss-aop.xml
   projects/aop/trunk/aop/docs/examples/logging/log4j.properties
   projects/aop/trunk/aop/docs/examples/logging/logging.html
Log:
[JBAOP-396] Example describing integration with JBoss logging

Added: projects/aop/trunk/aop/docs/examples/Non-standard examples.txt
===================================================================
--- projects/aop/trunk/aop/docs/examples/Non-standard examples.txt	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/Non-standard examples.txt	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,48 @@
+R Needs to be retroed (JDK 5 targets built and run with JDK 5; JDK 1.4 targets with compiled with 5, run with 1.4 [handled by script])
+N Normal (JDK 5 target
+
+R after-throwing
+N all
+R annotated-aspects
+R annotated-cflow
+R annotated-composition
+R annotated-declare
+R annotated-dynamic-cflow
+annotated-injboss - Complex needs own packaging
+R annotated-interceptors
+R annotated-introduction
+R annotated-parameters
+R annotated-precedence
+R annotated-typedef
+R annotation
+annotation14 - Should we get rid of this?
+R annotation-introductions - Rewritten to use JDK 5 annotations
+N aspect
+N beanstyleconf
+R beforeafter
+N caller
+N cflow
+N composition
+N constructor-execution
+N declare
+N dynamic_cflow
+N dynamic-aop
+N field-execution
+N implements
+injboss - Complex needs own packaging
+N instanceof
+N introductions
+N ioc_with_has
+metadata - uses annotationc
+N method-execution
+R overloaded-advices
+N packaging
+N precedence
+R return-types
+N stacks
+N typedefs
+
+
+REVISIT 
+annotated-declare and declare, are subtler than the others
+annotation14 should be merged with annotation
\ No newline at end of file

Added: projects/aop/trunk/aop/docs/examples/logging/Driver.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/Driver.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/Driver.java	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,33 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+
+public class Driver
+{
+   public static void main(String[] args)
+   {
+      POJO pojo = new POJO();
+      System.out.println("--- pojo.notwoven(); ---");
+      pojo.notwoven();
+      System.out.println("--- pojo.boundMethod(); ---");
+      pojo.boundMethod();
+   }
+}

Added: projects/aop/trunk/aop/docs/examples/logging/POJO.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/POJO.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/POJO.java	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+public class POJO
+{
+   public void notwoven() 
+   {
+      System.out.println("notwoven()");
+   }
+
+   public void boundMethod()
+   {
+      System.out.println("boundMethod");
+   }
+}
+
+
+

Added: projects/aop/trunk/aop/docs/examples/logging/SimpleInterceptor.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/SimpleInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/SimpleInterceptor.java	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.advice.Interceptor;
+
+/**
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 37406 $
+ */
+public class SimpleInterceptor implements Interceptor
+{
+   public String getName() { return "SimpleInterceptor"; }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      try
+      {
+         System.out.println("<<< Entering SimpleInterceptor");
+         return invocation.invokeNext();
+      }
+      finally
+      {
+         System.out.println(">>> Leaving SimpleInterceptor");
+      }
+   }
+}

Added: projects/aop/trunk/aop/docs/examples/logging/build.xml
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/build.xml	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/build.xml	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project default="usage_" name="JBoss/AOP">
+   <import file="../examples-build.xml"/>
+	
+   <target name="usage_">
+      <echo>Run one of the following targets (use JDK 5):</echo>
+      <echo> ant run.loadtime.50.nologging            Run with loadtime weaving and no logging</echo>
+      <echo> ant run.loadtime.50.system.out.logging   Run with loadtime weaving and logging via System.out</echo>
+      <echo> ant run.loadtime.50.log4j.logging        Run with loadtime weaving and logging via log4j</echo>
+      <echo> ant run.aopc.50.nologging                Run with compile-time weaving and no logging</echo>
+      <echo> ant run.aopc.50.system.out.logging       Run with compile-time weaving and logging via System.out</echo>
+      <echo> ant run.aopc.50.log4j.logging            Run with compile-time weaving and logging via log4j</echo>
+   </target>
+   
+   <target name="run.loadtime.50.nologging" depends="_compile50">
+      <!-- 
+         We exclude log4j.jar and jboss-logging-log4j.jar, which does not make a difference
+         since we do not use logging anyway
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+            <exclude name="log4j.jar"/>
+            <exclude name="jboss-logging-log4j.jar"/>
+         </fileset>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+   
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Include this for clarity, the default is false -->
+         <sysproperty key="jboss.aop.verbose" value="false"/>
+         <jvmarg value="-javaagent:${aop50jar}"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+
+   <target name="run.loadtime.50.system.out.logging" depends="_compile50">
+      <!-- 
+         We exclude log4j.jar and jboss-logging-log4j.jar, so when we turn on logging 
+         we will just write to System.out
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+            <exclude name="log4j.jar"/>
+            <exclude name="jboss-logging-log4j.jar"/>
+         </fileset>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+   
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn logging on -->
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <jvmarg value="-javaagent:${aop50jar}"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+
+   <target name="run.loadtime.50.log4j.logging" depends="_compile50">
+      <!-- 
+         We include log4j.jar and jboss-logging-log4j.jar, so when we turn on logging the 
+         we will use log4j configured with a log4j.properties file
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+         </fileset>
+         <!-- We need a log4j.properties on the classpath -->
+         <fileset file="log4j.properties"/>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+   
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn logging on -->
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <jvmarg value="-javaagent:${aop50jar}"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+
+   <target name="aopc.no.logging" depends="_compile50">
+      <!-- 
+         We exclude log4j.jar and jboss-logging-log4j.jar, which does not make a difference
+         since we do not use logging anyway
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+            <exclude name="log4j.jar"/>
+            <exclude name="jboss-logging-log4j.jar"/>
+         </fileset>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+      <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop.classpath"/>
+   
+      <aopc compilerclasspathref="run.classpath" classpathref="run.classpath">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Include this for clarity, the default is false -->
+         <sysproperty key="jboss.aop.verbose" value="false"/>
+         <classpath path="."/>
+         <src path="."/>
+         <aoppath path="jboss-aop.xml"/>
+      </aopc>   
+   </target>  
+   
+   <target name="run.aopc.50.nologging" depends="aopc.no.logging">
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+   
+   <target name="aopc.system.out.logging" depends="_compile50">
+      <!-- 
+         We exclude log4j.jar and jboss-logging-log4j.jar, so when we turn on logging 
+         we will just write to System.out
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+            <exclude name="log4j.jar"/>
+            <exclude name="jboss-logging-log4j.jar"/>
+         </fileset>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+      <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop.classpath"/>
+   
+      <aopc compilerclasspathref="run.classpath" classpathref="run.classpath">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn on logging -->  
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <classpath path="."/>
+         <src path="."/>
+         <aoppath path="jboss-aop.xml"/>
+      </aopc>
+   </target>
+  
+   <target name="run.aopc.50.system.out.logging" depends="aopc.system.out.logging">
+   
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn on logging although nothing is really being woven at runtime -->  
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+
+   <target name="aopc.log4j.logging" depends="_compile50">
+      <!-- 
+         We include log4j.jar and jboss-logging-log4j.jar, so when we turn on logging the 
+         we will use log4j configured with a log4j.properties file
+      -->
+      <path id="aop.classpath">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+         </fileset>
+         <!-- We need a log4j.properties on the classpath -->
+         <fileset file="log4j.properties"/>
+      </path>
+      <path id="run.classpath">
+         <path refid="aop.classpath"/>
+         <pathelement location="."/>
+      </path>
+      <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop.classpath"/>
+   
+      <aopc compilerclasspathref="run.classpath" classpathref="run.classpath">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn on logging -->  
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <classpath path="."/>
+         <src path="."/>
+         <aoppath path="jboss-aop.xml"/>
+      </aopc>
+   </target>
+
+   <target name="run.aopc.50.log4j.logging" depends="aopc.log4j.logging">
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <!-- Turn on logging although nothing is really being woven at runtime -->  
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <classpath refid="run.classpath"/>
+      </java>
+   </target>
+
+</project>
+

Added: projects/aop/trunk/aop/docs/examples/logging/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/jboss-aop.xml	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <bind pointcut="execution(public void POJO->boundMethod())">
+       <interceptor class="SimpleInterceptor"/>
+   </bind>
+</aop>

Added: projects/aop/trunk/aop/docs/examples/logging/log4j.properties
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/log4j.properties	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/log4j.properties	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,7 @@
+# Configure logging for testing
+
+log4j.rootLogger=DEBUG, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p %c - %m%n

Added: projects/aop/trunk/aop/docs/examples/logging/logging.html
===================================================================
--- projects/aop/trunk/aop/docs/examples/logging/logging.html	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/logging/logging.html	2007-05-15 23:22:43 UTC (rev 63065)
@@ -0,0 +1,267 @@
+<html>
+<body>
+<p>
+<h2>Logging</h2>
+
+</p><p>
+<h3>Overview</h3>
+
+<p>JBoss AOP allows you to view important information during the weaving process. We will see how to turn logging on, 
+and have a look at how once turned on we can choose log4j or System.out as the underlying logging mechanism. The System.out 
+logging meschanism will print everything regardless of logging level, while the log4j mechanism allows for more 
+control of which classes you want to be output. If using log4j, the classes in the <tt>org.jboss.aop</tt> package and
+sub-packages are where the logging is done.</p> 
+
+<p>All the examples require <tt>jboss-logging-spi.jar</tt> to be on the classpath, whether run without logging, or with 
+System.out logging or log4j logging. We will see later how, once logging is turned on, the inclusion of 
+<tt>jboss-logging-log4j.jar</tt> and <tt>log4j.jar</tt> enable the log4j logging mechanism. When run in the JBoss 
+Application server, both <tt>jboss-logging-log4j.jar</tt> and <tt>log4j.jar</tt> will be available, so if logging is enabled
+it will happen via log4j.</p>
+
+<p>All the examples in this lesson use JDK 5, but hopefully by now you have the knowledge to set this up using JDK 1.4!</p>
+
+<h3>Loadtime weaving</h3>
+<p>With loadtime weaving, classes are woven while the class is first loaded, so to see the logging of the weaving process we need 
+to turn on logging when the class is being loaded. We turn this on by passing in the value <tt>true</tt> for the <tt>jboss.aop.verbose</tt> 
+system property when running the application with the classloader hooks. The default value (i.e. if not passed in) is <tt>false</tt>.</p>
+
+<h4>Loadtime weaving with no logging</h4>
+<p>For this example, we explicitly pass in
+<pre>
+&lt;java ...&gt;
+   ...
+     &lt;!-- Include this for clarity, the default is false --&gt;
+     &lt;sysproperty key="jboss.aop.verbose" value="false"/%gt;
+   ...     
+&lt;/java&gt;
+</pre>
+when running the application, so we have turned off logging. If left out the result would have been exactly the same, it is 
+just there for clarity.</p>
+<p>To run the example with loadtime weaving and no logging turned on, you can run</P>
+<pre>
+$ ant  run.loadtime.50.nologging
+</pre>
+<p>This will run the application with no logging:</p>
+<pre>
+...
+run.loadtime.50.nologging:
+     [java] --- pojo.notwoven(); ---
+     [java] notwoven()
+     [java] --- pojo.boundMethod(); ---
+     [java] <<< Entering SimpleInterceptor
+     [java] boundMethod
+     [java] >>> Leaving SimpleInterceptor
+</pre>
+
+<h4>Loadtime weaving with Syetem.out logging</h4>
+<p>For this example we pass in
+<pre>
+&lt;java ...&gt;
+   ...
+     &lt;!-- Include this for clarity, the default is false --&gt;
+     &lt;sysproperty key="jboss.aop.verbose" value="true"/%gt;
+   ...     
+&lt;/java&gt;
+</pre>
+when running the application, so logging is now turned on. In this case neither <tt>jboss-logging-log4j.jar</tt> nor 
+<tt>log4j.jar</tt> are on the classpath, so JBoss AOP will default to use the System.out logging mechanism.</p>
+
+<p>To run the example with System.out logging, you  should run:</p>
+<pre>
+$ ant  run.loadtime.50.system.out.logging
+</pre>
+<p> This will generate quite a lot of output during the 'run' stage, the most important of which are outlined here:</p>
+<pre>
+run.loadtime.50.system.out.logging:
+...
+     [java] [aop-debug] org.jboss.aop.instrument.Instrumentor trying to transform POJO
+     [java] [aop-debug] org.jboss.aop.instrument.CallerTransformer There are no caller pointcuts!
+     [java] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtMethod at ae60ead5[public notwoven ()V] matches no pointcuts
+     [java] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtMethod at 7c6e6140[public boundMethod ()V] matches pointcut: execution(public void POJO->boundMethod())
+     [java] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtConstructor at 64c34e[public POJO ()V] matches no pointcuts
+     [java] [aop-debug] org.jboss.aop.instrument.Instrumentor was POJO converted: true
+...
+     [java] --- pojo.notwoven(); ---
+     [java] notwoven()
+     [java] --- pojo.boundMethod(); ---
+...
+     [java] <<< Entering SimpleInterceptor
+     [java] boundMethod
+     [java] >>> Leaving SimpleInterceptor
+</pre>
+<p>We can see that the weaver attempts to transform <tt>POJO</tt>, and finds that <tt>POJO.boundMethod()</tt> matches the single pointcut we have
+in out jboss-aop.xml: <tt>execution(public void POJO->boundMethod()</tt>. The other methods in <tt>POJO</tt> do not match this pointcut.
+</p>
+
+<h4>Loadtime weaving with log4j logging</h4>
+<p>For this example, again, we pass in
+<pre>
+&lt;java ...&gt;
+   ...
+     &lt;!-- Include this for clarity, the default is false --&gt;
+     &lt;sysproperty key="jboss.aop.verbose" value="true"/%gt;
+   ...     
+&lt;/java&gt;
+</pre>
+when running the application, so logging is now turned on. In this case both <tt>jboss-logging-log4j.jar</tt> and 
+<tt>log4j.jar</tt> are on the classpath, so JBoss AOP will now use the log4j logging mechanism. To get any meaningful
+output, you need a <a href="log4j.properties">log4j.properties</a> on the classpath, with which you 
+can get more fine-grained control of logging levels for different classes during the JBoss AOP weaving process, as
+well as control of the output formats etc. See the Apache log4j documentation for more information about log4j.</p>
+<p>To run the example with log4j logging, run:</p>
+<pre>
+$ ant  run.loadtime.50.log4j.logging
+</pre>
+<p>Again, this will generate quite a lot of logging for each woven class during the weaving process, the most important bits show below:</p>
+<pre>
+run.loadtime.50.log4j.logging:
+...
+     [java] 2007-05-15 23:38:23,625 DEBUG org.jboss.aop.instrument.Instrumentor - trying to transform POJO
+     [java] 2007-05-15 23:38:23,625 DEBUG org.jboss.aop.instrument.CallerTransformer - There are no caller pointcuts!
+     [java] 2007-05-15 23:38:23,625 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtMethod at ae60ead5[public notwoven ()V] matches no pointcuts
+     [java] 2007-05-15 23:38:23,640 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtMethod at 7c6e6140[public boundMethod ()V] matches pointcut: execution(public void POJO->boundMethod())
+     [java] 2007-05-15 23:38:24,015 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtConstructor at 60991f[public POJO ()V] matches no pointcuts
+     [java] 2007-05-15 23:38:24,015 DEBUG org.jboss.aop.instrument.Instrumentor - was POJO converted: true
+...
+     [java] --- pojo.notwoven(); ---
+     [java] notwoven()
+     [java] --- pojo.boundMethod(); ---
+...
+     [java] <<< Entering SimpleInterceptor
+     [java] boundMethod
+     [java] >>> Leaving SimpleInterceptor
+
+BUILD SUCCESSFUL
+Total time: 3 seconds
+</pre>
+<p>Yet again we see that the <tt>POJO</tt> class was woven since the pointcut <tt>execution(public void POJO->boundMethod()</tt>
+matched our method <tt>POJO.boundMethod()</tt> </p>
+
+
+<h3>Compile-time weaving</h3>
+<p>With compile-time weaving, we execute the <tt>aopc</tt> task to weave the classe, so to see the logging of the weaving process 
+we need to turn on logging when the class is being aopc'ed. We turn this on by passing in the value <tt>true</tt> for the <tt>jboss.aop.verbose</tt> 
+system property when running the aopc post-compiler. The default value (i.e. if not passed in) is false.</p>
+
+<h4>Compile-time logging with no logging</h4>
+<p>For this example we pass in:
+<pre>
+&lt;aopc ...&gt;
+     &lt;!-- Include this for clarity, the default is false --&gt;
+     &lt;sysproperty key="jboss.aop.verbose" value="false"/%gt;
+&lt;/aopc&gt;
+</pre>
+when aopc'ing, so we have turned off logging. If left out the result would have been exactly the same, it is 
+just there for clarity.</p>
+<p>To run the example:</p>
+<pre>
+$ ant  run.aopc.50.nologging
+</pre>
+<p>This will aopc the application without logging enabled, and then run the application. As expected, we get no
+logging during the aopc process</p>
+<pre>
+aopc.no.logging:
+     [aopc] Build Successful: 609 ms
+</pre>
+
+<h4>Compile-time logging with System.out logging</h4>
+<p>To run aopc with logging turned on, but defaulting to the System.out logger, we run aopc with</p>
+<pre>
+&lt;aopc ...&gt;
+     &lt;!-- Turn on logging --&gt; 
+     &lt;sysproperty key="jboss.aop.verbose" value="false"/%gt;
+&lt;/aopc&gt;
+</pre>
+<p>since neither <tt>jboss-logging-log4j.jar</tt> nor <tt>log4j.jar</tt> are on the classpath, JBoss AOP
+defaults to the System.out logger. To run:</p>
+<pre>
+$ ant  run.aopc.50.system.out.logging
+</pre>
+<p>The output looks much the same as during the loadtime weaving, but this time
+it happens during the <tt>aopc</tt> stage:</p>
+<pre>
+aopc.system.out.logging:
+...
+     [aopc] [aop-debug] org.jboss.aop.instrument.Instrumentor trying to transform POJO
+     [aopc] [aop-debug] org.jboss.aop.instrument.CallerTransformer There are no caller pointcuts!
+     [aopc] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtMethod at ae60ead5[public notwoven ()V] matches no pointcuts
+     [aopc] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtMethod at 7c6e6140[public boundMethod ()V] matches pointcut: execution(public void POJO->boundMethod())
+     [aopc] [aop-debug] org.jboss.aop.instrument.JoinpointSimpleClassifier javassist.CtConstructor at cb6009[public POJO ()V] matches no pointcuts
+     [aopc] [aop-debug] org.jboss.aop.instrument.Instrumentor was POJO converted: true
+...
+     [aopc] Build Successful: 781 ms
+</pre>
+<p>We also get some lugging when running the application, showing what happens when the aop information is processed at 
+runtime when running the application:</p>
+<pre>
+run.aopc.50.system.out.logging:
+...
+     [java] [aop-debug] org.jboss.aop.ClassAdvisor Creating chains for class POJO sun.misc.Launcher$AppClassLoader at a39137
+     [java] [aop-debug] org.jboss.aop.ClassAdvisor iterate binding file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0 execution(public void POJO->boundMethod())
+     [java] [debug] method matched binding: public void POJO.boundMethod()
+     [java] [aop-debug] org.jboss.aop.advice.AdviceBinding added advisor: POJO from binding: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0
+     [java] [aop-debug] org.jboss.aop.MethodMatchInfo populate bindings for public void POJO.boundMethod() all bindings
+     [java] [aop-debug] org.jboss.aop.MethodMatchInfo 0 POJO execution(public void POJO->boundMethod()) : 1
+     [java] [aop-debug] org.jboss.aop.MethodMatchInfo populate bindings for public void POJO.boundMethod() actual bindings
+     [java] [aop-debug] org.jboss.aop.MethodMatchInfo 0 POJO execution(public void POJO->boundMethod()) : 1
+     [java] [aop-debug] org.jboss.aop.advice.AdviceBinding added advisor: POJO from binding: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0
+     [java] --- pojo.notwoven(); ---
+     [java] notwoven()
+     [java] --- pojo.boundMethod(); ---
+     [java] [aop-debug] org.jboss.aop.advice.AspectFactoryWithClassLoaderSupport Using context classloader sun.misc.Launcher$AppClassLoader at a39137 to load aspect SimpleInterceptor
+     [java] <<< Entering SimpleInterceptor
+     [java] boundMethod
+     [java] >>> Leaving SimpleInterceptor
+</pre>
+<h4>Compile-time logging with log4j logging</h4>
+<p>To run aopc with logging turned on, but defaulting to the System.out logger, we run aopc with</p>
+<pre>
+&lt;aopc ...&gt;
+     &lt;!-- Turn on logging --&gt; 
+     &lt;sysproperty key="jboss.aop.verbose" value="false"/%gt;
+&lt;/aopc&gt;
+</pre>
+when running the aopc post-compiler, so logging of the weaving is now turned on. In this case both <tt>jboss-logging-log4j.jar</tt> and 
+<tt>log4j.jar</tt> are on the classpath, so JBoss AOP will now use the log4j logging mechanism. To get any meaningful
+output, you need a <a href="log4j.properties">log4j.properties</a> on the classpath as was the case when using loadtime weaving. To run:
+<pre>
+$ ant  run.aopc.50.log4j.logging
+</pre>
+<p>We get much the same output as we did in the <i>Compile-time logging with System.out logging</i> case, but this time formatted and 
+controllable using log4j. Here is the output from aopc:</p>
+<pre>
+aopc.log4j.logging:
+...
+     [aopc] 2007-05-16 00:03:58,468 DEBUG org.jboss.aop.instrument.Instrumentor - trying to transform POJO
+     [aopc] 2007-05-16 00:03:58,468 DEBUG org.jboss.aop.instrument.CallerTransformer - There are no caller pointcuts!
+     [aopc] 2007-05-16 00:03:58,468 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtMethod at ae60ead5[public notwoven ()V] matches no pointcuts
+     [aopc] 2007-05-16 00:03:58,468 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtMethod at 7c6e6140[public boundMethod ()V] matches pointcut: execution(public void POJO->boundMethod())
+     [aopc] 2007-05-16 00:03:58,796 DEBUG org.jboss.aop.instrument.JoinpointSimpleClassifier - javassist.CtConstructor at 4aa0ce[public POJO ()V] matches no pointcuts
+     [aopc] 2007-05-16 00:03:58,796 DEBUG org.jboss.aop.instrument.Instrumentor - was POJO converted: true
+...
+     [aopc] Build Successful: 828 ms
+</pre>
+<p>and here is the output from the runtime applicatiin of the aop information</p>
+<pre>
+run.aopc.50.log4j.logging:
+...
+     [java] 2007-05-16 00:03:59,343 DEBUG org.jboss.aop.ClassAdvisor - Creating chains for class POJO sun.misc.Launcher$AppClassLoader at 92e78c
+     [java] 2007-05-16 00:03:59,343 DEBUG org.jboss.aop.ClassAdvisor - iterate binding file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0 execution(public void POJO->boundMethod())
+     [java] [debug] method matched binding: public void POJO.boundMethod()
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.advice.AdviceBinding - added advisor: POJO from binding: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.MethodMatchInfo - populate bindings for public void POJO.boundMethod() all bindings
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.MethodMatchInfo - 0 POJO execution(public void POJO->boundMethod()) : 1
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.MethodMatchInfo - populate bindings for public void POJO.boundMethod() actual bindings
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.MethodMatchInfo - 0 POJO execution(public void POJO->boundMethod()) : 1
+     [java] 2007-05-16 00:03:59,359 DEBUG org.jboss.aop.advice.AdviceBinding - added advisor: POJO from binding: file:/C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/build/output/jboss-aop-snapshot/docs/aspect-framework/examples/logging/jboss-aop.xml0
+     [java] --- pojo.notwoven(); ---
+     [java] notwoven()
+     [java] --- pojo.boundMethod(); ---
+     [java] 2007-05-16 00:03:59,562 DEBUG org.jboss.aop.advice.AspectFactoryWithClassLoaderSupport - Using context classloader sun.misc.Launcher$AppClassLoader at 92e78c to load aspect SimpleInterceptor
+     [java] <<< Entering SimpleInterceptor
+     [java] boundMethod
+     [java] >>> Leaving SimpleInterceptor
+
+</pre>
+
+</html>




More information about the jboss-cvs-commits mailing list