/** Creates an instance of the resource object that can access properties * but not resources. */ public static <T> T create(PropertyAccessor accessor, Class<T> clazz) { return create(null, accessor, clazz); }
/** Creates an instance of the resource object that can access properties * but not resources. */ public static <T> T create(PropertyAccessor accessor, Class<T> clazz) { return create(null, accessor, clazz); }
/** Creates an instance of the resource object, using the class's name as * the name of the resource file. * * @see #create(String, Class) * * @param <T> Resource type * @param clazz Interface that contains a method for each resource * @return Instance of the interface that can be used to instantiate * resources */ public static <T> T create(Class<T> clazz) { return create(clazz.getCanonicalName(), clazz); }
/** Creates an instance of the resource object, using the class's name as * the name of the resource file. * * @see #create(String, Class) * * @param <T> Resource type * @param clazz Interface that contains a method for each resource * @return Instance of the interface that can be used to instantiate * resources */ public static <T> T create(Class<T> clazz) { return create(clazz.getCanonicalName(), clazz); }
return create(base, EmptyPropertyAccessor.INSTANCE, clazz);
return create(base, EmptyPropertyAccessor.INSTANCE, clazz);
/** Creates an instance of the resource object that can access properties * but not resources. */ public static <T> T create(final Properties properties, Class<T> clazz) { return create(null, new PropertiesAccessor(properties), clazz); }
/** Creates an instance of the resource object that can access properties * but not resources. */ public static <T> T create(final Properties properties, Class<T> clazz) { return create(null, new PropertiesAccessor(properties), clazz); }
/** * Retrieves the singleton instance of {@link SaffronProperties}. */ static SaffronProperties instance() { Properties properties = new Properties(); // read properties from the file "saffron.properties", if it exists in classpath try (InputStream stream = Helper.class.getClassLoader() .getResourceAsStream("saffron.properties")) { if (stream != null) { properties.load(stream); } } catch (IOException e) { throw new RuntimeException("while reading from saffron.properties file", e); } catch (AccessControlException e) { // we're in a sandbox } // copy in all system properties which start with "saffron." Properties source = System.getProperties(); for (Enumeration keys = source.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); String value = source.getProperty(key); if (key.startsWith("saffron.") || key.startsWith("net.sf.saffron.")) { properties.setProperty(key, value); } } return Resources.create(properties, SaffronProperties.class); } }
/** * Retrieves the singleton instance of {@link SaffronProperties}. */ static SaffronProperties instance() { Properties properties = new Properties(); // read properties from the file "saffron.properties", if it exists in classpath try (InputStream stream = Helper.class.getClassLoader() .getResourceAsStream("saffron.properties")) { if (stream != null) { properties.load(stream); } } catch (IOException e) { throw new RuntimeException("while reading from saffron.properties file", e); } catch (AccessControlException e) { // we're in a sandbox } // copy in all system properties which start with "saffron." Properties source = System.getProperties(); for (Enumeration keys = source.keys(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); String value = source.getProperty(key); if (key.startsWith("saffron.") || key.startsWith("net.sf.saffron.")) { properties.setProperty(key, value); } } return Resources.create(properties, SaffronProperties.class); } }