Package se.sperber.cryson.examples.advancedcrysondiary.initialization

Source Code of se.sperber.cryson.examples.advancedcrysondiary.initialization.Spring

package se.sperber.cryson.examples.advancedcrysondiary.initialization;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.Resource;
import se.sperber.cryson.CrysonServer;

import java.io.IOException;

public class Spring {

  private static AnnotationConfigApplicationContext context = null;

  public static void initialize() throws IOException {
    context = new AnnotationConfigApplicationContext();
    ConfigurableEnvironment environment = context.getEnvironment();
    environment.addActiveProfile("cryson_logging");
    PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
    configurer.setLocations(new Resource[]{context.getResource("advancedcrysondiary.properties"), context.getResource("cryson.properties")});
    context.addBeanFactoryPostProcessor(configurer);
    context.scan(Spring.class.getPackage().getName(), CrysonServer.class.getPackage().getName());
    context.refresh();
  }

}
TOP

Related Classes of se.sperber.cryson.examples.advancedcrysondiary.initialization.Spring

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.