public void begin ( InterpretationContext ec , String localName , Attributes attributes ) { if ( "substitutionProperty" . equals ( localName ) ) { addWarn ( "[substitutionProperty] element has been deprecated. Please use the [property] element instead." ) ; } String name = attributes . getValue ( NAME_ATTRIBUTE ) ; String value = attributes . getValue ( VALUE_ATTRIBUTE ) ; String scopeStr = attributes . getValue ( SCOPE_ATTRIBUTE ) ; Scope scope = ActionUtil . stringToScope ( scopeStr ) ; if ( checkFileAttributeSanity ( attributes ) ) { String file = attributes . getValue ( FILE_ATTRIBUTE ) ; file = ec . subst ( file ) ; try { FileInputStream istream = new FileInputStream ( file ) ; loadAndSetProperties ( ec , istream , scope ) ; } catch ( FileNotFoundException e ) { addError ( "Could not find properties file [" + file + "]." ) ; } catch ( IOException e1 ) { addError ( "Could not read properties file [" + file + "]." , e1 ) ; } } else if ( checkResourceAttributeSanity ( attributes ) ) { String resource = attributes . getValue ( RESOURCE_ATTRIBUTE ) ; resource = ec . subst ( resource ) ; URL resourceURL = Loader . getResourceBySelfClassLoader ( resource ) ; if ( resourceURL == null ) { addError ( "Could not find resource [" + resource + "]." ) ; } else { try { InputStream istream = resourceURL . openStream ( ) ; loadAndSetProperties ( ec , istream , scope ) ; } catch ( IOException e ) { addError ( "Could not read resource file [" + resource + "]." , e ) ; } } } else if ( checkValueNameAttributesSanity ( attributes ) ) { value = RegularEscapeUtil . basicEscape ( value ) ; // now remove both leading and trailing spaces value = value . trim ( ) ; value = ec . subst ( value ) ; ActionUtil . setProperty ( ec , name , value , scope ) ; } else { addError ( INVALID_ATTRIBUTES ) ; } }
Set a new property for the execution context by name value pair or adds all the properties found in the given file .