/** * Assumes a lightblue-client.properties file at the root of the classpath. * * <p> * For client configuration property keys, see * {@link com.redhat.lightblue.client.PropertiesLightblueClientConfiguration}. */ public static LightblueClientConfiguration fromDefault() { return fromResource(DEFAULT_CONFIG_FILE); }
/** * Returns a resource found using the current thread's context class loader. * * <p> * For client configuration property keys, see * {@link com.redhat.lightblue.client.PropertiesLightblueClientConfiguration}. * * @param resourcePath Follows the semantics of * {@link java.lang.ClassLoader#getResourceAsStream(String)}, which is to * say it is a relative / separated path from the root of the class path and * should <em>not</em> start with a forward slash (/). * * @see Thread#currentThread() * @see Thread#getContextClassLoader() */ public static LightblueClientConfiguration fromResource(String resourcePath) { return fromResource(resourcePath, Thread.currentThread().getContextClassLoader()); }
/** * For client configuration property keys, see * {@link com.redhat.lightblue.client.PropertiesLightblueClientConfiguration}. * * @param pathToProperties A file system path, relative to the working * directory of the java process. If the specified path has no leading * directories, try to look for it in the classpath instead */ public static LightblueClientConfiguration fromPath(Path pathToProperties) { try { //If specified path has no leading directories, look for the correponding file on the classpath if(pathToProperties.getFileName().toString().equals(pathToProperties.toString())) { return fromResource(pathToProperties.toString()); } else { InputStream inStream = Files.newInputStream(pathToProperties); return fromInputStream(inStream); } } catch (IOException e) { LOGGER.error(pathToProperties + " could not be found/read", e); throw new LightblueClientConfigurationException("Could not read properties file from " + "path, " + pathToProperties, e); } }