Last active
February 18, 2023 18:50
-
-
Save palaashatri/1bf0fe54d408f36af9e4b5b4d757c6f1 to your computer and use it in GitHub Desktop.
Simple demonstration of using Static blocks in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testcache; | |
public class StaticBlock { | |
static String prometheusUrl = null; | |
static String billing_service_name = null; | |
static { | |
prometheusUrl = System.getenv("PROMETHEUS_URL"); | |
if (prometheusUrl == null) { | |
prometheusUrl = "http://prom-prometheus-operator-prometheus.monitoring:9090/api/v1/query?/"; | |
} | |
bem_service_name = System.getenv("BILLING_SERVICE_NAME"); | |
if (bem_service_name == null) { | |
billing_service_name = "billingmanager"; | |
} | |
System.out.println("prometheusUrl: " + prometheusUrl ); | |
System.out.println("billing_service_name : "+ billing_service_name); | |
} | |
public static void main(String[] args) { | |
System.out.println("Main executed!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment