diff --git a/src/main/java/com/syncleus/grail/graph/action/AbstractActionTrigger.java b/src/main/java/com/syncleus/grail/graph/action/AbstractActionTrigger.java index a2f80859873d8ffe4054bc61e34bb62208169789..0e705afcc03ada00c3c4d532e0b8021b188abfe9 100644 --- a/src/main/java/com/syncleus/grail/graph/action/AbstractActionTrigger.java +++ b/src/main/java/com/syncleus/grail/graph/action/AbstractActionTrigger.java @@ -4,13 +4,13 @@ import java.lang.reflect.Method; import java.util.*; public abstract class AbstractActionTrigger implements ActionTrigger { - private final static Map<Class<?>, Map<String, Method>> ACTION_METHOD_CACHE = new HashMap<>(); + private final static Map<Class<?>, Map<String, Set<Method>>> ACTION_METHOD_CACHE = new HashMap<>(); - protected static final Map<String, Method> populateCache(final Class<?> parentClass) { - Map<String, Method> actionMethods = AbstractActionTrigger.ACTION_METHOD_CACHE.get(parentClass); + protected static final Map<String, Set<Method>> populateCache(final Class<?> parentClass) { + Map<String, Set<Method>> actionMethods = AbstractActionTrigger.ACTION_METHOD_CACHE.get(parentClass); if( actionMethods != null ) return actionMethods; - actionMethods = new HashMap<String, Method>(); + actionMethods = new HashMap<String, Set<Method>>(); AbstractActionTrigger.ACTION_METHOD_CACHE.put(parentClass, actionMethods); for(Class<?> triggerClass : parentClass.getInterfaces() ) { @@ -20,11 +20,18 @@ public abstract class AbstractActionTrigger implements ActionTrigger { if (actionAnnotation != null ) { if (triggerMethod.getParameterCount() > 0) throw new IllegalStateException("A method annotated with @Action required parameters"); - actionMethods.put(actionAnnotation.value(), triggerMethod); + + Set<Method> methods = actionMethods.get(actionAnnotation.value()); + if( methods == null ) { + methods = new HashSet<Method>(); + actionMethods.put(actionAnnotation.value(), methods); + } + + methods.add(triggerMethod); } } } - return actionMethods; + return Collections.unmodifiableMap(actionMethods); } } diff --git a/src/main/java/com/syncleus/grail/graph/action/AbstractPrioritySerialTrigger.java b/src/main/java/com/syncleus/grail/graph/action/AbstractPrioritySerialTrigger.java index 915ff405ff5de6fc3d050f186ee0db02d02e22af..e909eec53010164eebff94dcc16c1427128dc8fd 100644 --- a/src/main/java/com/syncleus/grail/graph/action/AbstractPrioritySerialTrigger.java +++ b/src/main/java/com/syncleus/grail/graph/action/AbstractPrioritySerialTrigger.java @@ -20,20 +20,22 @@ public abstract class AbstractPrioritySerialTrigger extends AbstractActionTrigge final Class<?> parentClass = triggerObject.getClass(); - Map<String, Method> actionMethods = AbstractPrioritySerialTrigger.populateCache(parentClass); + Map<String, Set<Method>> actionMethods = AbstractPrioritySerialTrigger.populateCache(parentClass); - final Method triggerMethod = actionMethods.get(actionName); - if( triggerMethod == null ) + final Set<Method> triggerMethods = actionMethods.get(actionName); + if( triggerMethods == null || triggerMethods.size() <= 0 ) throw new IllegalStateException("A ActionTrigger was configured to trigger an action which does not exist on the current object"); - try { - triggerMethod.invoke(triggerObject, null); - } - catch (final IllegalAccessException caught) { - throw new IllegalStateException("Tried to trigger an action method but can not access", caught); - } - catch (final InvocationTargetException caught) { - throw new IllegalStateException("Tried to trigger an action method but can not access", caught); + for( final Method triggerMethod : triggerMethods ) { + try { + triggerMethod.invoke(triggerObject, null); + } + catch (final IllegalAccessException caught) { + throw new IllegalStateException("Tried to trigger an action method but can not access", caught); + } + catch (final InvocationTargetException caught) { + throw new IllegalStateException("Tried to trigger an action method but can not access", caught); + } } } }