34
34
import org .springframework .beans .factory .annotation .Qualifier ;
35
35
import org .springframework .context .annotation .Bean ;
36
36
import org .springframework .context .annotation .Configuration ;
37
+ import org .springframework .context .event .ContextRefreshedEvent ;
38
+ import org .springframework .context .event .ContextStartedEvent ;
39
+ import org .springframework .context .event .EventListener ;
40
+ import org .springframework .stereotype .Component ;
37
41
38
42
import java .util .Collection ;
39
43
import java .util .Collections ;
@@ -56,10 +60,24 @@ public class OcppConfiguration {
56
60
LogUtils .setLoggerClass (Slf4jLogger .class );
57
61
}
58
62
63
+ private final CentralSystemService ocpp12Server ;
64
+ private final ocpp .cs ._2012 ._06 .CentralSystemService ocpp15Server ;
65
+ private final ocpp .cs ._2015 ._10 .CentralSystemService ocpp16Server ;
66
+ private final List <Interceptor <? extends Message >> interceptors ;
67
+ private final List <Feature > logging ;
68
+ private final String routerEndpointPath ;
69
+
59
70
public OcppConfiguration (CentralSystemService ocpp12Server , ocpp .cs ._2012 ._06 .CentralSystemService ocpp15Server , ocpp .cs ._2015 ._10 .CentralSystemService ocpp16Server , @ Qualifier ("MessageHeaderInterceptor" ) PhaseInterceptor <Message > messageHeaderInterceptor ) {
60
- List <Interceptor <? extends Message >> interceptors = asList (new MessageIdInterceptor (), messageHeaderInterceptor );
61
- List <Feature > logging = singletonList (LoggingFeatureProxy .INSTANCE .get ());
71
+ this .ocpp12Server = ocpp12Server ;
72
+ this .ocpp15Server = ocpp15Server ;
73
+ this .ocpp16Server = ocpp16Server ;
74
+ this .interceptors = asList (new MessageIdInterceptor (), messageHeaderInterceptor );
75
+ this .logging = singletonList (LoggingFeatureProxy .INSTANCE .get ());
76
+ this .routerEndpointPath = CONFIG .getRouterEndpointPath ();
77
+ }
62
78
79
+ @ EventListener
80
+ public void afterStart (ContextRefreshedEvent event ) {
63
81
createOcppService (ocpp12Server , "/CentralSystemServiceOCPP12" , interceptors , logging );
64
82
createOcppService (ocpp15Server , "/CentralSystemServiceOCPP15" , interceptors , logging );
65
83
createOcppService (ocpp16Server , "/CentralSystemServiceOCPP16" , interceptors , logging );
@@ -68,7 +86,7 @@ public OcppConfiguration(CentralSystemService ocpp12Server, ocpp.cs._2012._06.Ce
68
86
// one to be created, since in MediatorInInterceptor we go over created/registered services and build a map.
69
87
//
70
88
List <Interceptor <? extends Message >> mediator = singletonList (new MediatorInInterceptor (springBus ()));
71
- createOcppService (ocpp12Server , CONFIG . getRouterEndpointPath () , mediator , Collections .emptyList ());
89
+ createOcppService (ocpp12Server , routerEndpointPath , mediator , Collections .emptyList ());
72
90
}
73
91
74
92
@ Bean (name = Bus .DEFAULT_BUS_ID , destroyMethod = "shutdown" )
0 commit comments