use of com.axway.ats.agent.core.model.InitializationHandler in project ats-framework by Axway.
the class ComponentRepository method initializeAllComponents.
public void initializeAllComponents() {
//initialize the components
List<Component> components = getAllComponents();
for (Component component : components) {
ComponentActionMap actionMap = component.getActionMap();
Class<? extends InitializationHandler> initClass = actionMap.getInitializationHandler();
//skip the initialization phase if the component has not declared a handler
if (initClass != null) {
String initClassName = initClass.getName();
try {
InitializationHandler initHandler = initClass.newInstance();
initHandler.initializeComponent();
log.info("Component '" + actionMap.getComponentName() + "' initialized successfully");
} catch (IllegalAccessException iae) {
log.error("Could not instantiate initialization handler '" + initClassName + "' - it should have a no-argument public constructor");
} catch (InstantiationException ie) {
log.error("Could not instantiate initialization handler '" + initClassName + "' - it should have a no-argument public constructor");
} catch (Exception e) {
log.error("Exception during initialization for component '" + actionMap.getComponentName() + "'", e);
}
} else {
log.debug("Component '" + actionMap.getComponentName() + "' does not have an initialization handler");
}
//create the component backup if it does not exist yet
try {
List<ComponentEnvironment> componentEnvironments = component.getEnvironments();
if (componentEnvironments != null) {
for (ComponentEnvironment componentEnvironment : componentEnvironments) {
componentEnvironment.backupOnlyIfNotAlreadyDone();
}
}
} catch (AgentException ae) {
log.error(ae.getMessage(), ae);
}
}
}
Aggregations