cancel
Showing results for 
Search instead for 
Did you mean: 

Possible to register commands via spring configuration?

benvercammen
Champ in-the-making
Champ in-the-making
I hope this is a simple question; is it possible to register commands via Spring configuration? I've seen some documentation that states that you need to create your own CommandProcessor and then register the commands in a static block, but that seems to be a lot of overkill for something as (seemingly) trivial as registering one single command.

In the current case, I'm looking for a way to add a command to the UIActionCommandProcessor, but currently to no avail…

All help, hints and tips are welcome!
1 REPLY 1

benvercammen
Champ in-the-making
Champ in-the-making
For those interested in how I've currently registered my custom command…

In web-client-config-custom.xml:

     <config evaluator="string-compare" condition="Command Servlet">
        <command-servlet>
           <command-processor name="custom" class="….CustomCommandProcessor" />
        </command-servlet>
     </config>

In the CustomCommandProcessor class:

public class CustomCommandProcessor implements CommandProcessor {
   static {
      // add our commands to the command registry
      CommandFactory.getInstance().registerCommand("createwebpage", CreateWebPageCommand.class);
   }
   
   public void outputStatus(PrintWriter out) {
      // don't do anything
   }

   public void process(ServiceRegistry serviceRegistry, HttpServletRequest request, String command) {
      // don't do anything
   }

   public boolean validateArguments(ServletContext sc, String command, Map<String, String> args, String[] urlElements) {
      return false;
   }
}


What I am asking though is if it's possible to have Alfresco pick something like this up automatically:

          <!– THIS DOES NOT WORK, THIS IS HOW I WOULD LIKE IT TO WORK, SO I CAN AVOID THE ABOVE CONFIGURATION AND IMPLEMENTATION –>
     <config evaluator="string-compare" condition="Command">
        <command-servlet>
           <command-processor name="createwebpage" class="….CreateWebPageCommand" />
        </command-servlet>
     </config>

Anybody knows if there's a way to do so or if there's a good reason not to do so?