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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 10 06:23:51 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-04-10 06:23:51 -0400 (Thu, 10 Apr 2008)
New Revision: 71900

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
Log:
Add hasAnnotation(Field, Class)

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-04-10 10:16:19 UTC (rev 71899)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-04-10 10:23:51 UTC (rev 71900)
@@ -347,7 +347,7 @@
    {
       return resolveTypedAnnotation(annotation);
    }
-   
+
    public <T extends Annotation> T resolveTypedAnnotation(Class<T> annotation)
    {
       if (metadata != null)
@@ -421,7 +421,7 @@
    {
       return resolveTypedAnnotation(0, m, annotation);
    }
-   
+
    public <T extends Annotation> T resolveTypedAnnotation(Method m, Class<T> annotation)
    {
       return resolveTypedAnnotation(0, m, annotation);
@@ -431,7 +431,7 @@
    {
       return resolveTypedAnnotation(hash, m, annotation);
    }
-   
+
    public <T extends Annotation> T resolveTypedAnnotation(long hash, Method m, Class<T> annotation)
    {
       if (metadata != null)
@@ -450,7 +450,7 @@
 
       //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
       T value = (T)annotations.resolveAnnotation(m, annotation);
-      if (value == null && metadata == null) 
+      if (value == null && metadata == null)
       {
          value = AnnotationElement.getVisibleAnnotation(m, annotation);
       }
@@ -482,7 +482,7 @@
    {
       return resolveTypedAnnotation(f, annotation);
    }
-   
+
    public <T extends Annotation> T resolveTypedAnnotation(Field f, Class<T> annotation)
    {
       T value = null;
@@ -496,7 +496,7 @@
             if (value != null) return value;
          }
       }
-      
+
       //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
       value = (T)annotations.resolveAnnotation(f, annotation);
       if (value == null && metadata == null)
@@ -510,7 +510,7 @@
    {
       return resolveTypedAnnotation(c, annotation);
    }
-   
+
    public <T extends Annotation> T resolveTypedAnnotation(Constructor<?> c, Class<T> annotation)
    {
       T value = null;
@@ -524,7 +524,7 @@
             if (value != null) return value;
          }
       }
-      
+
       //MUST call this instead of AR.resolveTypedClassAnnotation since EJB3 overrides AR.resolveClassAnnotation
       value = (T)annotations.resolveAnnotation(c, annotation);
       if (value == null && metadata == null)
@@ -578,6 +578,11 @@
       return false;
    }
 
+   public boolean hasAnnotation(Field m, Class<? extends Annotation> annotation)
+   {
+      return hasAnnotation(m, annotation.getName());
+   }
+
    public boolean hasAnnotation(Field m, String annotation)
    {
       if (metadata != null)
@@ -642,7 +647,7 @@
       }
       return false;
    }
-   
+
    public boolean hasAnnotation(CtClass clazz, String annotation)
    {
       if (annotations.hasClassAnnotation(annotation)) return true;
@@ -679,7 +684,7 @@
 
    /**
     * Get the metadata
-    * 
+    *
     * @return the metadata
     */
    public MetaData getMetadata()
@@ -689,7 +694,7 @@
 
    /**
     * Set the metadata
-    * 
+    *
     * FIXME why does this have java.lang.Object signature?
     * @param metadata the metadata
     */
@@ -738,7 +743,7 @@
 
    public synchronized void addInterfaceIntroduction(InterfaceIntroduction pointcut)
    {
-      initInterfaceIntroductionsList();      
+      initInterfaceIntroductionsList();
       interfaceIntroductions.add(pointcut);
    }
 
@@ -758,12 +763,12 @@
    public abstract void removeClassMetaData(ClassMetaDataBinding data);
 
    // This is aspect stuff.  Aspect again, is a class that encapsulates advices
-   
+
    public Object getPerVMAspect(AspectDefinition def)
    {
       return getManager().getPerVMAspect(def);
    }
-   
+
    public void addPerInstanceAspect(AspectDefinition def)
    {
       initPerInstanceAspectDefinitionsSet();
@@ -808,7 +813,7 @@
       }
       setJoinpoints.addAll(joinpoints);
    }
