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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Apr 4 14:00:24 EDT 2007


Author: flavia.rainone at jboss.com
Date: 2007-04-04 14:00:24 -0400 (Wed, 04 Apr 2007)
New Revision: 62089

Added:
   projects/aop/trunk/aop/docs/examples/annotated-parameters/
   projects/aop/trunk/aop/docs/examples/annotated-parameters/Aspect.java
   projects/aop/trunk/aop/docs/examples/annotated-parameters/Driver.java
   projects/aop/trunk/aop/docs/examples/annotated-parameters/POJO.java
   projects/aop/trunk/aop/docs/examples/annotated-parameters/annotated-parameters.html
   projects/aop/trunk/aop/docs/examples/annotated-parameters/build.xml
   projects/aop/trunk/aop/docs/examples/annotated-parameters/jboss-aop.xml
Log:
[JBAOP-44] Second example on before/after/after throwing advices. This example introduces all annotated parameters (except Thrown)

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/Aspect.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/Aspect.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/Aspect.java	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,194 @@
+/*
+* 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.ConstructorInfo;
+import org.jboss.aop.FieldInfo;
+import org.jboss.aop.JoinPointInfo;
+
+import org.jboss.aop.advice.annotation.Arg;
+import org.jboss.aop.advice.annotation.Args;
+import org.jboss.aop.advice.annotation.Caller;
+import org.jboss.aop.advice.annotation.JoinPoint;
+import org.jboss.aop.advice.annotation.Return;
+import org.jboss.aop.advice.annotation.Target;
+
+import org.jboss.aop.joinpoint.CallerInvocation;
+import org.jboss.aop.joinpoint.CurrentInvocation;
+
+public class Aspect
+{
+   // @JoinPoint
+   
+   public void beforeJoinPoint(@JoinPoint JoinPointInfo joinPointInfo)
+   {
+      System.out.println(">>> beforeJoinPoint: FieldInfo " + joinPointInfo);
+   }
+   
+   public Object aroundJoinPoint(@JoinPoint CallerInvocation invocation) throws Throwable
+   {
+      System.out.println(">>> aroundJoinPoint: CallerInvocation " + invocation);
+      return invocation.invokeNext();
+   }
+   
+   public void afterJoinPoint(@JoinPoint ConstructorInfo joinPointInfo)
+   {
+      System.out.println(">>> afterJoinPoint: ConstructorInfo " + joinPointInfo);
+   }
+   
+   // @Target
+   
+   public void beforeTarget(@Target Object target)
+   {
+      System.out.println(">>> beforeTarget: Object " + target);
+   }
+   
+   public Object aroundTarget(@Target POJO target) throws Throwable
+   {
+      System.out.println(">>> aroundTarget: POJO " + target);
+      return CurrentInvocation.proceed();
+   }
+   
+   public void afterTarget(@Target POJO target) throws Throwable
+   {
+      System.out.println(">>> afterTarget: POJO " + target);
+   }
+   
+   // @Caller
+   
+   public void beforeCaller(@Caller POJO caller)
+   {
+      System.out.println(">>> beforeCaller: POJO " + caller);
+   }
+   
+   public Object aroundCaller(@Caller Driver target) throws Throwable
+   {
+      System.out.println(">>> aroundCaller: Driver " + target);
+      return CurrentInvocation.proceed();
+   }
+   
+   public void afterCaller(@Caller Object target)
+   {
+      System.out.println(">>> afterCaller: Object " + target);
+   }
+   
+   // @Return
+   
+   public void afterFieldReturn(@Return Object joinPointReturn)
+   {
+      System.out.println(">>> afterFieldReturn: Object " + joinPointReturn);
+   }
+   
+   public void afterMethodReturn(@Return boolean joinPointReturn)
+   {
+      System.out.println(">>> afterMethodReturn: boolean " + joinPointReturn);
+   }
+   
+   // @Arg
+   
+   public void beforeConstructorArg(@Arg Object argument)
+   {
+      System.out.println(">>> beforeConstructorArg: Object \"" + argument + "\"");
+   }
+   
+   public Object aroundConstructorArg(@Arg String argument) throws Throwable
+   {
+      System.out.println(">>> aroundConstructorArg: String \"" + argument + "\"");
+      return CurrentInvocation.proceed();
+   }
+   
+   public void afterArg(@Arg int argument)
+   {
+      System.out.println(">>> afterArg: int " + argument);
+   }
+   
+   public void beforeMethodArg(@Arg long argument)
+   {
+      System.out.println(">>> beforeMethodArg: long " + argument + "L");
+   }
+   
+   public void beforeMethodArg2(@Arg(index=2) long argument)
+   {
+      System.out.println(">>> beforeMethodArg2: long " + argument + "L");
+   }
+   
+   // @Args
+   
+   public void beforeArgs(@Args Object[] arguments)
+   {
+      System.out.print(">>> beforeArgs changing arguments: from ");
+      printArgs(arguments);
+      arguments[3] = "overridenString";
+      arguments[1] = Integer.valueOf(((Integer)arguments[1]).intValue() - 50);
+      System.out.print("                                   to ");
+      printArgs(arguments);
+   }
+   
+   public Object aroundArgs(@Args Object[] arguments) throws Throwable
+   {
+      System.out.print(">>> aroundArgs: arguments ");
+      printArgs(arguments);
+      return CurrentInvocation.proceed();
+   }
+   
+   public void afterArgs(@Args Object[] arguments)
+   {
+      System.out.print(">>> afterArgs: arguments ");
+      printArgs(arguments);
+   }
+   
+   private void printArgs(Object[] arguments)
+   {
+      if (arguments == null)
+      {
+         System.out.println(arguments);
+         return;
+      }
+      System.out.print("[");
+      if (arguments.length > 0)
+      {
+         System.out.print(arguments[0]);
+         for (int i = 1; i < arguments.length; i++)
+         {
+            System.out.print(", " + arguments[i]);
+         }
+      }
+      System.out.println("]");
+   }
+   
+   // empty parameter list
+   
+   public void beforeNoParameters()
+   {
+      System.out.println(">>> beforeNoParameters");
+   }
+   
+   public Object aroundNoParameters() throws Throwable
+   {
+      System.out.println(">>> aroundNoParameters");
+      return CurrentInvocation.proceed();
+   }
+   
+   public void afterNoParameters()
+   {
+      System.out.println(">>> afterNoParameters");
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/Driver.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/Driver.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/Driver.java	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,58 @@
+/*
+ * 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) throws Exception
+   {
+      
+      System.out.println("\nCalling POJO constructor");
+      System.out.println("========================");
+      POJO pojo = new POJO("Driver");
+      
+      System.out.println("\nSetting POJO->field with \"text\" value");
+      System.out.println("=======================================");
+      pojo.field = "text";
+      
+      System.out.println("\nReading POJO->field value");
+      System.out.println("=========================");
+      Object myValue = pojo.field;
+      
+      System.out.println("\nCalling POJO->method(int)");
+      System.out.println("=========================");
+      pojo.method(17);
+      
+      System.out.println("\nCalling POJO->method(long, int, long, String)");
+      System.out.println("=============================================");
+      pojo.method(20L,2, 1000L, "Driver");
+      
+      
+      System.out.println("\nCalling POJO->someMethod(int)");
+      System.out.println("=============================");
+      if(pojo.someMethod(10))
+      {
+         System.out.println("\nCalling POJO->callMethod()");
+         System.out.println("==========================");
+         pojo.callMethod();
+      }
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/POJO.java
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/POJO.java	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/POJO.java	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,59 @@
+/*
+ * 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 Object field;
+   
+   public POJO(String argument) 
+   {
+      System.out.println("RUNNING new POJO(\"" + argument + "\")");
+   }
+
+   public boolean someMethod(int argument)
+   {
+      System.out.println("RUNNING POJO->someMethod()");
+      return true;
+   }
+   
+   public void callMethod()
+   {
+      System.out.println("RUNNING POJO->callMethod()");
+      this.calledMethod();
+   }
+   
+   public void calledMethod()
+   {
+      System.out.println("RUNNING POJO->calledMethod()");
+   }
+   
+   public void method(int arg0)
+   {
+      System.out.println("RUNNING POJO->method(" + arg0 + ")");
+   }
+   
+   public void method(long arg0, int arg1, long arg2, String arg3)
+   {
+      System.out.println("RUNNING POJO->method(" + arg0 + "L, " + arg1 + ", " +
+            arg2 + "L, \"" + arg3 + "\")");
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/annotated-parameters.html
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/annotated-parameters.html	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/annotated-parameters.html	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,325 @@
+<html>
+<body>
+<p>
+<h2>Annotated Advice Parameters</h2>
+
+</p><p>
+<h4>Overview</h4>
+In generated advisor (default) mode, before, after and around advices can receive
+annotated parameters. The use of annotations provides maximum flexibility to the
+signature of advices, since an advice can receive only the values that are relevant
+to its execution. These parameters can be in any order and their type can be the type
+that is the most suitable to the advice functionality, according to the joinpoints it
+intercepts.
+
+</p><p>
+<h4>Annotated Parameter Signature</h4>
+</p><p>
+The annotated parameter signature is defined as:
+</p><p>
+<pre>
+public &lt;return-value&gt; &lt;any-method-name&gt;(@&lt;Annotation&gt; &lt;any type&gt; arg0, @&lt;Annotation&gt; &lt;any type&gt; arg1, ... , @&lt;Annotation&gt; &lt;any type&gt; argN) throws &lt;Exception1&gt;,&lt;Exception2&gt;,...,&lt;ExceptionN&gt;
+</pre>
+</p><p>
+This signature is  available for all kinds of advices in JBoss AOP (when running in
+the default generated advisor mode). Basicaly, it allows an advice to receive zero
+or more annotated parameters, in any order, and with any valid type.
+</p><p>
+Regarding the exception types, an advice is allowed to declare any exception in its
+signature. If the exception is declared in the joinpoint exceptions list (and if
+the joinpoint has an exception list), JBoss AOP rethrows the exception as is. If
+the exception is not part of the joinpoint exception list, JBoss AOP will wrap it in
+a <tt>RuntimeException</tt>. In both cases, the application would get the exception
+as if the joinpoint itself had thrown it.
+</p><p>
+A concrete example of this signature has been shown in the
+<a href="../beforeafter/beforeafter.html">before/after</a> example:
+</p><p>
+<pre>
+public void beforeAdvice(@JoinPoint Joinpoint joinPoint)
+</pre>
+</p><p>
+As we can see, this advice receives one parameter, annotated with
+<tt>&#64;JoinPoint</tt>.
+</p><p>
+In the next topics we will see all parameter annotations that can be used by an
+advice. Notice that an empty parameter list is also valid, as in the following
+signatures:
+</p><p>
+<pre>
+public void beforeNoParameters()
+
+public Object aroundNoParameters() throws Throwable
+
+public void afterNoParameters()
+</pre>
+</p><p>
+
+<h4>Parameter Annotations</h4>
+</p><p>
+JBoss AOP demands the use of parameter annotations to identify advice parameters.
+These parameters can represent several values, like the joinpoint target, a joinpoint
+argument, or its return value. In this example, we show all parameter annotations
+that can be used by before, after and around advices. These annotations are located
+in the <tt>org.jboss.aop.advice.annotation</tt> package.
+</p><p>
+The type of an annotated parameter can be chosen accordingly to the value it refers.
+For example, suppose you are intercepting a jointpoint with an argument of type
+<tt>ArrayList&lt;String&gt;</tt>. Advices that refer to this argument as being of
+type <tt>ArrayList&lt;String&gt;</tt>, or <tt>Collection&lt;String&gt;</tt> or <tt>
+Object</tt> would all be considered correct. This is useful because you can access
+specific operations and fields of the argument, without performing a cast, and yet you
+can receive a super type like <tt>Object</tt> and refer to arguments of different
+types when your advice is applied to different joinpoints.
+</p><p>
+Notice that, as a convention, we named the advices of this example after the names of
+parameter annotations. It is important to point that, as all previous examples, the
+name of advices can be chosen freely and JBoss AOP won't use these names to identify
+annotated parameters. The same applies to the names of advice parameters.
+</p><p>
+<h5>&#64;JoinPoint</h5>
+</p><p>
+This annotation is used on objects that represent a joinpoint. If the advice
+is an around advice, the type of this object belongs to the
+<a href="../../misc/invocation.html">Invocation class hierarchy</a>. On all other
+advices, joinpoints are represented by types of the <a href="../../misc/joinpoint.html">
+JoinPoint interface hierarchy</a>, as follows:
+</p><p>
+<pre>
+public void beforeJoinPoint(@JoinPoint JoinPointInfo joinPointInfo)
+
+public Object aroundJoinPoint(@JoinPoint CallerInvocation invocation) throws Throwable
+
+public void afterJoinPoint(@JoinPoint ConstructorInfo joinPointInfo)
+</pre>
+</p><p>
+Notice how <tt>beforeJoinPoint</tt> advice receives a parameter of the supertype
+<tt>JoinPointInfo</tt> while, in <tt>afterJoinPoint</tt>, the parameter is of the more
+specific type <tt>ConstructorInfo</tt>, valid only on constructor execution
+joinpoints.
+To see these and all other advice examples, open up the <tt>Aspect.java</tt> file.
+</p></p>
+<h5>&#64;Target</h5>
+</p><p>
+This annotation is used on parameters that refer to the joinpoint target. The
+joinpoint target is defined according to the joinpoint type. For example, the target
+of a method execution is the object whose method is being executed. On a call
+joinpoint, the target is the object whose method is being called. On a field access
+joinpoint, the target is the object that contains the field. Notice that not all
+joinpoints have a target. Static method executions and calls, and static field reads
+and writes don't have a target.
+</p><p>
+Examples of usage of this annotation follow:
+</p><p>
+<pre>
+public void beforeTarget(@Target Object target)
+
+public Object aroundTarget(@Target POJO target) throws Throwable
+
+public void afterTarget(@Target POJO target) throws Throwable
+</pre>
+</p><p>
+By opening up <tt>jboss-aop.xml</tt>, you can see that the target of all these
+advices is of type <tt>POJO</tt>, yet <tt>beforeTarget</tt> advice receives a target
+of type <tt>Object</tt>. Since <tt>POJO</tt> extends <tt>Object</tt>, this is
+perfectly valid, and useful when an advice intercepts joinpoints with different
+target types.
+</p><p>
+<h5>&#64;Caller</h5>
+</p><p>
+This annotation is used on parameters that refer to the caller object, during a call
+joinpoint interception. This should be used only on call joinpoints. If the call is
+inside a static method, the caller will be <tt>null</tt>.
+Examples follow:
+</p><p>
+<pre>
+public void beforeCaller(@Caller POJO caller)
+
+public Object aroundCaller(@Caller Driver target) throws Throwable
+
+public void afterCaller(@Caller Object target)
+</pre>
+</p><p>
+<h5>&#64;Return</h5>
+</p><p>
+Use this annotation only on after advices, to refer to the joinpoint return value:
+</p><p>
+<pre>
+public void afterFieldReturn(@Return Object joinPointReturn)
+
+public void afterMethodReturn(@Return boolean joinPointReturn)
+</pre>
+</p><p>
+<h5>&#64;Arg</h5>
+</p><p>
+This annotation is used to refer to a joinpoint argument. Since a joinpoint can
+receive more than one argument, this is the only annotation that can be used on more
+than one advice parameters.
+Look at these examples:
+</p><p>
+<pre>
+public void beforeConstructorArg(@Arg Object argument)
+
+public Object aroundConstructorArg(@Arg String argument) throws Throwable
+
+public void afterArg(@Arg int argument)
+</pre>
+</p><p>
+When the joinpoint receives multiple arguments, JBoss AOP infers to which
+argument an <tt>&#64;Arg</tt> annotated parameter refers. In this example, both
+<tt>beforeConstructorArg</tt> and <tt>aroundConstructorArg</tt> are applied to
+<tt>POJO</tt> constructor, whose unique argument is of type <tt>java.lang.String</tt>.
+So, the parameters of these advices will refer to this constructor argument.
+On the other hand, <tt>afterArg</tt> advice is applied to more than one method
+executions:
+</p><p>
+<pre>
+public class POJO
+{
+   ...
+   
+   public boolean someMethod(int argument)
+   {
+      ...
+   }
+   
+   public void method(long arg0, int arg1, long arg2, String arg3)
+   {
+      ...
+   }
+   
+   ...
+}
+</pre>
+</p><p>
+Wen intercepting <tt>POJO.someMethod(int)</tt> execution, the parameter of <tt>
+afterArg</tt> will contain the value of the single argument <tt>someMethod</tt>
+received, as it happens with <tt>beforeConstructorArg</tt> and <tt>
+aroundConstructorArg</tt> advices. But, when intercepting <tt>
+POJO.method(long,int,long,String)</tt>, JBoss AOP will automatically associate <tt>
+afterArg</tt> parameter with the parameter at index position <tt>1</tt>, which is the
+second <tt>POJO.method()</tt> parameter, of type <tt>int</tt>.
+</p><p>
+Associating the <tt>int</tt> value is easy, because there is only one joinpoint
+argument of that type. The same doesn't apply to the following advice:
+</p><p>
+<pre>
+public void beforeMethodArg(@Arg long argument)
+</pre>
+</p><p>
+Given that <tt>POJO->method(long,int,long,String)</tt> has two arguments of type <tt>
+long</tt>, JBoss AOP will pick the first <tt>long</tt> typed argument. If you want to
+refer to the second <tt>long</tt> typed argument, in position <tt>2</tt>, you can use
+the optional <tt>&#64;Arg.index</tt> element as is shown below:
+</p><p>
+<pre>
+public void beforeMethodArg2(@Arg(index=2) long argument)
+</pre>
+This element can be set everytime JBoss AOP does not associate your <tt>&#64;Arg</tt>
+annotated parameter with the joinpoint argument you want to receive.
+</p><p>
+<h5>&#64;Arguments</h5>
+</p><p>
+Finally, this annotation is used on advice parameters of type <tt>java.lang.Object[]
+</tt>, that contain the complete list of the joinpoint arguments.
+</p<p>
+Look at these examples:
+</p><p>
+<pre>
+public void beforeArgs(@Args Object[] arguments)
+
+public Object aroundArgs(@Args Object[] arguments) throws Throwable
+
+public void afterArgs(@Args Object[] arguments)
+</pre>
+</p><p>
+Use this annotation when you need a generic advice, that receives all arguments
+without knowing how many arguments there are, or their types. Using <tt>&#64;Arguments
+</tt> instead of a list of <tt>&#64;Arg</tt> annotated parameters is useful when you
+need to change one or more joinpoint argument values. An example is the <tt>
+beforeArgs</tt> advice, that ovewrites two argument values of <tt>
+POJO.method(long,int,long,String)</tt> method execution:
+</p><p>
+<pre>
+public void beforeArgs(@Args Object[] arguments)
+{
+   ...
+   arguments[3] = "overridenString";
+   arguments[1] = Integer.valueOf(((Integer)arguments[1]).intValue() - 50);
+   ...
+}
+</pre>
+</p><p>
+<h4>Run the example</h4>
+</p><p>
+To compile and run:
+<pre>
+  $ ant
+</pre>
+It will javac the files and then run the AOPC precompiler to manipulate the bytecode, then finally run the example.  The output should read as follows:
+<pre>
+run:
+
+     [java] Calling POJO constructor
+     [java] ========================
+     [java] &gt;&gt;&gt; beforeConstructorArg: Object "Driver"
+     [java] &gt;&gt;&gt; aroundConstructorArg: String "Driver"
+     [java] RUNNING new POJO("Driver")
+     [java] &gt;&gt;&gt; afterJoinPoint: ConstructorInfo Constructor[constructor=public POJO(java.lang.String)]
+
+     [java] Setting POJO->field with "text" value
+     [java] =======================================
+     [java] &gt;&gt;&gt; beforeJoinPoint: FieldInfo Field Write[field=public java.lang.Object POJO.field]
+     [java] &gt;&gt;&gt; aroundTarget: POJO POJO at 19209ea
+     [java] &gt;&gt;&gt; aroundArgs: arguments [text]
+
+     [java] Reading POJO->field value
+     [java] =========================
+     [java] &gt;&gt;&gt; aroundArgs: arguments []
+     [java] &gt;&gt;&gt; aroundNoParameters
+     [java] &gt;&gt;&gt; afterFieldReturn: Object text
+     [java] &gt;&gt;&gt; afterNoParameters
+
+     [java] Calling POJO->method(int)
+     [java] =========================
+     [java] &gt;&gt;&gt; aroundArgs: arguments [17]
+     [java] RUNNING POJO->method(17)
+     [java] &gt;&gt;&gt; afterArg: int 17
+     [java] &gt;&gt;&gt; afterArgs: arguments [17]
+
+     [java] Calling POJO->method(long, int, long, String)
+     [java] =============================================
+     [java] &gt;&gt;&gt; beforeMethodArg: long 20L
+     [java] &gt;&gt;&gt; beforeMethodArg2: long 1000L
+     [java] &gt;&gt;&gt; beforeArgs changing arguments: from [20, 2, 1000, Driver]
+     [java]                                    to [20, -48, 1000, overridenString]
+     [java] &gt;&gt;&gt; aroundArgs: arguments [20, -48, 1000, overridenString]
+     [java] RUNNING POJO->method(20L, -48, 1000L, "overridenString")
+     [java] &gt;&gt;&gt; afterArg: int -48
+     [java] &gt;&gt;&gt; afterArgs: arguments [20, -48, 1000, overridenString]
+
+     [java] Calling POJO->someMethod(int)
+     [java] =============================
+     [java] &gt;&gt;&gt; beforeNoParameters
+     [java] RUNNING POJO->someMethod()
+     [java] &gt;&gt;&gt; afterMethodReturn: boolean true
+     [java] &gt;&gt;&gt; afterArg: int 10
+
+     [java] Calling POJO->callMethod()
+     [java] ==========================
+     [java] &gt;&gt;&gt; aroundCaller: Driver null
+     [java] &gt;&gt;&gt; aroundArgs: arguments []
+     [java] RUNNING POJO->callMethod()
+     [java] &gt;&gt;&gt; beforeTarget: Object POJO at 19209ea
+     [java] &gt;&gt;&gt; beforeCaller: POJO POJO at 19209ea
+     [java] &gt;&gt;&gt; aroundJoinPoint: CallerInvocation JoinPoint_MByM__N_6287195452448676113POJO_N_1153034853916900765_8 at f99ff5
+     [java] RUNNING POJO->calledMethod()
+     [java] &gt;&gt;&gt; afterTarget: POJO POJO at 19209ea
+     [java] &gt;&gt;&gt; afterCaller: Object POJO at 19209ea
+</pre> 
+</p><p>
+</p><p>
+</p><p>
+</p>
+</body>
+</html>
\ No newline at end of file

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/build.xml
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/build.xml	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/build.xml	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project default="run" name="JBoss/AOP">
+   <target name="prepare">
+      <property name="jboss.aop.root" value="../../../.."/>
+      <property name="jboss.aop.lib" value="${jboss.aop.root}/lib"/>
+      <property name="jboss.aop.lib50" value="${jboss.aop.root}/lib-50"/>
+ 
+      <path id="jboss.aop.classpath">
+         <fileset dir="${jboss.aop.lib}">
+            <include name="*.jar"/>
+         </fileset>
+      </path>
+
+      <path id="jboss.aop.classpath50">
+         <fileset dir="${jboss.aop.lib50}">
+            <include name="*.jar"/>
+         </fileset>
+      </path>
+
+      <path id="classpath">
+         <path refid="jboss.aop.classpath"/>
+         <pathelement path="."/>
+      </path>
+	  
+      <property name="aop50jar" value="${jboss.aop.lib50}/jboss-aop-jdk50.jar"/>
+
+      <path id="classpath50">
+         <path refid="jboss.aop.classpath50"/>
+         <pathelement path="."/>
+      </path>
+
+      <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="jboss.aop.classpath"/>
+   </target>
+
+
+   <target name="compile" depends="prepare">
+      <javac srcdir="."
+         destdir="."
+         debug="on"
+         deprecation="on"
+         optimize="off"
+         includes="**">
+        <classpath refid="classpath50"/>
+      </javac>
+      <aopc compilerclasspathref="classpath50" classpathref="classpath50" verbose="true">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <sysproperty key="jboss.aop.verbose" value="true"/>
+         <classpath path="."/>
+         <src path="."/>
+         <aoppath path="jboss-aop.xml"/>
+      </aopc>
+   </target>
+
+   <target name="run" depends="compile">
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <sysproperty key="jboss.aop.instrumentor" value="org.jboss.aop.instrument.GeneratedAdvisorInstrumentor"/>
+         <classpath refid="classpath"/>
+      </java>
+   </target>
+
+   <target name="compile50standalone" depends="prepare">
+      <javac srcdir="."
+         destdir="."
+         debug="on"
+         deprecation="on"
+         optimize="off"
+         includes="**">
+         <classpath refid="classpath50"/>
+      </javac>
+   </target>
+
+   <target name="run.50.instrumented" depends="compile50standalone">
+      <java fork="yes" failOnError="true" className="Driver">
+         <sysproperty key="jboss.aop.path" value="jboss-aop.xml"/>
+         <sysproperty key="jboss.aop.instrumentor" value="org.jboss.aop.instrument.GeneratedAdvisorInstrumentor"/>
+         <jvmarg value="-javaagent:${aop50jar}"/>
+         <classpath refid="classpath50"/>
+      </java>
+   </target>
+
+</project>

Added: projects/aop/trunk/aop/docs/examples/annotated-parameters/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/docs/examples/annotated-parameters/jboss-aop.xml	                        (rev 0)
+++ projects/aop/trunk/aop/docs/examples/annotated-parameters/jboss-aop.xml	2007-04-04 18:00:24 UTC (rev 62089)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+
+   <aspect class="Aspect" scope="PER_VM"/>
+
+   <bind pointcut="get(* POJO->field)">
+      <after name="afterFieldReturn" aspect="Aspect"/>
+      <advice name="aroundArgs" aspect="Aspect"/>
+      <advice name="aroundNoParameters" aspect="Aspect"/>
+      <after name="afterNoParameters" aspect="Aspect"/>
+   </bind>
+         
+   <bind pointcut="set(* POJO->field)">
+      <before name="beforeJoinPoint" aspect="Aspect"/>
+      <advice name="aroundTarget" aspect="Aspect"/>
+      <advice name="aroundArgs" aspect="Aspect"/>
+   </bind>
+
+   <bind pointcut="execution(POJO->new(java.lang.String))">
+      <after name="afterJoinPoint" aspect="Aspect"/>
+      <before name="beforeConstructorArg" aspect="Aspect"/>
+      <advice name="aroundConstructorArg" aspect="Aspect"/>
+   </bind>
+   
+   <bind pointcut="execution(* POJO->someMethod(..))">
+      <after name="afterMethodReturn" aspect="Aspect"/>
+      <after name="afterArg" aspect="Aspect"/>
+      <before name="beforeNoParameters" aspect="Aspect"/>
+   </bind>
+   
+   <bind pointcut="execution(* POJO->method(..))">
+      <after name="afterArg" aspect="Aspect"/>
+      <advice name="aroundArgs" aspect="Aspect"/>
+      <after name="afterArgs" aspect="Aspect"/>
+   </bind>
+
+   <bind pointcut="execution(* POJO->method(long,int,long,java.lang.String))">
+      <before name="beforeMethodArg" aspect="Aspect"/>
+      <before name="beforeMethodArg2" aspect="Aspect"/>
+      <before name="beforeArgs" aspect="Aspect"/>
+   </bind>
+      
+   <bind pointcut="call(* POJO->calledMethod(..))">
+      <advice name="aroundJoinPoint" aspect="Aspect"/>
+      <before name="beforeTarget" aspect="Aspect"/>
+      <after name="afterTarget" aspect="Aspect"/>
+      <before name="beforeCaller" aspect="Aspect"/>
+      <after name="afterCaller" aspect="Aspect"/>
+   </bind>
+   
+   <bind pointcut="call(* POJO->callMethod())">
+      <advice name="aroundCaller" aspect="Aspect"/>
+      <advice name="aroundArgs" aspect="Aspect"/>
+   </bind>
+         
+</aop>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list