Package index.context

Source Code of index.context.RegisterProperties

package index.context;

import java.util.Properties;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

public enum Application {
    LunceneIndexer;
    Properties props;
    private ClassPathXmlApplicationContext applicationContext;

    void setProps(Properties props) {
        this.props = props;
    }

    void loadApplication() {
        applicationContext = new ClassPathXmlApplicationContext("maven-lucene-context.xml");
        applicationContext.start();
    }

    public <T> T getInstance(Class<T> objectType) {
        T contextBean = applicationContext.getBean(objectType);
        return contextBean;
    }
}

@Component
class RegisterProperties {
    @Bean
    PropertyPlaceholderConfigurer register() {
        PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
        configurer.setProperties(Application.LunceneIndexer.props);
        return configurer;
    }

}
TOP

Related Classes of index.context.RegisterProperties

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.