All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.andromedaioc.bean.instantiation.AbstractInstantiator Maven / Gradle / Ivy

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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy