Do something after return statement - Java

The requirement is below.

I have an electric rechargeable vehicle (device) that transmits a message to a Java application (service) through a SOAP message. When the device is turned on, it sends a request to the service through a SOAP message.

The service receives a SOAP message request and checks if the device is an authorized device (we check this from the database, where we have a few data about authorized devices) or not. If the device is enabled, the service responds to the device through a Received or Rejected SOAP message.

When a service sends a SOAP response to a device, after 5 SECONDS, the service should send a SOAP request to the device requesting device settings.

The following is sample code from a service.

public AuthorizeResponse authorize(AuthorizeRequest parameters) {
   AuthorizeResponse authorizeResponse = new AuthorizeResponse();

   //check from db whether the device is authorized or not from 
    parameters.getDeviceName();

   return authorizeResponse; 
}

, "return authorizeResponse;", Thread.sleep(5000) .

- , ?

+4
1

finally:

public Integer printAfterReturn() {
    try {
        int a = 10;
        return a + 10;
    } finally {
        System.out.println("printed");
    }
}
+14

Source: https://habr.com/ru/post/1531937/


All Articles