You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/05/20 05:57:12 UTC

cvs commit: maven-new/core/src/aspect/org/apache/maven PomInheritanceAspect.java

jvanzyl     2003/05/19 20:57:12

  Modified:    core/src/aspect/org/apache/maven PomInheritanceAspect.java
  Log:
  o Inheritance now works correctly except for one method, getName(), which
  actually resides in the super class BaseObject. But all inheritance seems
  to be working correctly using the aspect and the cleaned up Project which
  lazily instantiates the collections used within.
  
  Revision  Changes    Path
  1.2       +17 -10    maven-new/core/src/aspect/org/apache/maven/PomInheritanceAspect.java
  
  Index: PomInheritanceAspect.java
  ===================================================================
  RCS file: /home/cvs/maven-new/core/src/aspect/org/apache/maven/PomInheritanceAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PomInheritanceAspect.java	26 Apr 2003 16:52:16 -0000	1.1
  +++ PomInheritanceAspect.java	20 May 2003 03:57:12 -0000	1.2
  @@ -57,21 +57,18 @@
    */
   
   import org.apache.maven.project.Project;
  +import java.lang.reflect.Method;
   
   /**
  - * 
  - *  There is no inheritance on getId, getGroupId, getArtifactId.
  - *  I couldn't be bothered filling a use case that probably doesn't 
  - *  exist and would convolute the code unnecessarily.  XXX I could be 
  - *  wrong about removing inheritance on getGroupId, we'll tackle 
  - *  that later.
  - *
    *  @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
    * 
    *  @version $Id$
    */
   aspect PomInheritanceAspect
   {
  +    private static Class[] EMPTY_CLASS_ARGS = new Class[] {};
  +    private static Object[] EMPTY_OBJECT_ARGS = new Object[] {};
  +    
       pointcut projectGetters(Project p): call( * Project.get*( .. )  ) 
                                           && !call( * Project.getParent( .. )  )
                                           && target(p);
  @@ -85,8 +82,18 @@
           // we will try to retrieve the value from the parent.
           if ( o == null && p.hasParent() )
           {
  -            // Use reflection given the target method and lookup the value
  -            // in the parent. No biggie.
  +            Project parent = p.getParent();
  +            Method m = null;
  +            
  +            try
  +            {
  +                m  = parent.getClass().getMethod( thisJoinPoint.getSignature().getName(), EMPTY_CLASS_ARGS );
  +                o = m.invoke( parent, EMPTY_OBJECT_ARGS );
  +            }
  +            catch (Exception e)
  +            {
  +                // do nothing
  +            }
           }
   
           return o;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org