/** * Load a Properties object from the given stream, close it, and then populate * the Composite with the properties. * * @param propertyInputStream properties input stream * @param composite the instance * * @throws IOException if the stream could not be read */ public static void map( InputStream propertyInputStream, Composite composite ) throws IOException { if( propertyInputStream != null ) { Properties configProps = new Properties(); try { configProps.load( propertyInputStream ); } finally { propertyInputStream.close(); } map( configProps, composite ); } }
Type propertyType = GenericPropertyInfo.propertyTypeOf( propertyMethod ); value = mapToType( composite, propertyType, value.toString() );
private static void tokenize( String valueString, boolean mapSyntax, TokenizerCallback callback ) { char[] data = valueString.toCharArray(); int oldPos = 0; for( int pos = 0; pos < data.length; pos++ ) { char ch = data[ pos ]; if( ch == '\"' ) { pos = resolveQuotes( valueString, callback, data, pos, '\"' ); oldPos = pos; } if( ch == '\'' ) { pos = resolveQuotes( valueString, callback, data, pos, '\'' ); oldPos = pos; } if( ch == ',' || ( mapSyntax && ch == ':' ) ) { String token = new String( data, oldPos, pos - oldPos ); callback.token( token ); oldPos = pos + 1; } } String token = new String( data, oldPos, data.length - oldPos ); callback.token( token ); }
/** * Load a Properties object from the given stream, close it, and then populate * the Composite with the properties. * * @param propertyInputStream properties input stream * @param composite the instance * * @throws IOException if the stream could not be read */ public static void map( InputStream propertyInputStream, Composite composite ) throws IOException { if( propertyInputStream != null ) { Properties configProps = new Properties(); try { configProps.load( propertyInputStream ); } finally { propertyInputStream.close(); } map( configProps, composite ); } }
private static void tokenize( String valueString, boolean mapSyntax, TokenizerCallback callback ) { char[] data = valueString.toCharArray(); int oldPos = 0; for( int pos = 0; pos < data.length; pos++ ) { char ch = data[ pos ]; if( ch == '\"' ) { pos = resolveQuotes( valueString, callback, data, pos, '\"' ); oldPos = pos; } if( ch == '\'' ) { pos = resolveQuotes( valueString, callback, data, pos, '\'' ); oldPos = pos; } if( ch == ',' || ( mapSyntax && ch == ':' ) ) { String token = new String( data, oldPos, pos - oldPos ); callback.token( token ); oldPos = pos + 1; } } String token = new String( data, oldPos, data.length - oldPos ); callback.token( token ); }
Type propertyType = GenericPropertyInfo.propertyTypeOf( propertyMethod ); value = mapToType( composite, propertyType, value.toString() );
private <V> V tryLoadSystemProperties( UnitOfWork buildUow, EntityDescriptor configType, Identity identity ) throws InstantiationException { @SuppressWarnings( "unchecked" ) EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( (Class<V>) configType.primaryType(), identity ); PropertyMapper.map( systemProperties(), (Composite) configBuilder.instance() ); return configBuilder.newInstance(); }
private <V> V tryLoadSystemProperties( UnitOfWork buildUow, EntityDescriptor configType, Identity identity ) throws InstantiationException { @SuppressWarnings( "unchecked" ) EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( (Class<V>) configType.primaryType(), identity ); PropertyMapper.map( systemProperties(), (Composite) configBuilder.instance() ); return configBuilder.newInstance(); }
if ( asStream != null ) { try { PropertyMapper.map( asStream, (Composite) configBuilder.instance() ); } catch ( IOException e1 ) { uow.discard();
if ( asStream != null ) { try { PropertyMapper.map( asStream, (Composite) configBuilder.instance() ); } catch ( IOException e1 ) { uow.discard();
private <V> V tryLoadPropertiesFile( UnitOfWork buildUow, EntityDescriptor configType, Identity identity ) throws InstantiationException { @SuppressWarnings( "unchecked" ) EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( (Class<V>) configType.primaryType(), identity ); String resourceName = identity + ".properties"; try( InputStream asStream = getResource( configType.primaryType(), resourceName ) ) { if( asStream != null ) { try { PropertyMapper.map( asStream, (Composite) configBuilder.instance() ); return configBuilder.newInstance(); } catch( IOException e1 ) { InstantiationException exception = new InstantiationException( "Could not read underlying Properties file." ); exception.initCause( e1 ); throw exception; } } return null; } catch( IOException ignored ) { return null; } }
private <V> V tryLoadPropertiesFile( UnitOfWork buildUow, EntityDescriptor configType, Identity identity ) throws InstantiationException { @SuppressWarnings( "unchecked" ) EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( (Class<V>) configType.primaryType(), identity ); String resourceName = identity + ".properties"; try( InputStream asStream = getResource( configType.primaryType(), resourceName ) ) { if( asStream != null ) { try { PropertyMapper.map( asStream, (Composite) configBuilder.instance() ); return configBuilder.newInstance(); } catch( IOException e1 ) { InstantiationException exception = new InstantiationException( "Could not read underlying Properties file." ); exception.initCause( e1 ); throw exception; } } return null; } catch( IOException ignored ) { return null; } }