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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 3 08:02:42 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-11-03 08:02:40 -0500 (Fri, 03 Nov 2006)
New Revision: 58073

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java
Log:
Start migrating to org.jboss.metadata instead of org.jboss.repository for the AOP metadata

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2006-11-03 13:02:06 UTC (rev 58072)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2006-11-03 13:02:40 UTC (rev 58073)
@@ -55,7 +55,6 @@
 import org.jboss.aop.annotation.AnnotationRepository;
 import org.jboss.aop.instrument.ConstructionTransformer;
 import org.jboss.aop.instrument.ConstructorExecutionTransformer;
-import org.jboss.aop.instrument.FieldAccessTransformer;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.introduction.InterfaceIntroduction;
 import org.jboss.aop.joinpoint.ConstructorJoinpoint;
@@ -63,13 +62,13 @@
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aop.joinpoint.Joinpoint;
 import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.joinpoint.MethodJoinpoint;
 import org.jboss.aop.metadata.ClassMetaDataBinding;
 import org.jboss.aop.metadata.ConstructorMetaData;
 import org.jboss.aop.metadata.FieldMetaData;
 import org.jboss.aop.metadata.MethodMetaData;
 import org.jboss.aop.metadata.SimpleMetaData;
 import org.jboss.aop.pointcut.PointcutMethodMatch;
+import org.jboss.aop.util.MethodHashing;
 import org.jboss.repository.spi.MetaDataContext;
 import org.jboss.util.NestedRuntimeException;
 
@@ -355,10 +354,42 @@
 
    public boolean hasAnnotation(Class tgt, String annotation)
    {
-      if (metadataContext != null)
+      return hasAnnotation(tgt, annotation, null);
+   }
+   
+   public boolean hasAnnotation(Class tgt, Class annotation)
+   {
+      return hasAnnotation(tgt, null, annotation);
+   }
+   
+   private boolean hasAnnotation(Class tgt, String annotation, Class annotationClass)
+   {
+      if (annotation == null && annotationClass == null)
       {
-         if (metadataContext.hasAnnotation(annotation)) return true;
+         throw new RuntimeException("annotation or annotationClass must be passed in");
       }
+      
+      try
+      {
+         if (metadataContext != null)
+         {
+            if (annotationClass == null)
+            {
+               annotationClass = Thread.currentThread().getContextClassLoader().loadClass(annotation);
+            }
+            if (metadataContext.hasAnnotation(annotationClass)) return true;
+         }
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      
+      if (annotation == null)
+      {
+         annotation = annotationClass.getName();
+      }
+      
       if (annotations.hasClassAnnotation(annotation)) return true;
       if (tgt == null) return false;
       try
@@ -373,9 +404,18 @@
 
    public Object resolveAnnotation(Method m, Class annotation)
    {
+      return resolveAnnotation(0, m, annotation);
+   }
+   
+   public Object resolveAnnotation(long hash, Method m, Class annotation)
+   {
       if (metadataContext != null)
       {
-         Object val = metadataContext.getAnnotation(m, annotation);
+         if (hash == 0)
+         {
+            hash = MethodHashing.calculateHash(m);            
+         }
+         Object val = metadataContext.getAnnotationForMethod(hash, annotation);
          if (val != null) return val;
       }
       
@@ -418,11 +458,47 @@
 
    public boolean hasAnnotation(Method m, String annotation)
    {
-      if (metadataContext != null)
+      return hasAnnotation(0, m, annotation, null);
+   }
+   
+   public boolean hasAnnotation(Method m, Class annotation)
+   {
+      return hasAnnotation(0, m, null, annotation);
+   }
+   
+   private boolean hasAnnotation(long hash, Method m, String annotation, Class annotationClass)
+   {
+      if (annotation == null && annotationClass == null)
       {
-         if (metadataContext.hasAnnotation(m, annotation)) return true;
+         throw new RuntimeException("annotation or annotationClass must be passed in");
       }
+
+      try
+      {
+         if (metadataContext != null)
+         {
+            if (hash == 0)
+            {
+               hash = MethodHashing.methodHash(m);
+            }
+            if (annotationClass == null)
+            {
+               annotationClass = Thread.currentThread().getContextClassLoader().loadClass(annotation);
+            }
+            if (metadataContext.hasAnnotationForMethod(hash, annotationClass))
+               return true;
+         }
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }      
       
+      if (annotation == null)
+      {
+         annotation = annotationClass.getName();
+      }
+      
       if (annotations.hasAnnotation(m, annotation)) return true;
       try
       {

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	2006-11-03 13:02:06 UTC (rev 58072)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodInvocation.java	2006-11-03 13:02:40 UTC (rev 58073)
@@ -182,7 +182,7 @@
 
       if (getAdvisor() != null)
       {
-         val = getAdvisor().resolveAnnotation(getMethod(), annotation);
+         val = getAdvisor().resolveAnnotation(getMethodHash(), getMethod(), annotation);
          if (val != null) return val;
       }
 




More information about the jboss-cvs-commits mailing list