[jboss-cvs] JBossAS SVN: r89173 - in projects/microcontainer/trunk/aop-mc-int/src: test/java/org/jboss/test/microcontainer/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 20 08:38:52 EDT 2009


Author: alesj
Date: 2009-05-20 08:38:52 -0400 (Wed, 20 May 2009)
New Revision: 89173

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisabledType.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/test/AnnotationsTestCase.java
Modified:
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java
Log:
[JBKERNEL-31]; add fine grained disabled types.

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java	2009-05-20 12:30:05 UTC (rev 89172)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java	2009-05-20 12:38:52 UTC (rev 89173)
@@ -37,4 +37,10 @@
 @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
 public @interface DisableAOP 
 {
+   /**
+    * The disabled types.
+    *
+    * @return the disabled types
+    */
+   DisabledType[] value() default {DisabledType.ALL};
 }

Added: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisabledType.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisabledType.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisabledType.java	2009-05-20 12:38:52 UTC (rev 89173)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.microcontainer.annotations;
+
+/**
+ * Fine grained disable type.
+ * e.g. LIFECYCLE only disable aop lifecycle callbacks
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public enum DisabledType
+{
+   ALL(~0),
+   LIFECYCLE(1),
+   POINTCUTS(1 << 1);
+
+   private int bits;
+
+   DisabledType(int bits)
+   {
+      this.bits = bits;
+   }
+
+   /**
+    * Is the type disabled for this constraint.
+    *
+    * @param constraint the constraint
+    * @return true if disabled for this constraint
+    */
+   public boolean isDisabled(DisabledType constraint)
+   {
+      int and = bits & constraint.bits;
+      return and == constraint.bits;
+   }
+
+   /**
+    * Do values mark disabled usage.
+    *
+    * @param values the disabled values
+    * @param constraint the constraint
+    * @return true if disabled for this constraint
+    */
+   public static boolean isDisabled(DisabledType[] values, DisabledType constraint)
+   {
+      if (values == null || values.length == 0)
+         return false;
+
+      for (DisabledType value : values)
+      {
+         if (value.isDisabled(constraint))
+            return true;
+      }
+
+      return false;
+   }
+}

Copied: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/test/AnnotationsTestCase.java (from rev 88788, projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/test/AnnotationsInProxyTestCase.java)
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/test/AnnotationsTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/test/AnnotationsTestCase.java	2009-05-20 12:38:52 UTC (rev 89173)
@@ -0,0 +1,80 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt 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.test.microcontainer.test;
+
+import junit.framework.Test;
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.aop.microcontainer.annotations.DisabledType;
+
+/**
+ * Annotations test case.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationsTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(AnnotationsTestCase.class);
+   }
+
+   public AnnotationsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testDisabledType() throws Exception
+   {
+      DisabledType all = DisabledType.ALL;
+      assertTrue(all.isDisabled(DisabledType.ALL));
+      assertTrue(all.isDisabled(DisabledType.LIFECYCLE));
+      assertTrue(all.isDisabled(DisabledType.POINTCUTS));
+
+      DisabledType lifecycle = DisabledType.LIFECYCLE;
+      assertFalse(lifecycle.isDisabled(DisabledType.ALL));
+      assertTrue(lifecycle.isDisabled(DisabledType.LIFECYCLE));
+      assertFalse(lifecycle.isDisabled(DisabledType.POINTCUTS));
+
+      DisabledType pointcut = DisabledType.POINTCUTS;
+      assertFalse(pointcut.isDisabled(DisabledType.ALL));
+      assertFalse(pointcut.isDisabled(DisabledType.LIFECYCLE));
+      assertTrue(pointcut.isDisabled(DisabledType.POINTCUTS));
+
+      DisabledType[] three = {all, lifecycle, pointcut};
+      assertTrue(DisabledType.isDisabled(three, DisabledType.ALL));
+      assertTrue(DisabledType.isDisabled(three, DisabledType.LIFECYCLE));
+      assertTrue(DisabledType.isDisabled(three, DisabledType.POINTCUTS));
+
+      DisabledType[] two = {all, lifecycle};
+      assertTrue(DisabledType.isDisabled(two, DisabledType.ALL));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.LIFECYCLE));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.POINTCUTS));
+      two = new DisabledType[]{all, pointcut};
+      assertTrue(DisabledType.isDisabled(two, DisabledType.ALL));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.LIFECYCLE));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.POINTCUTS));
+      two = new DisabledType[]{lifecycle, pointcut};
+      assertFalse(DisabledType.isDisabled(two, DisabledType.ALL));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.LIFECYCLE));
+      assertTrue(DisabledType.isDisabled(two, DisabledType.POINTCUTS));
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list