Skip to content

Commit 1769bcf

Browse files
committed
fix: Remove cycling dependency
1 parent 9276357 commit 1769bcf

10 files changed

+98
-63
lines changed

src/main/java/de/rwth/idsg/steve/ocpp/ChargePointService12_InvokerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
import de.rwth.idsg.steve.ocpp.task.UnlockConnectorTask;
3131
import de.rwth.idsg.steve.ocpp.task.UpdateFirmwareTask;
3232
import de.rwth.idsg.steve.ocpp.ws.ChargePointServiceInvoker;
33+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
3334
import de.rwth.idsg.steve.ocpp.ws.ocpp12.Ocpp12TypeStore;
3435
import de.rwth.idsg.steve.ocpp.ws.ocpp12.Ocpp12WebSocketEndpoint;
3536
import de.rwth.idsg.steve.ocpp.ws.pipeline.OutgoingCallPipeline;
3637
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;
3738
import ocpp.cp._2010._08.ChargePointService;
39+
import org.springframework.beans.factory.annotation.Qualifier;
3840
import org.springframework.stereotype.Service;
3941

4042
/**
@@ -47,8 +49,8 @@ public class ChargePointService12_InvokerImpl implements ChargePointService12_In
4749
private final ChargePointServiceInvoker wsHelper;
4850
private final ClientProviderWithCache<ChargePointService> soapHelper;
4951

50-
public ChargePointService12_InvokerImpl(OutgoingCallPipeline pipeline, Ocpp12WebSocketEndpoint endpoint, ClientProvider clientProvider) {
51-
this.wsHelper = new ChargePointServiceInvoker(pipeline, endpoint, Ocpp12TypeStore.INSTANCE);
52+
public ChargePointService12_InvokerImpl(OutgoingCallPipeline pipeline, @Qualifier("sessionContextStore12") SessionContextStore sessionContextStore, ClientProvider clientProvider) {
53+
this.wsHelper = new ChargePointServiceInvoker(pipeline, sessionContextStore, Ocpp12TypeStore.INSTANCE);
5254
this.soapHelper = new ClientProviderWithCache<>(clientProvider);
5355
}
5456

src/main/java/de/rwth/idsg/steve/ocpp/ChargePointService15_InvokerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@
3636
import de.rwth.idsg.steve.ocpp.task.UnlockConnectorTask;
3737
import de.rwth.idsg.steve.ocpp.task.UpdateFirmwareTask;
3838
import de.rwth.idsg.steve.ocpp.ws.ChargePointServiceInvoker;
39+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
3940
import de.rwth.idsg.steve.ocpp.ws.ocpp15.Ocpp15TypeStore;
4041
import de.rwth.idsg.steve.ocpp.ws.ocpp15.Ocpp15WebSocketEndpoint;
4142
import de.rwth.idsg.steve.ocpp.ws.pipeline.OutgoingCallPipeline;
4243
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;
4344
import ocpp.cp._2012._06.ChargePointService;
45+
import org.springframework.beans.factory.annotation.Qualifier;
4446
import org.springframework.stereotype.Service;
4547

4648
/**
@@ -53,8 +55,8 @@ public class ChargePointService15_InvokerImpl implements ChargePointService15_In
5355
private final ChargePointServiceInvoker wsHelper;
5456
private final ClientProviderWithCache<ChargePointService> soapHelper;
5557

56-
public ChargePointService15_InvokerImpl(OutgoingCallPipeline pipeline, Ocpp15WebSocketEndpoint endpoint, ClientProvider clientProvider) {
57-
this.wsHelper = new ChargePointServiceInvoker(pipeline, endpoint, Ocpp15TypeStore.INSTANCE);
58+
public ChargePointService15_InvokerImpl(OutgoingCallPipeline pipeline, @Qualifier("sessionContextStore15") SessionContextStore sessionContextStore, ClientProvider clientProvider) {
59+
this.wsHelper = new ChargePointServiceInvoker(pipeline, sessionContextStore, Ocpp15TypeStore.INSTANCE);
5860
this.soapHelper = new ClientProviderWithCache<>(clientProvider);
5961
}
6062

src/main/java/de/rwth/idsg/steve/ocpp/ChargePointService16_InvokerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import de.rwth.idsg.steve.ocpp.soap.ClientProviderWithCache;
2323
import de.rwth.idsg.steve.ocpp.task.*;
2424
import de.rwth.idsg.steve.ocpp.ws.ChargePointServiceInvoker;
25+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
2526
import de.rwth.idsg.steve.ocpp.ws.ocpp16.Ocpp16TypeStore;
2627
import de.rwth.idsg.steve.ocpp.ws.ocpp16.Ocpp16WebSocketEndpoint;
2728
import de.rwth.idsg.steve.ocpp.ws.pipeline.OutgoingCallPipeline;
2829
import de.rwth.idsg.steve.repository.dto.ChargePointSelect;
2930
import ocpp.cp._2015._10.ChargePointService;
31+
import org.springframework.beans.factory.annotation.Qualifier;
3032
import org.springframework.stereotype.Service;
3133

3234
/**
@@ -39,8 +41,8 @@ public class ChargePointService16_InvokerImpl implements ChargePointService16_In
3941
private final ChargePointServiceInvoker wsHelper;
4042
private final ClientProviderWithCache<ChargePointService> soapHelper;
4143

42-
public ChargePointService16_InvokerImpl(OutgoingCallPipeline pipeline, Ocpp16WebSocketEndpoint endpoint, ClientProvider clientProvider) {
43-
this.wsHelper = new ChargePointServiceInvoker(pipeline, endpoint, Ocpp16TypeStore.INSTANCE);
44+
public ChargePointService16_InvokerImpl(OutgoingCallPipeline pipeline, @Qualifier("sessionContextStore16") SessionContextStore sessionContextStore, ClientProvider clientProvider) {
45+
this.wsHelper = new ChargePointServiceInvoker(pipeline, sessionContextStore, Ocpp16TypeStore.INSTANCE);
4446
this.soapHelper = new ClientProviderWithCache<>(clientProvider);
4547
}
4648

src/main/java/de/rwth/idsg/steve/ocpp/ws/AbstractWebSocketEndpoint.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,18 @@ public abstract class AbstractWebSocketEndpoint extends ConcurrentWebSocketHandl
6060
private final ScheduledExecutorService service;
6161
private final OcppServerRepository ocppServerRepository;
6262
private final FutureResponseContextStore futureResponseContextStore;
63-
private final SessionContextStore sessionContextStore = new SessionContextStore();
63+
private final SessionContextStore sessionContextStore;
6464
private final List<Consumer<String>> connectedCallbackList = new ArrayList<>();
6565
private final List<Consumer<String>> disconnectedCallbackList = new ArrayList<>();
6666
private final Object sessionContextLock = new Object();
6767

6868
private final IncomingPipeline pipeline;
6969

70-
public AbstractWebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, AbstractCallHandler server, AbstractTypeStore store) {
70+
public AbstractWebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, AbstractCallHandler server, AbstractTypeStore store, SessionContextStore sessionContextStore) {
7171
this.service = service;
7272
this.ocppServerRepository = ocppServerRepository;
7373
this.futureResponseContextStore = futureResponseContextStore;
74+
this.sessionContextStore = sessionContextStore;
7475
Deserializer deserializer = new Deserializer(futureResponseContextStore, store);
7576
this.pipeline = new IncomingPipeline(deserializer, server);
7677

@@ -195,28 +196,7 @@ protected String getChargeBoxId(WebSocketSession session) {
195196
return (String) session.getAttributes().get(CHARGEBOX_ID_KEY);
196197
}
197198

198-
protected void registerConnectedCallback(Consumer<String> consumer) {
199-
connectedCallbackList.add(consumer);
200-
}
201-
202-
protected void registerDisconnectedCallback(Consumer<String> consumer) {
203-
disconnectedCallbackList.add(consumer);
204-
}
205-
206-
public List<String> getChargeBoxIdList() {
207-
return sessionContextStore.getChargeBoxIdList();
208-
}
209-
210-
public int getNumberOfChargeBoxes() {
211-
return sessionContextStore.getNumberOfChargeBoxes();
212-
}
213-
214-
public Map<String, Deque<SessionContext>> getACopy() {
215-
return sessionContextStore.getACopy();
216-
}
217-
218199
public WebSocketSession getSession(String chargeBoxId) {
219200
return sessionContextStore.getSession(chargeBoxId);
220201
}
221-
222202
}

src/main/java/de/rwth/idsg/steve/ocpp/ws/ChargePointServiceInvoker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
public class ChargePointServiceInvoker {
4242

4343
private final OutgoingCallPipeline outgoingCallPipeline;
44-
private final AbstractWebSocketEndpoint endpoint;
44+
private final SessionContextStore sessionContextStore;
4545
private final TypeStore typeStore;
4646

4747
/**
@@ -76,7 +76,7 @@ private void run(String chargeBoxId, CommunicationTask task) {
7676

7777
FutureResponseContext frc = new FutureResponseContext(task, pair.getResponseClass());
7878

79-
CommunicationContext context = new CommunicationContext(endpoint.getSession(chargeBoxId), chargeBoxId);
79+
CommunicationContext context = new CommunicationContext(sessionContextStore.getSession(chargeBoxId), chargeBoxId);
8080
context.setOutgoingMessage(call);
8181
context.setFutureResponseContext(frc);
8282

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* SteVe - SteckdosenVerwaltung - https://github.com/steve-community/steve
3+
* Copyright (C) 2013-2023 SteVe Community Team
4+
* All Rights Reserved.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
package de.rwth.idsg.steve.ocpp.ws;
20+
21+
import org.springframework.beans.factory.annotation.Qualifier;
22+
import org.springframework.context.annotation.Bean;
23+
import org.springframework.context.annotation.Configuration;
24+
25+
@Configuration
26+
public class SessionContextStoreFactory {
27+
28+
@Bean
29+
@Qualifier("sessionContextStore12")
30+
public SessionContextStore sessionContextStore12() {
31+
return new SessionContextStore();
32+
}
33+
34+
@Bean
35+
@Qualifier("sessionContextStore15")
36+
public SessionContextStore sessionContextStore15() {
37+
return new SessionContextStore();
38+
}
39+
40+
@Bean
41+
@Qualifier("sessionContextStore16")
42+
public SessionContextStore sessionContextStore16() {
43+
return new SessionContextStore();
44+
}
45+
}

src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp12/Ocpp12WebSocketEndpoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import de.rwth.idsg.steve.ocpp.ws.AbstractTypeStore;
2727
import de.rwth.idsg.steve.ocpp.ws.AbstractWebSocketEndpoint;
2828
import de.rwth.idsg.steve.ocpp.ws.FutureResponseContextStore;
29+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
2930
import de.rwth.idsg.steve.ocpp.ws.pipeline.AbstractCallHandler;
3031
import de.rwth.idsg.steve.ocpp.ws.pipeline.Deserializer;
3132
import de.rwth.idsg.steve.ocpp.ws.pipeline.IncomingPipeline;
@@ -41,6 +42,7 @@
4142
import ocpp.cs._2010._08.StartTransactionRequest;
4243
import ocpp.cs._2010._08.StatusNotificationRequest;
4344
import ocpp.cs._2010._08.StopTransactionRequest;
45+
import org.springframework.beans.factory.annotation.Qualifier;
4446
import org.springframework.context.ApplicationEventPublisher;
4547
import org.springframework.stereotype.Component;
4648

@@ -53,8 +55,8 @@
5355
@Component
5456
public class Ocpp12WebSocketEndpoint extends AbstractWebSocketEndpoint {
5557

56-
public Ocpp12WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService12_SoapServer server) {
57-
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp12CallHandler(server), Ocpp12TypeStore.INSTANCE);
58+
public Ocpp12WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService12_SoapServer server, @Qualifier("sessionContextStore12") SessionContextStore sessionContextStore) {
59+
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp12CallHandler(server), Ocpp12TypeStore.INSTANCE, sessionContextStore);
5860
}
5961

6062
@Override

src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp15/Ocpp15WebSocketEndpoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import de.rwth.idsg.steve.ocpp.soap.CentralSystemService15_SoapServer;
2626
import de.rwth.idsg.steve.ocpp.ws.AbstractWebSocketEndpoint;
2727
import de.rwth.idsg.steve.ocpp.ws.FutureResponseContextStore;
28+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
2829
import de.rwth.idsg.steve.ocpp.ws.pipeline.AbstractCallHandler;
2930
import de.rwth.idsg.steve.ocpp.ws.pipeline.Deserializer;
3031
import de.rwth.idsg.steve.ocpp.ws.pipeline.IncomingPipeline;
@@ -40,6 +41,7 @@
4041
import ocpp.cs._2012._06.StartTransactionRequest;
4142
import ocpp.cs._2012._06.StatusNotificationRequest;
4243
import ocpp.cs._2012._06.StopTransactionRequest;
44+
import org.springframework.beans.factory.annotation.Qualifier;
4345
import org.springframework.context.ApplicationEventPublisher;
4446
import org.springframework.stereotype.Component;
4547

@@ -51,8 +53,8 @@
5153
*/
5254
@Component
5355
public class Ocpp15WebSocketEndpoint extends AbstractWebSocketEndpoint {
54-
public Ocpp15WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService15_SoapServer server) {
55-
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp15CallHandler(server), Ocpp15TypeStore.INSTANCE);
56+
public Ocpp15WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService15_SoapServer server, @Qualifier("sessionContextStore15") SessionContextStore sessionContextStore) {
57+
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp15CallHandler(server), Ocpp15TypeStore.INSTANCE, sessionContextStore);
5658
}
5759

