use of com.axway.ats.agent.core.ComponentActionMap in project ats-framework by Axway.
the class Test_ActionMethodEnumArguments method setUpTest_ActionHandler.
@BeforeClass
public static void setUpTest_ActionHandler() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassEnumArguments.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentActionMap in project ats-framework by Axway.
the class Test_ActionMethodValidation method setUpTest_ActionHandler.
@BeforeClass
public static void setUpTest_ActionHandler() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassForValidation.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentActionMap in project ats-framework by Axway.
the class DisabledTest_RampUpLoaderMultipleInvocations method setUpTest_ActionInvoker.
@BeforeClass
public static void setUpTest_ActionInvoker() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(LoadTestActionClass.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentActionMap in project ats-framework by Axway.
the class AbstractComponentLoader method registerComponent.
/**
* Register a component into a component repository
*
* @param configParser the configuration parser which describes the component
* @param componentRepository the component repository
* @throws ComponentAlreadyDefinedException if the component has already been defined
* @throws ComponentLoadingException if the component cannot be loaded for some reason
*/
@SuppressWarnings("unchecked")
protected void registerComponent(ConfigurationParser configParser, ComponentRepository componentRepository) throws ComponentAlreadyDefinedException, ComponentLoadingException {
String componentName = configParser.getComponentName();
//first add the action classes to the global map
ComponentActionMap componentActionMap = new ComponentActionMap(componentName);
try {
//initialization and finalization handlers are optional
if (configParser.getInitializationHandler() == null) {
componentActionMap.setInitializationHandler(null);
} else {
Class<?> initHandlerClass = loadClass(configParser.getInitializationHandler());
//check if this class implements the proper interface
if (InitializationHandler.class.isAssignableFrom(initHandlerClass)) {
componentActionMap.setInitializationHandler((Class<? extends InitializationHandler>) initHandlerClass);
} else {
throw new ComponentLoadingException(componentName, "Initialization handler '" + initHandlerClass.getName() + "' does not implement the InitializationHandler interface");
}
}
if (configParser.getFinalizationHandler() == null) {
componentActionMap.setFinalizationHandler(null);
} else {
Class<?> finalHandlerClass = loadClass(configParser.getFinalizationHandler());
//check if this class implements the proper interface
if (FinalizationHandler.class.isAssignableFrom(finalHandlerClass)) {
componentActionMap.setFinalizationHandler((Class<? extends FinalizationHandler>) finalHandlerClass);
} else {
//fatal error
throw new ComponentLoadingException(componentName, "Finalization handler '" + finalHandlerClass.getName() + "' does not implement the FinalizationHandler interface");
}
}
Class<?> cleanupHandlerClass = loadClass(configParser.getCleanupHandler());
//check if this class implements the proper interface
if (EnvironmentCleanupHandler.class.isAssignableFrom(cleanupHandlerClass)) {
componentActionMap.setCleanupHandler((Class<? extends EnvironmentCleanupHandler>) cleanupHandlerClass);
} else {
//fatal error
throw new ComponentLoadingException(componentName, "Cleanup handler '" + cleanupHandlerClass.getName() + "' does not implement the EnvironmentCleanupHandler interface");
}
} catch (ClassNotFoundException cnfe) {
//fatal error
throw new ComponentLoadingException(componentName, "Component class or a referred class could not be loaded, check configuration for component '" + componentName + "': " + cnfe.getMessage());
}
Set<String> actionClassNames = configParser.getActionClassNames();
for (String actionClassName : actionClassNames) {
try {
componentActionMap.registerActionClass(loadClass(actionClassName));
} catch (ClassNotFoundException | NoClassDefFoundError cnfe) {
//this is a non-fatal error so we can just log it
log.error("Action class or a referred class could not be loaded, check configuration for component '" + componentName + "': " + cnfe.getMessage());
}
}
//create the component object
Component component = new Component(componentName);
component.setActionMap(componentActionMap);
component.setEnvironments(configParser.getEnvironments());
componentRepository.putComponent(component);
}
use of com.axway.ats.agent.core.ComponentActionMap in project ats-framework by Axway.
the class Test_LocalExecutor method setUpTest_LocalExecutor.
@BeforeClass
public static void setUpTest_LocalExecutor() throws AgentException {
Component component = new Component(TEST_COMPONENT_NAME);
ComponentActionMap actionMap = new ComponentActionMap(TEST_COMPONENT_NAME);
actionMap.registerActionClass(ActionClassOne.class);
component.setActionMap(actionMap);
ComponentRepository componentRepository = ComponentRepository.getInstance();
componentRepository.clear();
componentRepository.putComponent(component);
}
Aggregations