Goal
- To define new (more logical?) structure of where commands are implemented and defined.
- Allow easier use of commands by the App developers.
- Remove command pooling.
Further (future) goals:
- Better documentation (list of commands with description, and for each command a list of parameters).
- Get rid of the Commons Chain library (see Greg's comment).
- Allow commands to be injected.
- Allow configuration-by-code for commands.
Current Status
The above class diagram represents the current distribution of the command classes into the (basic) packages. As we want to get rid of the Admin Interface module, we need to move the MessageCommand
class and the whole tree of the BaseRepositoryCommand
class to the another package(s).
Proposal
The command classes related to the activation (marked green on the above image) will be moved to the Activation module (package i.m.module.activation.commands
), the rest will be moved to the Core module, to the i.m.commands.impl
package.
The CommandsManager
class will be extended with a method executeCommand(String catalog, String command, Map<String,Object> parameters)
, that will allow to run commands without need to handle Context etc. The UI classes (actions etc.) should use command by calling this method (i.e. this will be the preferred method, but not the only one).
Command Definitions Reorganisation
The commands are still defined in particular modules, as described in http://documentation.magnolia-cms.com/technical-guide/commands.html - but the catalogs are now additive, i.e. it is possible to define a catalog in one module, and add a new command to the catalog in another module. Anyway, it is still forbidden to have two command of the same name in the catalog - if such situation happens, the CommandsManager
will produce RuntimeException
on its initialisation.
Besides the commands in independent modules (e.g. Data or Forum), there are following commands definitions in the (old) Admin Interface and DMS modules that requires to be moved:
Old path | New path | Note |
---|---|---|
/modules/adminInterface/commands/default/activate | /modules/activation/commands/default/activate | |
/modules/adminInterface/commands/default/deactivate | /modules/activation/commands/default/deactivate | |
/modules/adminInterface/commands/website/activate | /modules/ui-pages-app/commands/website/activate | Composite command, composed of 'version' and 'default-activate' command. |
/modules/adminInterface/commands/website/delete | /modules/ui-pages-app/commands/website/delete | |
/modules/dms/commands/dms/activate | /modules/dam-app-assets/commands/dms/activate | Composite command, composed of 'version' and 'default-activate' command. |
/modules/dms/commands/dms/delete | /modules/dam-app-assets/commands/dms/delete |
Remove Command Pooling
The pooling capabilities will be removed from the MgnlCommand
base class, and the CommandsManager
will be changed to create new instance for each getCommand()
or executeCommand()
call.
Proposals for future goals (not to be implemented in this sprint):
Getting rid of the Commons Chain library:
New interface Command
(a 'copy' of the one from the Commons Chain library) will be defined in the info.magnolia.commands
package. (Option: simply remove 'implements Command
' from the MgnlCommand
class definition.)
The MgnlCatalog
class will be rewritten to provide the functionality of the org.apache.commons.chain.impl.CatalogBase
class.
This will also require to remove the dependency to org.apache.commons.chain.Context
interface from the interface info.magnolia.context.Context
, and cross-check for this dependency throughout the code.
Allow commands to be injected
TODO
Allow configuration-by-code for commands
TODO