Search in sources :

Example 16 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class ZpmInstall method readOrDefaultConfig.

private ZpmConfiguration readOrDefaultConfig(Path zpmFile) throws IOException {
    ZpmConfiguration config = new ZpmConfiguration();
    config.repositories = emptyList();
    config.imports = emptyList();
    config.dependencies = emptyList();
    Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
    if (Files.exists(zpmFile)) {
        try (InputStream in = newInputStream(zpmFile)) {
            config = builder.fromJson(in, ZpmConfiguration.class);
        }
    }
    return config;
}
Also used : Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) Files.newInputStream(java.nio.file.Files.newInputStream) InputStream(java.io.InputStream)

Example 17 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class ZpmInstall method writeLockFile.

private void writeLockFile(ZpmConfiguration config, Path lockFile) throws IOException {
    Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
    createDirectories(lockDir);
    try (OutputStream out = newOutputStream(lockFile)) {
        builder.toJson(config, out);
    }
}
Also used : Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) JarOutputStream(java.util.jar.JarOutputStream) OutputStream(java.io.OutputStream) Files.newOutputStream(java.nio.file.Files.newOutputStream)

Example 18 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class ZpmEncrypt method readSecurity.

private ZpmSecurity readSecurity(Path settingsDir) throws IOException, PlexusCipherException {
    Path securityFile = settingsDir.resolve("security.json");
    ZpmSecurity security = new ZpmSecurity();
    Jsonb builder = JsonbBuilder.newBuilder().withConfig(new JsonbConfig().withFormatting(true)).build();
    if (Files.exists(securityFile)) {
        try (InputStream in = newInputStream(securityFile)) {
            security = builder.fromJson(in, ZpmSecurity.class);
        }
    }
    return security;
}
Also used : Path(java.nio.file.Path) Jsonb(jakarta.json.bind.Jsonb) JsonbConfig(jakarta.json.bind.JsonbConfig) Files.newInputStream(java.nio.file.Files.newInputStream) InputStream(java.io.InputStream) ZpmSecurity(io.aklivity.zilla.manager.internal.settings.ZpmSecurity)

Example 19 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class NamespaceConfigAdapterTest method initJson.

@Before
public void initJson() {
    JsonbConfig config = new JsonbConfig().withAdapters(new NamespaceAdapter());
    jsonb = JsonbBuilder.create(config);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Before(org.junit.Before)

Example 20 with JsonbConfig

use of jakarta.json.bind.JsonbConfig in project zilla by aklivity.

the class OptionsConfigAdapterTest method initJson.

@Before
public void initJson() {
    adapter = new OptionsAdapter(OptionsConfigAdapterSpi.Kind.BINDING);
    adapter.adaptType("test");
    JsonbConfig config = new JsonbConfig().withAdapters(adapter);
    jsonb = JsonbBuilder.create(config);
}
Also used : JsonbConfig(jakarta.json.bind.JsonbConfig) Before(org.junit.Before)

Aggregations

JsonbConfig (jakarta.json.bind.JsonbConfig)45 Before (org.junit.Before)28 Jsonb (jakarta.json.bind.Jsonb)12 Test (org.junit.jupiter.api.Test)5 InputStream (java.io.InputStream)4 Files.newInputStream (java.nio.file.Files.newInputStream)3 Path (java.nio.file.Path)3 ZpmSecurity (io.aklivity.zilla.manager.internal.settings.ZpmSecurity)2 Annot8ComponentDescriptor (io.annot8.api.components.Annot8ComponentDescriptor)2 Descriptor (io.annot8.common.serialization.TestNested.Descriptor)2 OutputStream (java.io.OutputStream)2 Files.newOutputStream (java.nio.file.Files.newOutputStream)2 ZpmCredentials (io.aklivity.zilla.manager.internal.settings.ZpmCredentials)1 ZpmSettings (io.aklivity.zilla.manager.internal.settings.ZpmSettings)1 Engine (io.aklivity.zilla.runtime.engine.Engine)1 EngineConfiguration (io.aklivity.zilla.runtime.engine.EngineConfiguration)1 BindingConfig (io.aklivity.zilla.runtime.engine.config.BindingConfig)1 NamespaceConfig (io.aklivity.zilla.runtime.engine.config.NamespaceConfig)1 RouteConfig (io.aklivity.zilla.runtime.engine.config.RouteConfig)1 VaultConfig (io.aklivity.zilla.runtime.engine.config.VaultConfig)1