List of usage examples for java.util Properties getProperty
public String getProperty(String key, String defaultValue)
From source file:gobblin.kafka.schemareg.KafkaSchemaRegistryFactory.java
@SuppressWarnings("unchecked") public static KafkaSchemaRegistry getSchemaRegistry(Properties props) { Preconditions.checkArgument(//ww w . ja va 2 s.c o m props.containsKey(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS), "Missing required property " + KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS); boolean tryCache = Boolean.parseBoolean(props.getProperty( KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CACHE, DEFAULT_TRY_CACHING)); Class<?> clazz; try { clazz = (Class<?>) Class .forName(props.getProperty(KafkaSchemaRegistryConfigurationKeys.KAFKA_SCHEMA_REGISTRY_CLASS)); KafkaSchemaRegistry schemaRegistry = (KafkaSchemaRegistry) ConstructorUtils.invokeConstructor(clazz, props); if (tryCache && !schemaRegistry.hasInternalCache()) { schemaRegistry = new CachingKafkaSchemaRegistry(schemaRegistry); } return schemaRegistry; } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { log.error("Failed to instantiate " + KafkaSchemaRegistry.class, e); throw Throwables.propagate(e); } }