]> source.dussan.org Git - aspectj.git/commitdiff
updated reflection interfaces to represent a pointcut expression as a PointcutExpress...
authoracolyer <acolyer>
Fri, 17 Jun 2005 09:24:30 +0000 (09:24 +0000)
committeracolyer <acolyer>
Fri, 17 Jun 2005 09:24:30 +0000 (09:24 +0000)
Note that the whole MAP support in this module is still a work in progress and is scheduled for completion in M4.
-- AMC.

aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java [new file with mode: 0644]
aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java
aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java [new file with mode: 0644]
aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java

index 895e4b4a40429cbab8ba37ba24b2711e65cc3589..d46b0bf610bf8e1331c0e24741d79d34c3a693ed 100644 (file)
@@ -16,6 +16,7 @@ import java.lang.reflect.Method;
 import org.aspectj.lang.annotation.AdviceName;
 import org.aspectj.lang.reflect.Advice;
 import org.aspectj.lang.reflect.AdviceType;
+import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
  * @author colyer
@@ -25,12 +26,12 @@ public class AdviceImpl implements Advice {
 
        private final AdviceType kind;
        private final Method adviceMethod;
-       private String pointcutExpression;
+       private PointcutExpression pointcutExpression;
        
        protected AdviceImpl(Method method, String pointcut, AdviceType type) {
                this.kind = type;
                this.adviceMethod = method;
-               this.pointcutExpression = pointcut;
+               this.pointcutExpression = new PointcutExpressionImpl(pointcut);
        }
        
        public AdviceType getKind() {
@@ -47,7 +48,7 @@ public class AdviceImpl implements Advice {
                return adviceName;
        }
        
-       public String getPointcutExpression() {
+       public PointcutExpression getPointcutExpression() {
                return pointcutExpression;
        }
        
index 826b36c19b8592a2b5f29af4117afa298ae30b79..03ea6d40c217c60ddf4f1474864944a9f511f7b3 100644 (file)
@@ -12,6 +12,7 @@
 package org.aspectj.internal.lang.reflect;
 
 import org.aspectj.lang.reflect.DeclareErrorOrWarning;
+import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
  * @author colyer
@@ -19,12 +20,12 @@ import org.aspectj.lang.reflect.DeclareErrorOrWarning;
  */
 public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning {
 
-       private String pc;
+       private PointcutExpression pc;
        private String msg;
        private boolean isError;
        
        public DeclareErrorOrWarningImpl(String pointcut, String message, boolean isError) {
-               this.pc = pointcut;
+               this.pc = new PointcutExpressionImpl(pointcut);
                this.msg = message;
                this.isError = isError;
        }
@@ -32,7 +33,7 @@ public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getPointcutExpression()
         */
-       public String getPointcutExpression() {
+       public PointcutExpression getPointcutExpression() {
                return pc;
        }
 
index a589f79dc6f4484f36deb83492fad9d98078a2d5..819d044bf1b91d35051db263c509647119c90997 100644 (file)
@@ -13,6 +13,7 @@ package org.aspectj.internal.lang.reflect;
 
 import org.aspectj.lang.reflect.PerClause;
 import org.aspectj.lang.reflect.PerClauseKind;
+import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
  * @author colyer
@@ -21,11 +22,11 @@ import org.aspectj.lang.reflect.PerClauseKind;
 public class PerClauseImpl implements PerClause {
 
        private final PerClauseKind kind;
-       private final String pointcutExpression;
+       private final PointcutExpression pointcutExpression;
        
        protected PerClauseImpl(PerClauseKind kind, String pointcutExpression) {
                this.kind = kind;
-               this.pointcutExpression = pointcutExpression;
+               this.pointcutExpression = new PointcutExpressionImpl(pointcutExpression);
        }
        
        /* (non-Javadoc)
@@ -38,7 +39,7 @@ public class PerClauseImpl implements PerClause {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.PerClause#getPointcutExpression()
         */
-       public String getPointcutExpression() {
+       public PointcutExpression getPointcutExpression() {
                return pointcutExpression;
        }
 
diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java
new file mode 100644 (file)
index 0000000..e31bd19
--- /dev/null
@@ -0,0 +1,30 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.internal.lang.reflect;
+
+import org.aspectj.lang.reflect.PointcutExpression;
+
+/**
+ * @author colyer
+ *
+ */
+public class PointcutExpressionImpl implements PointcutExpression {
+       private String expression;
+       
+       public PointcutExpressionImpl(String aPointcutExpression) {
+               this.expression = aPointcutExpression;
+       }
+       
+       public String toString() {
+               return expression;
+       }
+}
index adc1e9510dcae5713bcaf9de6080b85d307f1b32..e0c102f2f86d5a244ca562022a31c9c27df92b87 100644 (file)
@@ -15,6 +15,7 @@ import java.lang.reflect.Method;
 
 import org.aspectj.lang.reflect.AjType;
 import org.aspectj.lang.reflect.Pointcut;
+import org.aspectj.lang.reflect.PointcutExpression;
 
 /**
  * @author colyer
@@ -23,13 +24,13 @@ import org.aspectj.lang.reflect.Pointcut;
 public class PointcutImpl implements Pointcut {
 
        private final String name;
-       private final String pc;
+       private final PointcutExpression pc;
        private final Method baseMethod;
        private final AjType declaringType;
        
        protected PointcutImpl(String name, String pc, Method method, AjType declaringType) {
                this.name = name;
-               this.pc = pc;
+               this.pc = new PointcutExpressionImpl(pc);
                this.baseMethod = method;
                this.declaringType = declaringType;
        }
@@ -37,7 +38,7 @@ public class PointcutImpl implements Pointcut {
        /* (non-Javadoc)
         * @see org.aspectj.lang.reflect.Pointcut#getPointcutExpression()
         */
-       public String getPointcutExpression() {
+       public PointcutExpression getPointcutExpression() {
                return pc;
        }
        
index 3fbc668cd7de4dba7c9119ec0fa7a31cbf5870e4..4792a3ba9cb158d8c2824ca543c05624e2772dd6 100644 (file)
@@ -17,5 +17,5 @@ public interface Advice {
        
        String getName();
        
-       String getPointcutExpression();
+       PointcutExpression getPointcutExpression();
 }
index 4fa4783f038aa299eacaf63f912e19b7cbf0d5d7..c8539c1669ed1d8b24e210e8680d3f3903f5c6a3 100644 (file)
@@ -16,7 +16,7 @@ package org.aspectj.lang.reflect;
  *
  */
 public interface DeclareErrorOrWarning {
-       String getPointcutExpression();
+       PointcutExpression getPointcutExpression();
        String getMessage();
        boolean isError();
        
index 7416ac09d0bee61a020c13c84169f47eb4fe5b21..c3396c5481389d7f239ccdc6a4d2f3e253fe0f9e 100644 (file)
@@ -17,5 +17,5 @@ package org.aspectj.lang.reflect;
  */
 public interface PerClause {
        PerClauseKind getKind();
-       String getPointcutExpression();
+       PointcutExpression getPointcutExpression();
 }
index 0802db4109223d9c8c7a57b9551c355dd9a13966..a82941306f1d3061f29883cf1b06c06edf655a91 100644 (file)
@@ -13,7 +13,7 @@ package org.aspectj.lang.reflect;
 
 public interface Pointcut {
 
-       String getPointcutExpression();
+       PointcutExpression getPointcutExpression();
        
        String getName();
        
diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java
new file mode 100644 (file)
index 0000000..b2ab44d
--- /dev/null
@@ -0,0 +1,24 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *   Adrian Colyer                     Initial implementation
+ * ******************************************************************/
+package org.aspectj.lang.reflect;
+
+/**
+ * Represents an anonymous pointcut expression as used in pointcuts, advice declarations,
+ * declares, and per-clauses
+ */
+public interface PointcutExpression {
+
+       /**
+        * Returns a String representation of the pointcut expression 
+        */
+       String toString();
+}
index 1ecd34516f76357e222c4f008530dac6d8947495..8d0820ecc70c244856133d822f71ee5f59eba66d 100644 (file)
@@ -56,23 +56,23 @@ public class AjTypeTestsWithAspects extends TestCase {
                
                PerClause pc = perThisA.getPerClause();
                assertEquals(PerClauseKind.PERTHIS,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression());
+               assertEquals("pc()",pc.getPointcutExpression().toString());
                
                pc= perTargetA.getPerClause();
                assertEquals(PerClauseKind.PERTARGET,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression());
+               assertEquals("pc()",pc.getPointcutExpression().toString());
 
                pc= perCflowA.getPerClause();
                assertEquals(PerClauseKind.PERCFLOW,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression());
+               assertEquals("pc()",pc.getPointcutExpression().toString());
 
                pc= perCflowbelowA.getPerClause();
                assertEquals(PerClauseKind.PERCFLOWBELOW,pc.getKind());
-               assertEquals("pc()",pc.getPointcutExpression());
+               assertEquals("pc()",pc.getPointcutExpression().toString());
 
                pc= perTypeWithinA.getPerClause();
                assertEquals(PerClauseKind.PERTYPEWITHIN,pc.getKind());
-               assertEquals("org.aspectj..*",pc.getPointcutExpression());
+               assertEquals("org.aspectj..*",pc.getPointcutExpression().toString());
 
        }
        
@@ -143,13 +143,13 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetDeclaredPointcut() throws Exception {
                Pointcut p1 = sa.getDeclaredPointcut("simpleAspectMethodExecution");
                assertEquals("simpleAspectMethodExecution",p1.getName());
-               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression());
+               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().toString());
                assertEquals(sa,p1.getDeclaringType());
                assertEquals(0,p1.getParameterTypes().length);
                assertTrue(Modifier.isPublic(p1.getModifiers()));
                Pointcut p2 = sa.getDeclaredPointcut("simpleAspectCall");
                assertEquals("simpleAspectCall",p2.getName());
-               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression());
+               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().toString());
                assertEquals(sa,p2.getDeclaringType());
                assertEquals(1,p2.getParameterTypes().length);
                assertTrue(Modifier.isPrivate(p2.getModifiers()));
@@ -164,13 +164,13 @@ public class AjTypeTestsWithAspects extends TestCase {
        public void testGetPointcut() throws Exception {
                Pointcut p1 = sa.getPointcut("simpleAspectMethodExecution");
                assertEquals("simpleAspectMethodExecution",p1.getName());
-               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression());
+               assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().toString());
                assertEquals(sa,p1.getDeclaringType());
                assertEquals(0,p1.getParameterTypes().length);
                assertTrue(Modifier.isPublic(p1.getModifiers()));
                Pointcut p2 = sa.getPointcut("simpleAspectCall");
                assertEquals("simpleAspectCall",p2.getName());
-               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression());
+               assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().toString());
                assertEquals(sa,p2.getDeclaringType());
                assertEquals(1,p2.getParameterTypes().length);
                assertTrue(Modifier.isPrivate(p2.getModifiers()));
@@ -212,10 +212,10 @@ public class AjTypeTestsWithAspects extends TestCase {
                assertEquals(4,advice.length);
 
                advice = sa.getDeclaredAdvice(AdviceType.BEFORE);
-               assertEquals("execution(* SimpleAspect.*(..))",advice[0].getPointcutExpression());
+               assertEquals("execution(* SimpleAspect.*(..))",advice[0].getPointcutExpression().toString());
                assertEquals("logEntry",advice[0].getName());
                assertEquals(AdviceType.BEFORE,advice[0].getKind());
-               assertEquals("execution(* SimpleAspect.*(..))",advice[1].getPointcutExpression());
+               assertEquals("execution(* SimpleAspect.*(..))",advice[1].getPointcutExpression().toString());
                assertEquals("",advice[1].getName());
        }
        
@@ -304,11 +304,11 @@ public class AjTypeTestsWithAspects extends TestCase {
                        if (deow.isError()) {
                                if (deow.getMessage().equals("dont call this method code")) foundCodeError = true;
                                if (deow.getMessage().equals("dont call this method ann")) foundAnnError = true;
-                               assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression());
+                               assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression().toString());
                        } else {
                                if (deow.getMessage().equals("dont call this method code")) foundCodeWarning = true;
                                if (deow.getMessage().equals("dont call this method ann")) foundAnnWarning = true;
-                               assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression());                            
+                               assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression().toString());                         
                        }
                }
                assertTrue(foundCodeWarning && foundAnnWarning && foundCodeError && foundAnnError);