* @param configuration Configuration object to get destroyer class with context
* and configuration objects.
* @param propertyName Name of property that holds destroyer class.
*/
public static void executeDestroyer(boolean success, Configuration configuration, String propertyName) {
Destroyer destroyer = (Destroyer) ClassUtils.instantiate(configuration.get(propertyName));
if(destroyer == null) {
LOG.info("Skipping running destroyer as non was defined.");
return;
}
// Objects that should be pass to the Destroyer execution
PrefixContext subContext = new PrefixContext(configuration, JobConstants.PREFIX_CONNECTOR_CONTEXT);
Object configConnection = ConfigurationUtils.getConfigConnectorConnection(configuration);
Object configJob = ConfigurationUtils.getConfigConnectorJob(configuration);
// Propagate connector schema in every case for now
// TODO: Change to coditional choosing between HIO and Connector schema
Schema schema = ConfigurationUtils.getConnectorSchema(configuration);
DestroyerContext destroyerContext = new DestroyerContext(subContext, success, schema);
LOG.info("Executing destroyer class " + destroyer.getClass());
destroyer.destroy(destroyerContext, configConnection, configJob);
}