blob: 8b07a4d4ef8110188d1437612b180ad3504694b8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container.impl;
import com.yahoo.text.Utf8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
/**
* @author Tony Vaagenes
* @author ollivir
*/
public class StandaloneContainerRunner {
public static Path createApplicationPackage(String servicesXml) {
try {
return createApplicationDirectory(servicesXml);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static Path createApplicationDirectory(String servicesXml) throws IOException {
Path applicationDir = Files.createTempDirectory("application");
Path servicesXmlFile = applicationDir.resolve("services.xml");
String content = servicesXml;
if (!servicesXml.startsWith("<?xml")) {
content = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + servicesXml;
}
Files.write(servicesXmlFile, Utf8.toBytes(content));
return applicationDir;
}
}
|