List of usage examples for org.springframework.core.env PropertyResolver getProperty
<T> T getProperty(String key, Class<T> targetType, T defaultValue);
From source file:com.indeed.imhotep.iql.cache.QueryCacheFactory.java
public static final QueryCache newQueryCache(PropertyResolver props) throws PropertyException { final String cacheType; boolean enabled; enabled = props.getProperty("query.cache.enabled", Boolean.class, true); if (!enabled) { log.info("Query caching disabled in config"); return new NoOpQueryCache(); }//from w ww. jav a 2 s . co m cacheType = props.getProperty("query.cache.backend", String.class, "HDFS"); if ("HDFS".equals(cacheType)) { return new HDFSQueryCache(props); } if ("S3".equals(cacheType)) { return new S3QueryCache(props); } throw new PropertyException("Unknown cache type (property: query.cache.backend): " + cacheType); }
From source file:org.grails.datastore.mapping.mongo.config.MongoMappingContext.java
public static String getDefaultDatabaseName(PropertyResolver configuration) { String connectionString = configuration.getProperty(MongoDatastore.SETTING_CONNECTION_STRING, String.class, null);/*from w w w.j a va2 s .c o m*/ if (connectionString != null) { MongoClientURI mongoClientURI = new MongoClientURI(connectionString); String database = mongoClientURI.getDatabase(); if (database != null) { return database; } } return configuration.getProperty(MongoSettings.SETTING_DATABASE_NAME, "test"); }
From source file:org.grails.datastore.mapping.mongo.config.MongoMappingContext.java
/** * Constructs a new {@link MongoMappingContext} for the given arguments * * @param configuration The configuration * @param classes The persistent classes * @deprecated Use {@link #MongoMappingContext(AbstractMongoConnectionSourceSettings, Class[])} instead * *//*from w ww.ja v a 2 s . co m*/ @Deprecated public MongoMappingContext(PropertyResolver configuration, Class... classes) { this(getDefaultDatabaseName(configuration), configuration.getProperty(MongoSettings.SETTING_DEFAULT_MAPPING, Closure.class, null), classes); }
From source file:org.springframework.boot.ImageBanner.java
private void printBanner(Environment environment, PrintStream out) throws IOException { PropertyResolver properties = new RelaxedPropertyResolver(environment, "banner.image."); int width = properties.getProperty("width", Integer.class, 76); int height = properties.getProperty("height", Integer.class, 0); int margin = properties.getProperty("margin", Integer.class, 2); boolean invert = properties.getProperty("invert", Boolean.class, false); BufferedImage image = readImage(width, height); printBanner(image, margin, invert, out); }