@Override protected void startAppContext(String[] args) { // SpringConfigApplicationContext context = new SpringConfigApplicationContext(); AbstractRefreshableConfigApplicationContext context = createApplicationContext(); // context.setConfigLocation(""); Springs.initApplicationIfNotInitialized(context); initApplicationContext(context); context.refresh(); this.afterInitApplicationContext(context); }
@Override public void initialize(AbstractRefreshableConfigApplicationContext ctx) { ctx.setAllowBeanDefinitionOverriding(false); ConfigurableEnvironment env = ctx.getEnvironment(); Set<String> aps = new LinkedHashSet<>(); Collections.addAll(aps, env.getActiveProfiles()); Collections.addAll(aps, testConfig ? Constants.PROFILES_TEST : Constants.PROFILES_PROD); env.getPropertySources().addLast(new LabelPropertySource()); env.getPropertySources().addLast(new DomainPropertySource(ctx)); env.setDefaultProfiles(Constants.PROFILE_ROOT_DEFAULT); ctx.setConfigLocations(Constants.DEFAULT_LOCATIONS); env.setActiveProfiles(aps.toArray(new String[aps.size()])); }
protected void initApplicationContext(AbstractRefreshableConfigApplicationContext context){ }
protected void afterInitApplicationContext(AbstractRefreshableConfigApplicationContext context){ Springs.getInstance().printBeanNames(); }
abstract protected AbstractRefreshableConfigApplicationContext createApplicationContext();