vidakovic commented on code in PR #6387:
URL: https://github.com/apache/fineract/pull/6387#discussion_r3979920954


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/boot/FineractApplicationLifecycleLogger.java:
##########
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.core.boot;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.boot.web.context.WebServerApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class FineractApplicationLifecycleLogger {
+
+    private volatile ConfigurableApplicationContext readyApplicationContext;
+
+    @EventListener
+    public void onApplicationReady(ApplicationReadyEvent event) {
+        ConfigurableApplicationContext applicationContext = 
event.getApplicationContext();
+        readyApplicationContext = applicationContext;
+        Environment environment = applicationContext.getEnvironment();
+        log.info("Fineract lifecycle event: {}", 
createReadyMessage(environment, getServerPort(applicationContext)));
+    }
+
+    @EventListener
+    public void onApplicationClosing(ContextClosedEvent event) {
+        if (event.getApplicationContext() == readyApplicationContext) {
+            log.info("Fineract lifecycle event: {}", 
createShuttingDownMessage());
+        }
+    }
+
+    static String createReadyMessage(Environment environment, int serverPort) {
+        String scheme = environment.getProperty("server.ssl.enabled", 
Boolean.class, false) ? "https" : "http";

Review Comment:
   You could just inject 
`org.springframework.boot.web.server.autoconfigure.ServerProperties` and have a 
type-safe way of getting that value... and without the need to provide a 
default value... or the need for the `Environment` component. That helps you 
then also with the property for `server.address`... again, all type-safe.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to