public static void writeDataSource(PrintStream writer,DataSource ds){
  writer.print("  <dataSource jndiName=\"");
  writer.print(ds.getJndiLocation());
  writer.print("\" id=\"");
  writer.print(ds.getId());
  writer.println("\">");
  writer.print("    <jdbcDriver libraryRef=\"cargoLib\" ");
  writer.print(ds.getConnectionType());
  writer.print("=\"");
  writer.print(ds.getDriverClass());
  writer.println("\"/>");
  writer.print("    <properties ");
  String url=ds.getUrl();
  if (url != null) {
    writer.print("URL=\"");
    writer.print(ds.getUrl());
    writer.print("\" ");
  }
  writeProperties(writer,ds.getConnectionProperties());
  writer.println("/>");
  String user=ds.getUsername();
  String pass=ds.getPassword();
  if (user != null && pass != null) {
    writer.print("    <containerAuthData user=\"");
    writer.print(user);
    writer.print("\" password=\"");
    writer.print(pass);
    writer.println("\"/>");
  }
  writer.println("  </dataSource>");
}

public static void writeDataSource ( PrintStream writer , DataSource ds ) { writer . print ( "  <dataSource jndiName=\"" ) ; writer . print ( ds . getJndiLocation ( ) ) ; writer . print ( "\" id=\"" ) ; writer . print ( ds . getId ( ) ) ; writer . println ( "\">" ) ; writer . print ( "    <jdbcDriver libraryRef=\"cargoLib\" " ) ; writer . print ( ds . getConnectionType ( ) ) ; writer . print ( "=\"" ) ; writer . print ( ds . getDriverClass ( ) ) ; writer . println ( "\"/>" ) ; writer . print ( "    <properties " ) ; String url = ds . getUrl ( ) ; if ( url != null ) { writer . print ( "URL=\"" ) ; writer . print ( ds . getUrl ( ) ) ; writer . print ( "\" " ) ; } writeProperties ( writer , ds . getConnectionProperties ( ) ) ; writer . println ( "/>" ) ; String user = ds . getUsername ( ) ; String pass = ds . getPassword ( ) ; if ( user != null && pass != null ) { writer . print ( "    <containerAuthData user=\"" ) ; writer . print ( user ) ; writer . print ( "\" password=\"" ) ; writer . print ( pass ) ; writer . println ( "\"/>" ) ; } writer . println ( "  </dataSource>" ) ; }
writes a datasource to the write .
