net.sf.andromedaioc.bean.instantiation.AbstractInstantiator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of andromeda-ioc Show documentation
Show all versions of andromeda-ioc Show documentation
Inversion of Control Framework for Android
The newest version!
package net.sf.andromedaioc.bean.instantiation;
import net.sf.andromedaioc.exception.BeanInstantiationException;
/**
* Contains common logic for instantiation using constructor or factory method
*
* @author Alexey Mitrov
*/
public abstract class AbstractInstantiator implements Instantiator {
private final InstanceProcessor instanceProcessor;
protected AbstractInstantiator(InstanceProcessor instanceProcessor) {
this.instanceProcessor = instanceProcessor;
}
protected abstract Object createInstance() throws BeanInstantiationException;
public Object newInstance() throws BeanInstantiationException {
Object instance = createInstance();
return instanceProcessor == null ? instance : instanceProcessor.process(instance);
}
}