File tree Expand file tree Collapse file tree 2 files changed +15
-11
lines changed
devicehive-auth/src/main/java/com/devicehive/application Expand file tree Collapse file tree 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 2020 * #L%
2121 */
2222
23- import org .springframework .context .event .ContextRefreshedEvent ;
24- import org .springframework .context .event .EventListener ;
23+ import org .springframework .boot .context .event .ApplicationPreparedEvent ;
24+ import org .springframework .boot .context .event .SpringApplicationEvent ;
25+ import org .springframework .context .ApplicationEvent ;
26+ import org .springframework .context .ApplicationListener ;
27+ import org .springframework .context .event .ApplicationContextEvent ;
2528import org .springframework .core .env .ConfigurableEnvironment ;
2629import org .springframework .core .env .MapPropertySource ;
27- import org .springframework .stereotype .Component ;
2830
2931import java .util .ArrayList ;
30- import java .util .List ;
3132import java .util .Collection ;
33+ import java .util .List ;
3234
33- @ Component
34- public class AppContextEventListener {
35-
36- @ EventListener
37- public void handleContextRefreshed (ContextRefreshedEvent event ) {
38- printActiveProperties ((ConfigurableEnvironment ) event .getApplicationContext ().getEnvironment ());
39- }
35+ public class AppContextEventListener implements ApplicationListener <ApplicationEvent > {
4036
4137 private void printActiveProperties (ConfigurableEnvironment env ) {
4238
@@ -64,4 +60,11 @@ private void printActiveProperties(ConfigurableEnvironment env) {
6460 });
6561 System .out .println ("******************************************************************************" );
6662 }
63+
64+ @ Override
65+ public void onApplicationEvent (ApplicationEvent event ) {
66+ if (event instanceof ApplicationPreparedEvent ) {
67+ printActiveProperties ((ConfigurableEnvironment ) ((ApplicationPreparedEvent ) event ).getApplicationContext ().getEnvironment ());
68+ }
69+ }
6770}
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public class DeviceHiveAuthApplication extends SpringBootServletInitializer {
5757
5858 public static void main (String ... args ) {
5959 ConfigurableApplicationContext context = new SpringApplicationBuilder ()
60+ .listeners (new AppContextEventListener ())
6061 .sources (DeviceHiveAuthApplication .class )
6162 .web (WebApplicationType .SERVLET )
6263 .run (args );
You can’t perform that action at this time.
0 commit comments