public static String getValue( final Properties properties, final Class<? extends GuiceProperty> guiceProperty) { return (properties.getProperty(getName(guiceProperty))); }
private static void loadPropertyFromSystemProperty( final Properties properties, final Class<? extends GuiceProperty> guiceProperty) { System.out.println("loading from SystemProperty:" + guiceProperty); final String value = System.getProperty(getName(guiceProperty)); if (value != null) properties.setProperty(getName(guiceProperty), value); }
public static String getEnvironmentVariableName(final Class<? extends GuiceProperty> guiceProperty) { return (getName(guiceProperty).replaceAll("\\.", "_")); }
private static void loadPropertyFromProperties( final Properties tempProperties, final Properties properties, final Class<? extends GuiceProperty> guiceProperty) { System.out.println("loading from properties file:" + guiceProperty); final Object value = tempProperties.get(getName(guiceProperty)); if (value != null) properties.put(getName(guiceProperty), value); }
private static void loadDefaultOnInterface( final Properties properties, final Class<? extends GuiceProperty> guiceProperty, final Field field) throws IllegalAccessException { for (final Class<? extends GuiceProperty> guicePropertyClass : ((Class<? extends GuiceProperty>[]) guiceProperty.getInterfaces())) { if (!GuiceProperty.class.equals(guicePropertyClass)) properties.setProperty(getName(guicePropertyClass), getValue(field).toString()); } }
private static void loadPropertyFromEnvironment( final Properties properties, final Class<? extends GuiceProperty> guiceProperty) { System.out.println("loading from env:" + guiceProperty); final String value = System.getenv().get(getEnvironmentVariableName(guiceProperty)); if (value != null) properties.setProperty(getName(guiceProperty), value); }
@Override protected void loadDefaults() { super.loadDefaults(); properties.setProperty(PropertyUtil.getName(Debug.class), Boolean.toString(true)); }
protected void loadSpecifiedProperties() { if (propertyValuePairs != null && propertyValuePairs.length > 0) { for (PropertyValuePair propertyValuePair : propertyValuePairs) { properties.setProperty( PropertyUtil.getName(propertyValuePair.getPropertyClass()), propertyValuePair.getValue().toString()); } } } }
public static void loadEnvironmentProperty( final Properties properties, final Class<? extends EnvironmentProperty> environmentProperty) { try { for (final EnvironmentProperty environmentProperty1 : environmentProperty.getEnumConstants()) { for (final Class<? extends GuiceProperty> supportedProperty : environmentProperty1.getSupportedProperties()) { final String value = environmentProperty1.getValue(properties, supportedProperty); properties.setProperty(getName(supportedProperty), value); } } } catch (Exception e) { LOGGER.warn("Error loading properties for:" + environmentProperty, e); } }
private static void loadDefault( final Properties properties, final Class<? extends GuiceProperty> guiceProperty) { for (final Field field : guiceProperty.getDeclaredFields()) { System.out.println("checking if default:" + field); LOGGER.trace("checking value:" + field); if (field.isAnnotationPresent(DefaultValue.class)) { System.out.println("loading default:" + field); LOGGER.trace("setting default value:" + field); try { properties.setProperty(getName(guiceProperty), getValue(field).toString()); if (field.isEnumConstant()) loadDefaultOnInterface(properties, guiceProperty, field); } catch (IllegalAccessException e) { System.err.println("error setting default:" + field); LOGGER.warn("Unable to set default value", e); } } } }