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;
}
Aggregations