5860
@Override

src/main/java/de/rwth/idsg/steve/ocpp/ws/ocpp16/Ocpp16WebSocketEndpoint.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import de.rwth.idsg.steve.ocpp.soap.CentralSystemService16_SoapServer;
2626
import de.rwth.idsg.steve.ocpp.ws.AbstractWebSocketEndpoint;
2727
import de.rwth.idsg.steve.ocpp.ws.FutureResponseContextStore;
28+
import de.rwth.idsg.steve.ocpp.ws.SessionContextStore;
2829
import de.rwth.idsg.steve.ocpp.ws.pipeline.AbstractCallHandler;
2930
import de.rwth.idsg.steve.ocpp.ws.pipeline.Deserializer;
3031
import de.rwth.idsg.steve.ocpp.ws.pipeline.IncomingPipeline;
@@ -40,6 +41,7 @@
4041
import ocpp.cs._2015._10.StartTransactionRequest;
4142
import ocpp.cs._2015._10.StatusNotificationRequest;
4243
import ocpp.cs._2015._10.StopTransactionRequest;
44+
import org.springframework.beans.factory.annotation.Qualifier;
4345
import org.springframework.context.ApplicationEventPublisher;
4446
import org.springframework.stereotype.Component;
4547

@@ -51,8 +53,8 @@
5153
*/
5254
@Component
5355
public class Ocpp16WebSocketEndpoint extends AbstractWebSocketEndpoint {
54-
public Ocpp16WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService16_SoapServer server) {
55-
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp16CallHandler(server), Ocpp16TypeStore.INSTANCE);
56+
public Ocpp16WebSocketEndpoint(ScheduledExecutorService service, OcppServerRepository ocppServerRepository, FutureResponseContextStore futureResponseContextStore, ApplicationEventPublisher applicationEventPublisher, CentralSystemService16_SoapServer server, @Qualifier("sessionContextStore16") SessionContextStore sessionContextStore) {
57+
super(service, ocppServerRepository, futureResponseContextStore, applicationEventPublisher, new Ocpp16CallHandler(server), Ocpp16TypeStore.INSTANCE, sessionContextStore);
5658
}
5759

5860
@Override

0 commit comments

Comments
 (0)