[jboss-cvs] JBossAS SVN: r61164 - in projects/aop/trunk/aop/src/main/org/jboss/aop: microcontainer/lifecycle and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 6 17:20:21 EST 2007
Author: kabir.khan at jboss.com
Date: 2007-03-06 17:20:21 -0500 (Tue, 06 Mar 2007)
New Revision: 61164
Added:
projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackDefinition.java
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackBinding.java
Log:
[JBAOP-372] AOP Support for lifecycle callbacks - need to be able to specify the uninstall/install methods
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java 2007-03-06 22:05:18 UTC (rev 61163)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ReflectiveAspectBinder.java 2007-03-06 22:20:21 UTC (rev 61164)
@@ -42,6 +42,7 @@
import org.jboss.aop.advice.AdviceBinding;
import org.jboss.aop.introduction.AnnotationIntroduction;
import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
+import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackDefinition;
import org.jboss.aop.pointcut.AnnotationMatcher;
import org.jboss.aop.pointcut.PointcutMethodMatch;
import org.jboss.aop.proxy.container.InstanceProxyContainer;
@@ -65,8 +66,8 @@
protected boolean isInstanceContainer;
TLongObjectHashMap methodMap = new TLongObjectHashMap();
- //Lifecycle callbacks are a microcontainer thing
- protected Map<Object, Set<String>> lifecycleCallbacks = new HashMap<Object, Set<String>>();
+ //Lifecycle callbacks are a microcontainer thing, the key is the MC ControllerState
+ protected Map<Object, Set<LifecycleCallbackDefinition>> lifecycleCallbacks = new HashMap<Object, Set<LifecycleCallbackDefinition>>();
boolean initialisedAspects;
boolean intitialisedLifecycleCallbacks;
@@ -93,7 +94,7 @@
return aspects;
}
- public Map<Object, Set<String>> getLifecycleCallbacks()
+ public Map<Object, Set<LifecycleCallbackDefinition>> getLifecycleCallbacks()
{
if (!intitialisedLifecycleCallbacks)
{
@@ -319,15 +320,15 @@
if (binding.matches(advisor, clazz))
{
final Object state = binding.getControllerState();
- Set<String> callbacks = lifecycleCallbacks.get(state);
+ Set<LifecycleCallbackDefinition> callbacks = lifecycleCallbacks.get(state);
if (callbacks == null)
{
- callbacks = new HashSet<String>();
+ callbacks = new HashSet<LifecycleCallbackDefinition>();
lifecycleCallbacks.put(state, callbacks);
}
- List<String> boundCallbacks = binding.getLifecycleCallbacks();
- for (String callback : boundCallbacks)
+ List<LifecycleCallbackDefinition> boundCallbacks = binding.getLifecycleCallbacks();
+ for (LifecycleCallbackDefinition callback : boundCallbacks)
{
System.out.println("=====> Adding lifecycle " + callback + ":" + state);
callbacks.add(callback);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackBinding.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackBinding.java 2007-03-06 22:05:18 UTC (rev 61163)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackBinding.java 2007-03-06 22:20:21 UTC (rev 61164)
@@ -58,13 +58,14 @@
/**
* A list of beans
*/
- List<String> lifecycleCallbacks = new ArrayList();
+ List<LifecycleCallbackDefinition> lifecycleCallbackDefinitions = new ArrayList<LifecycleCallbackDefinition>();
/**
* This will be an instance of org.jboss.dependency.spi.ControllerState from the MC project
*/
Object controllerState;
+
public LifecycleCallbackBinding(String name, String classString, String typeExpression, Object controllerState) throws Exception
{
this.name = name;
@@ -89,19 +90,20 @@
this.controllerState = controllerState;
}
+
public String getName()
{
return name;
}
- public void addLifecycleCallback(String name)
+ public void addLifecycleCallback(String bean, String installMethod, String uninstallMethod)
{
- lifecycleCallbacks.add(name);
+ lifecycleCallbackDefinitions.add(new LifecycleCallbackDefinition(bean, installMethod, uninstallMethod));
}
- public List<String> getLifecycleCallbacks()
+ public List<LifecycleCallbackDefinition> getLifecycleCallbacks()
{
- return lifecycleCallbacks;
+ return lifecycleCallbackDefinitions;
}
public boolean equals(Object obj)
Added: projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackDefinition.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackDefinition.java (rev 0)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/microcontainer/lifecycle/LifecycleCallbackDefinition.java 2007-03-06 22:20:21 UTC (rev 61164)
@@ -0,0 +1,70 @@
+/*
+* 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.microcontainer.lifecycle;
+
+/**
+ * Represents a bean that is used for callbacks
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleCallbackDefinition
+{
+ /**
+ * The name of the bean implementing the callback
+ */
+ private String bean;
+
+ /**
+ * The method to call on installation
+ */
+ private String installMethod;
+
+ /**
+ * The method to call on uninstallation
+ */
+ private String uninstallMethod;
+
+ public LifecycleCallbackDefinition(String bean, String installMethod, String uninstallMethod)
+ {
+ this.bean = bean;
+ this.installMethod = installMethod;
+ this.uninstallMethod = uninstallMethod;
+ }
+
+ public String getBean()
+ {
+ return bean;
+ }
+
+ public String getInstallMethod()
+ {
+ return installMethod;
+ }
+
+ public String getUninstallMethod()
+ {
+ return uninstallMethod;
+ }
+
+
+}
More information about the jboss-cvs-commits
mailing list