[jboss-cvs] JBossAS SVN: r70175 - in projects/aop/trunk/aop/src/main/org/jboss/aop: util and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 27 09:33:23 EST 2008


Author: kabir.khan at jboss.com
Date: 2008-02-27 09:33:23 -0500 (Wed, 27 Feb 2008)
New Revision: 70175

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/util/MetaDataUtil.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
Log:
Encapsulate the metadata annotation checks

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-02-27 14:30:33 UTC (rev 70174)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java	2008-02-27 14:33:23 UTC (rev 70175)
@@ -71,6 +71,7 @@
 import org.jboss.aop.metadata.MethodMetaData;
 import org.jboss.aop.metadata.SimpleMetaData;
 import org.jboss.aop.pointcut.PointcutMethodMatch;
+import org.jboss.aop.util.MetaDataUtil;
 import org.jboss.aop.util.UnmodifiableEmptyCollections;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.metadata.spi.signature.ConstructorSignature;
@@ -392,7 +393,7 @@
 
       if (metadata != null)
       {
-         if (metadata.isMetaDataPresent(annotation)) return true;
+         if (MetaDataUtil.isAnnotationPresent(metadata, annotation)) return true;
       }
 
       if (annotations.hasClassAnnotation(annotation)) return true;
@@ -595,7 +596,7 @@
             MetaData md = metadata.getComponentMetaData(sig);
             if (md != null)
             {
-               if (md.isMetaDataPresent(annotation))
+               if (MetaDataUtil.isAnnotationPresent(metadata, annotation))
                   return true;
             }
          }

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/util/MetaDataUtil.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/util/MetaDataUtil.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/util/MetaDataUtil.java	2008-02-27 14:33:23 UTC (rev 70175)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.aop.util;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataUtil
+{
+   public static boolean isAnnotationPresent(MetaData metaData, String name)
+   {
+      if (metaData == null)
+         throw new IllegalArgumentException("Null metadata");
+
+      Object test = metaData.isMetaDataPresent(name);
+      return test != null && (test instanceof Annotation);
+   }
+}




More information about the jboss-cvs-commits mailing list