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

io.katharsis.spring.SpringServiceLocator Maven / Gradle / Ivy

There is a newer version: 3.0.2
Show newest version
package io.katharsis.spring;

import io.katharsis.locator.JsonServiceLocator;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;

public class SpringServiceLocator implements BeanFactoryAware, JsonServiceLocator {

    private ConfigurableBeanFactory beanFactory;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        if (beanFactory instanceof ConfigurableBeanFactory) {
            this.beanFactory = (ConfigurableBeanFactory) beanFactory;
        }
    }

    @Override
    public  T getInstance(Class clazz) {
        return beanFactory.getBean(clazz);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy