[jboss-cvs] JBossAS SVN: r60429 - projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 8 13:25:31 EST 2007


Author: flavia.rainone at jboss.com
Date: 2007-02-08 13:25:30 -0500 (Thu, 08 Feb 2007)
New Revision: 60429

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java
Log:
[JBAOP-352] Code refactoring plus Get/setArgument policies documented

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -34,7 +34,8 @@
    private static final long serialVersionUID = -6040602776303974658L;
    
    protected Object callingObject;
-
+   protected Object[] arguments;
+   
    public CallerInvocation(Advisor advisor, Object callingObject, Interceptor[] interceptors)
    {
       super(interceptors);
@@ -57,4 +58,42 @@
    {
       return this.callingObject;
    }
+   
+   /**
+    * Returns an array containing all call arguments.
+    * <p>
+    * The returned array can be changed by the advice or interceptor accordingly. All
+    * changes are reflected on joinpoint execution, and are noticed as well by
+    * other advices and interceptors that are executed after the current one.
+    * <br>
+    * However, changes to this array are limited to the scope of current advice
+    * execution, and must be performed before execution of {@link #invokeNext()},
+    * {@link #invokeNext(Interceptor[])}, or {@link #invokeTarget()} method.
+    * Otherwise, inconsistency on joinpoint argument values may be noticed.
+    *
+    * @return the call arguments
+    */
+   public Object[] getArguments()
+   {
+      return arguments;
+   }
+
+   /**
+    * Replaces call argument values by the ones contained in <code>
+    * arguments</code>.
+    * <p>
+    * Advices and interceptors must be aware that, for performance reasons,
+    * this array does not get copied across; its reference is directly used instead.
+    * Hence, changes to <code>arguments</code> array after this method being called
+    * are forbidden. Otherwise, inconsistency on joinpoint argument values may be
+    * noticed. 
+    *  
+    * @param arguments an array containing the new values of call arguments.
+    *                  The size of this array must be the same as the one of 
+    *                  {@link #getArguments()}, as well as the element types.
+    */
+   public void setArguments(Object[] arguments)
+   {
+      this.arguments = arguments;
+   }
 }
\ No newline at end of file

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -42,8 +42,6 @@
 {
    private static final long serialVersionUID = -1569257745454443521L;
 
-   protected Object[] arguments;
-   
    //info fields
    protected Constructor calling;
    protected Constructor constructor;
@@ -73,16 +71,6 @@
       super(callingObject, interceptors);
    }
    
-   public Object[] getArguments()
-   {
-      return arguments;
-   }
-
-   public void setArguments(Object[] arguments)
-   {
-      this.arguments = arguments;
-   }
-
    /**
     *
     * @return the constructor that is calling the called constructor
@@ -100,14 +88,17 @@
    /**
     * Is the called constructor aspectized?  If so then there is a wrapping
     * method that must be called.
-    * @return
+    * 
+    * @return <code>true</code> if the constructor is wrapped
     */
    public boolean isWrapped() { return wrappingMethod != null; }
 
    /**
     * Is the called constructor aspectized?  If so then this method
     * returns the method that wraps the constructor.
-    * @return
+    * 
+    * @return the method that wraps the constructor if {@link #isWrapped()} returns
+    *         <code>true</code>; <code>null</code> otherwise.
     */
    public Method getWrappingMethod() { return wrappingMethod; }
 
@@ -192,12 +183,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
-    * @param newchain
-    * @return
+   
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -207,7 +199,8 @@
 
    /**
     * Copies complete state of Invocation object.
-    * @return
+    * 
+    * @return a copy of this instance
     */
    public Invocation copy()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -42,8 +42,6 @@
 {
    private static final long serialVersionUID = -3269308917757322223L;
 
-   protected Object[] arguments = null;
-
    //info fields
    protected Class callingClass;
    protected Method callingMethod;
@@ -78,24 +76,6 @@
    }
 
    /**
-    * @return the arguments of the called constructor
-    */
-   public Object[] getArguments()
-   {
-      return arguments;
-   }
-
-   /**
-    * change the arguments to the called constructor
-    *
-    * @param arguments
-    */
-   public void setArguments(Object[] arguments)
-   {
-      this.arguments = arguments;
-   }
-
-   /**
     * @return The class that is making the call on the constructor
     */
    public Class getCallingClass()
