AnsweredAssumed Answered

Executing code from the web client

Question asked by peterm on Apr 4, 2006
Latest reply on Apr 4, 2006 by rwetherall
Something I've found useful when developing with Alfresco is the ability to execute different sorts of code from the web client. Sometimes its nice to be able to run some code against the repository without having to set up complex test data in a unit test or run a remote client. So I created a simple action executor that (with a bit of configuration) can execute any class that implements a particular interface.

The executor looks like this…

public class GenericActionExecuter extends ActionExecuterAbstractBase {
    public static final String NAME = "action-generic";
    private ActionExecutable target;
    private List<Object> executionArgs;

    public void setExecutionArgs(List<Object> executionArgs) {
        this.executionArgs = executionArgs;

    public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) {
        target.doExecute(ruleAction, actionedUponNodeRef, executionArgs);

    protected void addParameterDefintions(List<ParameterDefinition> paramList) {

    public void setTarget(ActionExecutable target) { = target;
Any class that implements this interface…

public interface ActionExecutable {

    public void doExecute(Action ruleAction, NodeRef actionedUponNodeRef, List<Object> args);
    public void doAddParameterDefintions(List<ParameterDefinition> paramList);


…can be wired by Spring to be executed from the web client's run action interface. Not a replacement for a unit test, but a quick way to run some code against a repository and visually see the results.