/** * Same as `tryGetGlobalProperty` but with null as implicit default value * @param key Variable name * @return Environment or System property value or null if not found */ public static String tryGetGlobalProperty(String key) { return tryGetGlobalProperty(key, null); }
/** * Same as `tryGetGlobalProperty` but with null as implicit default value * @param key Variable name * @return Environment or System property value or null if not found */ public static String tryGetGlobalProperty(String key) { return tryGetGlobalProperty(key, null); }
@Override protected HttpURLConnection getConnection(String url) throws IOException { // let's see if there is a different URL we should post to (e.g. load/stress testing) final String fcmURL = ConfigurationUtils.tryGetGlobalProperty(CUSTOM_AEROGEAR_FCM_PUSH_HOST, FCM_ENDPOINT_HOST); return (HttpURLConnection) new URL(fcmURL).openConnection(); }
@Override protected HttpURLConnection getConnection(String url) throws IOException { // let's see if there is a different URL we should post to (e.g. load/stress testing) final String fcmURL = ConfigurationUtils.tryGetGlobalProperty(CUSTOM_AEROGEAR_FCM_PUSH_HOST, FCM_ENDPOINT_HOST); return (HttpURLConnection) new URL(fcmURL).openConnection(); }
@GET @Produces(MediaType.APPLICATION_JSON) public Response configurationFile() throws JsonProcessingException { final String realmName = ConfigurationUtils.tryGetGlobalProperty(REALM_NAME_PROPERTY); final String keycloakServerURL = removeDefaultHttpPorts(ConfigurationUtils.tryGetGlobalProperty(REALM_URL_PROPERTY)); final Config config = new Config(realmName, keycloakServerURL); logger.trace("rendering '{}' realm config, for {}", realmName, keycloakServerURL); return Response.ok(mapper.writeValueAsString(config)).build(); }
@SuppressWarnings("unchecked") private static <T> T getProperty(VariantType type, ConfigurationProperty property, T defaultValue, Class<T> expectedType) { String systemPropertyName = getSystemPropertyName(type, property); if (expectedType == String.class) { return (T) ConfigurationUtils.tryGetGlobalProperty(systemPropertyName, (String) defaultValue); } else if (expectedType == Integer.class) { return (T) ConfigurationUtils.tryGetGlobalIntegerProperty(systemPropertyName, (Integer) defaultValue); } else { throw new IllegalStateException("Unexpected type: " + expectedType); } }
@SuppressWarnings("unchecked") private static <T> T getProperty(VariantType type, ConfigurationProperty property, T defaultValue, Class<T> expectedType) { String systemPropertyName = getSystemPropertyName(type, property); if (expectedType == String.class) { return (T) ConfigurationUtils.tryGetGlobalProperty(systemPropertyName, (String) defaultValue); } else if (expectedType == Integer.class) { return (T) ConfigurationUtils.tryGetGlobalIntegerProperty(systemPropertyName, (Integer) defaultValue); } else { throw new IllegalStateException("Unexpected type: " + expectedType); } }