1
2
3
4 package org.kuali.student.common.spring;
5
6 import org.apache.commons.lang.StringUtils;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.BeansException;
10 import org.springframework.beans.factory.InitializingBean;
11 import org.springframework.context.ApplicationContext;
12 import org.springframework.context.ApplicationContextAware;
13
14
15
16
17
18 public class DisplayActiveProfiles implements ApplicationContextAware, InitializingBean {
19
20
21 private static final Logger log = LoggerFactory.getLogger(DisplayActiveProfiles.class);
22
23 private ApplicationContext applicationContext;
24
25
26
27
28
29
30 public DisplayActiveProfiles() {
31 }
32
33
34
35
36
37
38 @Override
39 public void setApplicationContext(ApplicationContext applicationContext)
40 throws BeansException {
41 this.applicationContext = applicationContext;
42
43 }
44
45
46
47
48
49
50 @Override
51 public void afterPropertiesSet() throws Exception {
52
53 String[] profiles = this.applicationContext.getEnvironment().getActiveProfiles();
54
55 if (profiles.length == 0) {
56 profiles = this.applicationContext.getEnvironment().getDefaultProfiles();
57 log.info(applicationContext.getDisplayName() + " : Default Active Profiles are : " + StringUtils.join(profiles, ", "));
58 }
59 else
60 log.info(applicationContext.getDisplayName() + " : Active Profiles are : " + StringUtils.join(profiles, ", "));
61 }
62
63
64
65 }