org.etlunit.feature.AbstractFeature Maven / Gradle / Ivy
package org.etlunit.feature;
import com.google.inject.Injector;
import org.etlunit.*;
import org.etlunit.parser.ETLTestValueObject;
import javax.inject.Inject;
import javax.inject.Named;
import java.util.Collections;
import java.util.List;
public abstract class AbstractFeature implements Feature
{
protected Configuration configuration;
protected Log applicationLog;
protected Log userLog;
private Injector injector;
protected ETLTestValueObject featureConfiguration;
private final ResourceFeatureMetaInfo metaInfo = new ResourceFeatureMetaInfo(this);
private List supportedFolderNames;
@Override
public void dispose()
{
// by default features don't need disposing. If they do they must override
// this method.
}
@Override
public final List getTestSupportFolderNames()
{
if (supportedFolderNames == null)
{
supportedFolderNames = getSupportedFolderNamesSub();
}
return supportedFolderNames;
}
protected List getSupportedFolderNamesSub()
{
return Collections.EMPTY_LIST;
}
@Inject
@Override
public void setApplicationLog(@Named("applicationLog") Log log)
{
applicationLog = log;
}
@Inject
@Override
public void setUserLog(@Named("userLog") Log log)
{
userLog = log;
}
@Override
public void setFeatureConfiguration(ETLTestValueObject obj)
{
featureConfiguration = obj;
}
@Override
public ETLTestValueObject getFeatureConfiguration()
{
return featureConfiguration;
}
@Inject
@Override
public void setConfiguration(Configuration conf)
{
configuration = conf;
}
@Override
public StatusReporter getStatusReporter()
{
return null;
}
public boolean isInjected()
{
return configuration != null;
}
protected T postCreate(T object)
{
if (injector == null)
{
throw new IllegalStateException("Feature does not have a valid injector");
}
injector.injectMembers(object);
return object;
}
protected void useInjector(Injector inj)
{
injector = inj;
}
@Override
public ClassDirector getDirector()
{
return null;
}
@Override
public ClassLocator getLocator()
{
return null;
}
@Override
public ClassListener getListener()
{
return null;
}
@Override
public List getPrerequisites()
{
return Collections.emptyList();
}
protected Injector preCreateSub(Injector inj)
{
return null;
}
@Override
public final Injector preCreate(Injector inj)
{
useInjector(inj);
Injector injSub = preCreateSub(inj);
if (injSub != null)
{
inj = injSub;
}
useInjector(inj);
return inj;
}
@Override
public void initialize(Injector inj)
{
}
@Override
public String toString()
{
return "AbstractFeature{" +
"name='" + getFeatureName() +
"'}";
}
@Override
public FeatureMetaInfo getMetaInfo()
{
return metaInfo;
}
@Override
public LogListener getLogListener()
{
return null;
}
@Override
public long getPriorityLevel()
{
return 0L;
}
@Override
public void setRuntimeOption(RuntimeOption option)
{
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy