File tree Expand file tree Collapse file tree
src/main/java/de/rwth/idsg/steve/ocpp/ws Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import de .rwth .idsg .steve .ocpp .ws .data .OcppJsonCall ;
1010import de .rwth .idsg .steve .ocpp .ws .pipeline .OutgoingPipeline ;
1111import lombok .Setter ;
12+ import org .slf4j .Logger ;
13+ import org .slf4j .LoggerFactory ;
1214import org .springframework .beans .factory .annotation .Autowired ;
1315
1416import java .util .UUID ;
1820 * @since 20.03.2015
1921 */
2022public abstract class AbstractChargePointServiceInvoker {
23+ private final Logger log = LoggerFactory .getLogger (getClass ());
2124
2225 @ Autowired private OutgoingPipeline outgoingPipeline ;
2326
2427 @ Setter private TypeStore typeStore ;
2528 @ Setter private AbstractWebSocketEndpoint endpoint ;
2629
30+ /**
31+ * Just a wrapper to make try-catch block and exception handling stand out
32+ */
2733 public void runPipeline (String chargeBoxId , RequestType request , OcppResponseHandler handler ) {
34+ try {
35+ run (chargeBoxId , request , handler );
36+ } catch (Exception e ) {
37+ log .error ("Exception occurred" , e );
38+ // Outgoing call failed due to technical problems. Pass the exception to handler to inform the user
39+ handler .handleException (e );
40+ }
41+ }
42+
43+ /**
44+ * Actual processing
45+ */
46+ private void run (String chargeBoxId , RequestType request , OcppResponseHandler handler ) {
2847 String messageId = UUID .randomUUID ().toString ();
2948 ActionResponsePair pair = typeStore .findActionResponse (request );
3049 if (pair == null ) {
Original file line number Diff line number Diff line change @@ -22,16 +22,8 @@ public class OutgoingPipeline implements Pipeline {
2222
2323 @ Override
2424 public void run (CommunicationContext context ) {
25- try {
26- serializer .process (context );
27- sender .process (context );
28-
29- } catch (Exception e ) {
30- log .error ("Exception occurred" , e );
31- // Outgoing call failed due to technical problems. Pass the exception to handler to inform the user.
32- context .getFutureResponseContext ().getHandler ().handleException (e );
33- return ;
34- }
25+ serializer .process (context );
26+ sender .process (context );
3527
3628 // All went well, and the call is sent. Store the response context for later lookup.
3729 futureResponseContextStore .add (context .getSession (),
You can’t perform that action at this time.
0 commit comments