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()); } }
protected void bindToProperty(final Class<? extends GuiceProperty> guicePropertyClass) { final String value = PropertyUtil.getValue(properties, guicePropertyClass); if (value != null) bindConstant().annotatedWith(new PropertyImpl(guicePropertyClass)).to(value); else { throw (new IllegalStateException( guicePropertyClass + " was not set and not default value was provided either, this is likely a configuration problem.")); } }
public static void setJavaProperty( final Properties properties, final Class<? extends JavaEnvironmentProperty> environmentProperty) { for (final JavaEnvironmentProperty environmentProperty1 : environmentProperty.getEnumConstants()) { System.setProperty( environmentProperty1.getKey(), getValue(properties, environmentProperty1.getPropertyKey())); } } }
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); } } } }
private static void doStopService(final Class<? extends Service> serviceClass) { try { final Service service = GuiceHelper.getGuiceInjector().getInstance(serviceClass); if (service.isRunning()) service .stopAsync() .awaitTerminated( Long.valueOf(PropertyUtil.getValue(null, ServiceStopTimeout.class)), TimeUnit.SECONDS); else LOGGER.warn("Service:" + service + " is already stopped."); } catch (TimeoutException | IllegalStateException e) { LOGGER.warn("Service is still stopping, killing."); } } }
protected Class<? extends AbstractCommandLineHandler> getCommandLineHandlerClass() { return (getOperatingMode(PropertyUtil.getValue(getProperties(), getOperatingModeClass())) .getInitiatorClass()); }