@@ -123,7 +103,7 @@
     * Is the called constructor aspectized?  If so then there is a wrapping
     * method that must be called.
     *
-    * @return
+    * @return <code>true</code> if the constructor is wrapped
     */
    public boolean isWrapped()
    {
@@ -134,7 +114,8 @@
     * Is the called constructor aspectized?  If so then this method
     * returns the method that wraps the constructor.
     *
-    * @return
+    * @return the method that wraps the constructor if {@link #isWrapped()} returns
+    *         <code>true</code>; <code>null</code> otherwise.
     */
    public Method getWrappingMethod()
    {
@@ -222,13 +203,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
     *
-    * @param newchain
-    * @return
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -239,7 +220,7 @@
    /**
     * Copies complete state of Invocation object.
     *
-    * @return
+    * @return a copy of this instance
     */
    public Invocation copy()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -159,12 +159,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
-    * @param newchain
-    * @return
+    * 
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -174,7 +175,8 @@
 
    /**
     * Copies complete state of Invocation object.
-    * @return
+    * 
+    * @return a copy of this instance
     */
    public Invocation copy()
    {
@@ -187,11 +189,39 @@
       return wrapper;
    }
 
+   /**
+    * Returns an array containing all constructor arguments.
+    * <p>
+    * The returned array can be changed by the advice or interceptor accordingly. All
+    * changes are reflected on joinpoint execution, and are noticed as well by
+    * other advices and interceptors that are executed after the current one.
+    * <br>
+    * However, changes to this array are limited to the scope of current advice
+    * execution, and must be performed before execution of {@link #invokeNext()},
+    * {@link #invokeNext(Interceptor[])}, or {@link #invokeTarget()} method.
+    * Otherwise, inconsistency on joinpoint argument values may be noticed.
+    *
+    * @return the constructor arguments
+    */
    public Object[] getArguments()
    {
       return arguments;
    }
 
+   /**
+    * Replaces constructor argument values by the ones contained in <code>
+    * arguments</code>.
+    * <p>
+    * Advices and interceptors must be aware that, for performance reasons,
+    * this array does not get copied across; its reference is directly used instead.
+    * Hence, changes to <code>arguments</code> array after this method being called
+    * are forbidden. Otherwise, inconsistency on joinpoint argument values may be
+    * noticed. 
+    *  
+    * @param arguments an array containing the new values of constructor arguments.
+    *                  The size of this array must be the same as the one of 
+    *                  {@link #getArguments()}, as well as the element types.
+    */
    public void setArguments(Object[] arguments)
    {
       this.arguments = arguments;

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -45,8 +45,7 @@
    //info fields
    protected Constructor calling;
    protected Method method;
-   protected Object[] arguments = null;
-
+   
    public MethodCalledByConstructorInvocation(MethodByConInfo info, Object callingObject, Object target, Object[] args, Interceptor[] interceptors)
    {
       this(info.getAdvisor(), info.getCalling(), info.getMethod(), callingObject, target, args, interceptors);
@@ -129,12 +128,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
-    * @param newchain
-    * @return
+    * 
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -144,7 +144,8 @@
 
    /**
     * Copies complete state of Invocation object.
-    * @return
+    * 
+    * @return a copy of this instance
     */
    public Invocation copy()
    {
@@ -157,26 +158,6 @@
    }
 
    /**
-    * What are the arguments of the method call
-    * The are expressed as an Object[] array.
-    *
-    * @return the arguments of the method call
-    */
-   public Object[] getArguments()
-   {
-      return arguments;
-   }
-
-   /**
-    * Change the arguments of the method call
-    * @param arguments
-    */
-   public void setArguments(Object[] arguments)
-   {
-      this.arguments = arguments;
-   }
-
-   /**
     * The constructor that is calling the method
     *
     * @return The constructor that is calling the method

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -46,8 +46,6 @@
    Method callingMethod;
    Method method;
    
-   protected Object[] arguments = null;
-   
    public MethodCalledByMethodInvocation(MethodByMethodInfo info, Object callingObject, Object targetObject, Object[] arguments, Interceptor[] interceptors)
    {
       this(info.getAdvisor(), info.getCallingClass(), info.getCallingMethod(), info.getMethod(), callingObject, targetObject, arguments, interceptors);
@@ -133,13 +131,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
     *
-    * @param newchain
-    * @return
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -150,7 +148,7 @@
    /**
     * Copies complete state of Invocation object.
     *
-    * @return
+    * @return a copy of this instance
     */
    public Invocation copy()
    {
@@ -163,24 +161,6 @@
    }
 
    /**
-    * @return the arguments of the called method
-    */
-   public Object[] getArguments()
-   {
-      return arguments;
-   }
-
-   /**
-    * change the arguments to the called method
-    *
-    * @param arguments
-    */
-   public void setArguments(Object[] arguments)
-   {
-      this.arguments = arguments;
-   }
-
-   /**
     * @return The class that is making the call on the method
     */
    public Class getCallingClass()

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java	2007-02-08 18:15:13 UTC (rev 60428)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java	2007-02-08 18:25:30 UTC (rev 60429)
@@ -236,13 +236,13 @@
    }
 
    /**
-    * Get a wrapper invocation object that can insert a new chain of interceptors
+    * Returns a wrapper invocation object that can insert a new chain of interceptors
     * at runtime to the invocation flow.  CFlow makes use of this.
     * When the wrapper object finishes its invocation chain it delegates back to
     * the wrapped invocation.
     *
-    * @param newchain
-    * @return
+    * @param newchain chain of interceptors to be inserted on invocation
+    * @return an invocation wrapper
     */
    public Invocation getWrapper(Interceptor[] newchain)
    {
@@ -253,7 +253,7 @@
    /**
     * Copies complete state of Invocation object.
     *
-    * @return
+    * @return a copy of this instance
     */
    public Invocation copy()
    {
@@ -266,7 +266,20 @@
       return wrapper;
    }
 
-
+   /**
+    * Returns an array containing all method arguments.
+    * <p>
+    * The returned array can be changed by the advice or interceptor accordingly. All
+    * changes are reflected on joinpoint execution, and are noticed as well by
+    * other advices and interceptors that are executed after the current one.
+    * <br>
+    * However, changes to this array are limited to the scope of current advice
+    * execution, and must be performed before execution of {@link #invokeNext()},
+    * {@link #invokeNext(Interceptor[])}, or {@link #invokeTarget()} method.
+    * Otherwise, inconsistency on joinpoint argument values may be noticed.
+    *
+    * @return the method arguments
+    */
    public Object[] getArguments()
    {
       if (arguments == null && marshalledArguments != null)
@@ -288,7 +301,20 @@
       return arguments;
    }
 
-
+   /**
+    * Replaces method argument values by the ones contained in <code>
+    * arguments</code>.
+    * <p>
+    * Advices and interceptors must be aware that, for performance reasons,
+    * this array does not get copied across; its reference is directly used instead.
+    * Hence, changes to <code>arguments</code> array after this method being called
+    * are forbidden. Otherwise, inconsistency on joinpoint argument values may be
+    * noticed. 
+    *  
+    * @param arguments an array containing the new values of method arguments.
+    *                  The size of this array must be the same as the one of 
+    *                  {@link #getArguments()}, as well as the element types.
+    */
    public void setArguments(Object[] arguments)
    {
       this.arguments = arguments;




More information about the jboss-cvs-commits mailing list