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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jul 3 07:28:03 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-07-03 07:28:02 -0400 (Thu, 03 Jul 2008)
New Revision: 75343

Added:
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectAnnotationLoaderStrategy.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManagerAnnotationLoaderStrategy.java
Log:
[JBAOP-607] Make what is done once we have read the annotations pluggable. In AOP we still install things directly into the AspectManager.

(When running in MC/AS5 we need to create AspectManagerAwareBeanMetaDataFactories and install those in the MC)

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectAnnotationLoaderStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectAnnotationLoaderStrategy.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectAnnotationLoaderStrategy.java	2008-07-03 11:28:02 UTC (rev 75343)
@@ -0,0 +1,91 @@
+/*
+* 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;
+
+import org.jboss.aop.advice.PrecedenceDefEntry;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.introduction.InterfaceIntroduction;
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.pointcut.ast.ASTCFlowExpression;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AspectAnnotationLoaderStrategy
+{
+
+   void deployAspect(AspectAnnotationLoader loader, boolean isFactory, String name, Scope scope);
+   
+   void deployAspectMethodBinding(
+         AspectAnnotationLoader loader, 
+         org.jboss.aop.advice.AdviceType internalAdviceType, 
+         String aspectDefName, 
+         String methodName, 
+         String bindingName,
+         String pointcutString,
+         String cflow,
+         ASTCFlowExpression cflowExpression) throws Exception;
+   
+   void undeployAspect(AspectAnnotationLoader loader, String name);
+   
+   void undeployAspectMethodBinding(AspectAnnotationLoader loader, String bindingName, String className, String methodName);
+   
+   void deployInterceptor(AspectAnnotationLoader loader, boolean isFactory, String name, Scope scope);
+   
+   void deployInterceptorBinding(AspectAnnotationLoader loader, String name, String pointcutString, String cflow, ASTCFlowExpression cflowExpression) throws Exception;
+   
+   void undeployInterceptor(AspectAnnotationLoader loader, String name);
+   
+   void undeployInterceptorBinding(AspectAnnotationLoader loader, String name);
+   
+   void deployDynamicCFlow(AspectAnnotationLoader loader, String name, String clazz);
+   
+   void undeployDynamicCFlow(AspectAnnotationLoader loader, String name);
+   
+   void deployPointcut(AspectAnnotationLoader loader, String name, String expr) throws Exception;
+   
+   void undeployPointcut(AspectAnnotationLoader loader, String name);
+   
+   void deployPrecedence(AspectAnnotationLoader loader, String name, PrecedenceDefEntry[] pentries);
+
+   void undeployPrecedence(AspectAnnotationLoader loader, String name);
+   
+   void deployTypedef(AspectAnnotationLoader loader, String name, String expr) throws Exception;
+   
+   void undeployTypedef(AspectAnnotationLoader loader, String name);
+
+   void deployDeclare(AspectAnnotationLoader loader, String name, String expr, boolean warning, String msg) throws Exception;
+   
+   void deployAnnotationIntroduction(AspectAnnotationLoader loader, String expr, String annotation, boolean invisible);
+
+   void undeployAnnotationIntroduction(AspectAnnotationLoader loader, String expr, String annotation, boolean invisible);
+
+   void deployCFlow(AspectAnnotationLoader loader, CFlowStack stack);
+   
+   void undeployCFlow(AspectAnnotationLoader loader, String name);
+   
+   void deployInterfaceIntroduction(AspectAnnotationLoader loader, InterfaceIntroduction introduction);
+
+   void undeployInterfaceIntroduction(AspectAnnotationLoader loader, String name);
+}

Added: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManagerAnnotationLoaderStrategy.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManagerAnnotationLoaderStrategy.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManagerAnnotationLoaderStrategy.java	2008-07-03 11:28:02 UTC (rev 75343)
@@ -0,0 +1,224 @@
+/*
+* 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;
+
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.advice.AdviceFactory;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.AspectFactory;
+import org.jboss.aop.advice.AspectFactoryDelegator;
+import org.jboss.aop.advice.AspectFactoryWithClassLoader;
+import org.jboss.aop.advice.DynamicCFlowDefinition;
+import org.jboss.aop.advice.GenericAspectFactory;
+import org.jboss.aop.advice.InterceptorFactory;
+import org.jboss.aop.advice.PrecedenceDef;
+import org.jboss.aop.advice.PrecedenceDefEntry;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.advice.ScopedInterceptorFactory;
+import org.jboss.aop.introduction.AnnotationIntroduction;
+import org.jboss.aop.introduction.InterfaceIntroduction;
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.pointcut.DeclareDef;
+import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutExpression;
+import org.jboss.aop.pointcut.Typedef;
+import org.jboss.aop.pointcut.TypedefExpression;
+import org.jboss.aop.pointcut.ast.ASTCFlowExpression;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectManagerAnnotationLoaderStrategy implements AspectAnnotationLoaderStrategy
+{
+   
+   public void deployAspect(AspectAnnotationLoader loader, boolean isFactory, String name, Scope scope)
+   {
+      AspectFactory factory = null;
+      if (isFactory)
+      {
+         factory = new AspectFactoryDelegator(name, null);
+         ((AspectFactoryWithClassLoader)factory).setClassLoader(loader.getClassLoader());
+      }
+      else
+      {
+         factory = new GenericAspectFactory(name, null);
+         ((AspectFactoryWithClassLoader)factory).setClassLoader(loader.getClassLoader());
+      }
+      AspectDefinition def = new AspectDefinition(name, scope, factory);
+      loader.getAspectManager().addAspectDefinition(def);
+   }
+   
+   public void deployAspectMethodBinding(
+         AspectAnnotationLoader loader, 
+         org.jboss.aop.advice.AdviceType internalAdviceType, 
+         String aspectDefName, 
+         String methodName, 
+         String bindingName,
+         String pointcutString,
+         String cflow,
+         ASTCFlowExpression cflowExpression)throws Exception
+   {
+      AspectDefinition def = loader.getAspectManager().getAspectDefinition(aspectDefName);
+      AdviceFactory factory = null;
+      if (internalAdviceType == org.jboss.aop.advice.AdviceType.AROUND)
+      {
+         factory = new AdviceFactory(def, methodName);
+      }
+      else
+      {
+         factory = new AdviceFactory(def, methodName, internalAdviceType);
+      }
+      
+      loader.getAspectManager().addInterceptorFactory(factory.getName(), factory);
+      InterceptorFactory[] fact = {factory};
+      PointcutExpression pointcut = new PointcutExpression(bindingName, pointcutString);
+      AdviceBinding abinding = new AdviceBinding(bindingName, pointcut, cflowExpression, cflow, fact);
+      loader.getAspectManager().addBinding(abinding);
+   }
+   
+   public void undeployAspect(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removeAspectDefinition(name);
+   }
+   
+   public void undeployAspectMethodBinding(AspectAnnotationLoader loader, String bindingName, String className, String methodName)
+   {
+      String adviceName = className + "." + methodName;
+      loader.getAspectManager().removeInterceptorFactory(adviceName);
+      loader.getAspectManager().removePointcut(bindingName);
+      loader.getAspectManager().removeBinding(bindingName);
+   }
+   
+   public void deployInterceptor(AspectAnnotationLoader loader, boolean isFactory, String name, Scope scope)
+   {
+      deployAspect(loader, isFactory, name, scope);
+      AspectDefinition def = loader.getAspectManager().getAspectDefinition(name);
+      ScopedInterceptorFactory factory = new ScopedInterceptorFactory(def);
+      loader.getAspectManager().addInterceptorFactory(factory.getName(), factory);
+   }
+   
+   public void deployInterceptorBinding(AspectAnnotationLoader loader, String name, String pointcutString, String cflow, ASTCFlowExpression cflowExpression) throws Exception
+   {
+      InterceptorFactory factory = loader.getAspectManager().getInterceptorFactory(name);
+      InterceptorFactory[] inters = {factory};
+      Pointcut p = null;
+      p = new PointcutExpression(name, pointcutString);
+      AdviceBinding binding = new AdviceBinding(name, p, cflowExpression, cflow, inters);
+      loader.getAspectManager().addBinding(binding);
+
+   }
+   
+   public void undeployInterceptor(AspectAnnotationLoader loader, String name)
+   {
+      undeployAspect(loader, name);
+      loader.getAspectManager().removeInterceptorFactory(name);
+   }
+   
+   public void undeployInterceptorBinding(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removePointcut(name);
+      loader.getAspectManager().removeBinding(name);
+   }
+   
+   public void deployDynamicCFlow(AspectAnnotationLoader loader, String name, String clazz)
+   {
+      loader.getAspectManager().addDynamicCFlow(name, new DynamicCFlowDefinition(null, clazz, name));
+   }
+   
+   public void undeployDynamicCFlow(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removeDynamicCFlow(name);
+   }
+   
+   public void deployPointcut(AspectAnnotationLoader loader, String name, String expr) throws Exception
+   {
+      Pointcut p = new PointcutExpression(name, expr);
+      loader.getAspectManager().addPointcut(p);
+   }
+   
+   public void undeployPointcut(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removePointcut(name);
+   }
+   
+   public void deployPrecedence(AspectAnnotationLoader loader, String name, PrecedenceDefEntry[] pentries)
+   {
+      PrecedenceDef precedenceDef = new PrecedenceDef(name, pentries);
+      loader.getAspectManager().addPrecedence(precedenceDef);
+   }
+   
+   public void undeployPrecedence(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removePointcut(name);
+   }
+
+   public void deployTypedef(AspectAnnotationLoader loader, String name, String expr) throws Exception
+   {
+      Typedef typedef = new TypedefExpression(name, expr);
+      loader.getAspectManager().addTypedef(typedef);
+   }
+   
+   public void undeployTypedef(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removeTypedef(name);
+   }
+   
+   public void deployDeclare(AspectAnnotationLoader loader, String name, String expr, boolean warning, String msg) throws Exception
+   {
+      DeclareDef def = new DeclareDef(name, expr, warning, msg);
+      loader.getAspectManager().addDeclare(def);
+   }
+   
+   public void deployAnnotationIntroduction(AspectAnnotationLoader loader, String expr, String annotation, boolean invisible)
+   {
+      AnnotationIntroduction annIntro = AnnotationIntroduction.createComplexAnnotationIntroduction(expr, annotation, invisible);
+      loader.getAspectManager().addAnnotationIntroduction(annIntro);
+   }
+   
+   public void undeployAnnotationIntroduction(AspectAnnotationLoader loader, String expr, String annotation, boolean invisible)
+   {
+      AnnotationIntroduction annIntro = AnnotationIntroduction.createComplexAnnotationIntroduction(expr, annotation, invisible);
+      loader.getAspectManager().removeAnnotationIntroduction(annIntro);
+   }
+   
+   public void deployCFlow(AspectAnnotationLoader loader, CFlowStack stack)
+   {
+      loader.getAspectManager().addCFlowStack(stack);
+   }
+   
+   public void undeployCFlow(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removeCFlowStack(name);
+   }
+   
+   public void deployInterfaceIntroduction(AspectAnnotationLoader loader, InterfaceIntroduction introduction)
+   {
+      loader.getAspectManager().addInterfaceIntroduction(introduction);
+   }
+   
+   public void undeployInterfaceIntroduction(AspectAnnotationLoader loader, String name)
+   {
+      loader.getAspectManager().removeInterfaceIntroduction(name);
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list