public Parse propertiesFromSource( String identifier ) throws FileNotFoundException, Exception { InputStream rawStream = MultiPropertiesConfig.class.getResourceAsStream( identifier ); if ( rawStream != null ) { InputStream pis = new BufferedInputStream( rawStream ); Properties p = new Properties(); List<DelayedLogItem> messages = new LinkedList<DelayedLogItem>(); try { p.load( pis ); } finally { try { if ( pis != null ) pis.close(); } //ensures closuer of nested rawStream as well catch (IOException e) { messages.add( new DelayedLogItem( Level.WARNING, "An IOException occurred while closing InputStream from resource path '" + identifier + "'.", e ) ); } } return new Parse(p, messages); } else throw new FileNotFoundException( String.format("Resource not found at path '%s'.", identifier) ); } }
pbrp.put( rp, parse.getProperties() ); goodPaths.add( rp ); delayedLogItems.addAll( parse.getDelayedLogItems() );
public Parse propertiesFromSource( String identifier ) throws FileNotFoundException, Exception { if ( "/".equals( identifier ) ) return new Parse( (Properties) System.getProperties().clone(), Collections.<DelayedLogItem>emptyList() ); else throw new Exception( String.format("Unexpected identifier for System properties: '%s'", identifier) ); } }
public Parse propertiesFromSource( ClassLoader cl, String identifier ) throws FileNotFoundException, Exception { List<DelayedLogItem> dlis = new LinkedList<DelayedLogItem>(); Config config = extractConfig( cl, identifier, dlis ); PropertiesConversion pc = configToProperties( config ); for( String path : pc.unrenderable ) dlis.add( new DelayedLogItem( Level.FINE, String.format("Value at path '%s' could not be converted to a String. Skipping.", path) ) ); return new Parse( pc.properties, dlis ); }