-   
+
    public void removePerInstanceJoinpointAspect(AspectDefinition def)
    {
       perInstanceJoinpointAspectDefinitions.remove(def);
@@ -891,7 +896,7 @@
       {
          Method method = (Method) advisedMethods.get(keys[i]);
          PointcutMethodMatch match = binding.getPointcut().matchesExecution(this, method);
-         
+
          if (match != null && match.isMatch())
          {
             adviceBindings.add(binding);
@@ -926,7 +931,7 @@
          methodMatchInfo.getInfo().getInterceptorChainReadWriteLock().writeLock().lock();
       }
    }
-   
+
    protected void unlockWriteChain(MethodInterceptors methodInterceptors)
    {
       Object[] methodMatchInfos = methodInterceptors.infos.getValues();
@@ -936,7 +941,7 @@
          methodMatchInfo.getInfo().getInterceptorChainReadWriteLock().writeLock().unlock();
       }
    }
-   
+
    protected void resetChain(MethodInterceptors methodInterceptors)
    {
       Object[] methodMatchInfos = methodInterceptors.infos.getValues();
@@ -954,12 +959,12 @@
          methodMatchInfo.getInfo().clear();
       }
    }
-   
+
    protected void finalizeMethodChain()
    {
       boolean maintain = AspectManager.maintainAdvisorMethodInterceptors;
       TLongObjectHashMap newMethodInfos = (maintain) ? new TLongObjectHashMap() : null;
-      
+
       long[] keys = methodInfos.keys();
       for (int i = 0; i < keys.length; i++)
       {
@@ -973,7 +978,7 @@
             interceptors = applyPrecedence(list.toArray(new Interceptor[list.size()]));
          }
          info.setInterceptors(interceptors);
-         
+
          if (maintain)
          {
             newMethodInfos.put(keys[i], info);
@@ -1141,7 +1146,7 @@
          info.setInterceptors(interceptors);
       }
    }
-   
+
    protected void lockWriteChain(JoinPointInfo[] infos)
    {
       for (int i = 0; i < infos.length; i++)
@@ -1149,7 +1154,7 @@
          infos[i].getInterceptorChainReadWriteLock().writeLock().lock();
       }
    }
-   
+
    protected void unlockWriteChain(JoinPointInfo[] infos)
    {
       for (int i = 0; i < infos.length; i++)
@@ -1157,7 +1162,7 @@
          infos[i].getInterceptorChainReadWriteLock().writeLock().unlock();
       }
    }
-   
+
    protected void resetChain(JoinPointInfo[] infos)
    {
       for (int i = 0; i < infos.length; i++)
@@ -1165,9 +1170,9 @@
          infos[i].clear();
       }
    }
-   
-   
 
+
+
 //   protected void finalizeConstructionChain(ArrayList newConstructionInfos)
 //   {
 //      for (int i = 0; i < newConstructionInfos.size(); i++)
@@ -1291,7 +1296,7 @@
       //Implemented by base-classes
       throw new NotImplementedException("Not a legal operation for Advisor");
    }
-   
+
    interface DeployAnnotationOverrideAction
    {
       void deploy(Advisor advisor, AnnotationIntroduction introduction);
@@ -1331,7 +1336,7 @@
          }
       };
    }
-   
+
    public void cleanup()
    {
       //AspectDefinitions have strong links back to us
@@ -1340,7 +1345,7 @@
          removePerInstanceAspect(def);
          def.unregisterAdvisor(this);
       }
-      
+
       for(AspectDefinition def : perInstanceJoinpointAspectDefinitions.keySet())
       {
          removePerInstanceJoinpointAspect(def);
@@ -1356,13 +1361,13 @@
             defs[i].unregisterAdvisor(this);
          }
       }
-            
+
       if (methodInfos != null)
       {
          methodInfos. clear();
       }
    }
-   
+
    protected void initInterfaceIntroductionsList()
    {
       if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
@@ -1376,7 +1381,7 @@
          }
       }
    }
-   
+
    protected void initClassMetaDataBindingsList()
    {
       if (classMetaDataBindings == UnmodifiableEmptyCollections.EMPTY_ARRAYLIST)
@@ -1390,7 +1395,7 @@
          }
       }
    }
-   
+
    protected void initPerInstanceAspectDefinitionsSet()
    {
       if (perInstanceAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET)
@@ -1404,7 +1409,7 @@
          }
       }
    }
-   
+
    protected void initPerInstanceJoinpointAspectDefinitionsMap()
    {
       if (perInstanceJoinpointAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
@@ -1432,4 +1437,5 @@
          }
       }
    }
+
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list