diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-06-01 11:31:13 +0200 |
commit | cd6e2dd7ab638487c462c40293a0d8db43fdb530 (patch) | |
tree | edf9cec58f4a0e995fd713089779ec5d0a14d134 /standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java | |
parent | f7d0fe5fdfad579e867f01acc1d41b2ec77bd785 (diff) | |
parent | 5c57852b26126d72b080fb6e0893dc3d633c28c1 (diff) |
Merge with master
Diffstat (limited to 'standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java')
-rw-r--r-- | standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java b/standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java new file mode 100644 index 00000000000..a0fee3265df --- /dev/null +++ b/standalone-container/src/main/java/com/yahoo/application/container/impl/StandaloneContainerRunner.java @@ -0,0 +1,34 @@ +// 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; + } +} |