Search in sources :

Example 1 with CommandServletConfigElement

use of org.alfresco.web.config.CommandServletConfigElement in project acs-community-packaging by Alfresco.

the class CommandServlet method createCommandProcessor.

/**
 * Created the specified CommandProcessor instance. The name of the processor is looked up
 * in the client config, it should find a valid class impl and then create it.
 *
 * @param procName      Name of the CommandProcessor to lookup in the client config.
 *
 * @return CommandProcessor
 *
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
private CommandProcessor createCommandProcessor(String procName) throws InstantiationException, IllegalAccessException {
    Config config = Application.getConfigService(getServletContext()).getConfig("Command Servlet");
    if (config == null) {
        throw new AlfrescoRuntimeException("No command processors configured - unable to process any commands.");
    }
    CommandServletConfigElement configElement = (CommandServletConfigElement) config.getConfigElement(CommandServletConfigElement.CONFIG_ELEMENT_ID);
    if (configElement == null) {
        throw new AlfrescoRuntimeException("No command processors configured - unable to process any commands.");
    }
    Class clazz = configElement.getCommandProcessor(procName);
    Object obj = clazz.newInstance();
    if (obj instanceof CommandProcessor == false) {
        throw new AlfrescoRuntimeException("Configured command processor '" + procName + "' is does not implement interface CommandProcessor!");
    }
    return (CommandProcessor) obj;
}
Also used : Config(org.springframework.extensions.config.Config) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException) ExtCommandProcessor(org.alfresco.web.app.servlet.command.ExtCommandProcessor) CommandProcessor(org.alfresco.web.app.servlet.command.CommandProcessor) CommandServletConfigElement(org.alfresco.web.config.CommandServletConfigElement)

Aggregations

AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)1 CommandProcessor (org.alfresco.web.app.servlet.command.CommandProcessor)1 ExtCommandProcessor (org.alfresco.web.app.servlet.command.ExtCommandProcessor)1 CommandServletConfigElement (org.alfresco.web.config.CommandServletConfigElement)1 Config (org.springframework.extensions.config.Config)1