static void writeDependenciesFeature ( Writer writer , ProvisionOption < ? > ... provisionOptions ) { XMLOutputFactory xof = XMLOutputFactory . newInstance ( ) ; xof . setProperty ( "javax.xml.stream.isRepairingNamespaces" , true ) ; XMLStreamWriter sw = null ; try { sw = xof . createXMLStreamWriter ( writer ) ; sw . writeStartDocument ( "UTF-8" , "1.0" ) ; sw . setDefaultNamespace ( KARAF_FEATURE_NS ) ; sw . writeCharacters ( "\n" ) ; sw . writeStartElement ( "features" ) ; sw . writeAttribute ( "name" , "test-dependencies" ) ; sw . writeCharacters ( "\n" ) ; sw . writeStartElement ( "feature" ) ; sw . writeAttribute ( "name" , "test-dependencies" ) ; sw . writeCharacters ( "\n" ) ; for ( ProvisionOption < ? > provisionOption : provisionOptions ) { if ( provisionOption . getURL ( ) . startsWith ( "link" ) || provisionOption . getURL ( ) . startsWith ( "scan-features" ) ) { // well those we've already handled at another location... continue ; } sw . writeStartElement ( "bundle" ) ; if ( provisionOption . getStartLevel ( ) != null ) { sw . writeAttribute ( "start-level" , provisionOption . getStartLevel ( ) . toString ( ) ) ; } sw . writeCharacters ( provisionOption . getURL ( ) ) ; endElement ( sw ) ; } endElement ( sw ) ; endElement ( sw ) ; sw . writeEndDocument ( ) ; } catch ( XMLStreamException e ) { throw new RuntimeException ( "Error writing feature " + e . getMessage ( ) , e ) ; } finally { close ( sw ) ; } }
Write a feature xml structure for test dependencies specified as ProvisionOption in system to the given writer