/** returns an unsubmitted task which invokes the given effector; use {@link Entities#invokeEffector(EntityLocal, Entity, Effector, Map)} for a submitted variant */ public static <T> TaskAdaptable<T> invocation(Entity entity, Effector<T> eff, @SuppressWarnings("rawtypes") Map parameters) { @SuppressWarnings("unchecked") Effector<T> eff2 = (Effector<T>) ((EntityInternal)entity).getEffector(eff.getName()); if (log.isTraceEnabled()) log.trace("invoking "+eff+"/"+ (eff instanceof EffectorWithBody<?> ? ((EffectorWithBody<?>)eff).getBody() : "bodyless")+ " on entity " + entity+" "+ (eff2==eff ? "" : " (actually "+eff2+"/"+ (eff2 instanceof EffectorWithBody<?> ? ((EffectorWithBody<?>)eff2).getBody() : "bodyless")+")")); if (eff2!=null) { if (eff2!=eff) { if (eff2 instanceof EffectorWithBody) { log.debug("Replacing invocation of {} on {} with {} which is the impl defined at that entity", new Object[] { eff, entity, eff2 }); return ((EffectorWithBody<T>)eff2).getBody().newTask(entity, eff2, ConfigBag.newInstance().putAll(parameters)); } else { log.warn("Effector {} defined on {} has no body; invoking caller-supplied {} instead", new Object[] { eff2, entity, eff }); } } else { log.debug("Effector {} does not exist on {}; attempting to invoke anyway", new Object[] { eff, entity }); } } if (eff instanceof EffectorWithBody) { return ((EffectorWithBody<T>)eff).getBody().newTask(entity, eff, ConfigBag.newInstance().putAll(parameters)); } throw new UnsupportedOperationException("No implementation registered for effector "+eff+" on "+entity); }