[jboss-cvs] JBossAS SVN: r60943 - projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 27 09:50:25 EST 2007


Author: alesj
Date: 2007-02-27 09:50:25 -0500 (Tue, 27 Feb 2007)
New Revision: 60943

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/AbstractIntroduction.java
Log:
Introduction helper class.

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/AbstractIntroduction.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/AbstractIntroduction.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/AbstractIntroduction.java	2007-02-27 14:50:25 UTC (rev 60943)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.aop.microcontainer.aspects;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * Abstract helper class for [Aspect]Introduction.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractIntroduction implements Interceptor
+{
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   protected abstract Class<? extends Annotation> getBindingAnnotation();
+
+   protected boolean isBindingInfoPresent(Invocation invocation)
+   {
+      return invocation.resolveClassAnnotation(getBindingAnnotation()) != null;
+   }
+
+   protected void onRegistration(Invocation invocation, KernelControllerContext context)
+   {
+      onRegistration(context);
+   }
+
+   protected void onRegistration(KernelControllerContext context)
+   {
+   }
+
+   protected void onUnregistration(Invocation invocation, KernelControllerContext context)
+   {
+      onUnregistration(context);
+   }
+
+   protected void onUnregistration(KernelControllerContext context)
+   {
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      MethodInvocation mi = (MethodInvocation) invocation;
+      KernelControllerContext context = (KernelControllerContext) mi.getArguments()[0];
+      String methodName = mi.getMethod().getName();
+      boolean infoPresent = isBindingInfoPresent(invocation);
+
+      if ("setKernelControllerContext".equals(methodName) && infoPresent)
+      {
+         onRegistration(invocation, context);
+      }
+      else if (infoPresent)
+      {
+         onUnregistration(invocation, context);
+      }
+
+      return null;
+   }
+}




More information about the jboss-cvs-commits mailing list