You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/12/17 10:31:25 UTC
[shardingsphere] branch master updated: Remove YamlEngine (#22935)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 259a5b763e5 Remove YamlEngine (#22935)
259a5b763e5 is described below
commit 259a5b763e5aa437e441d9512094704f35bc8ba9
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sat Dec 17 18:31:18 2022 +0800
Remove YamlEngine (#22935)
---
.../config/loader/PluginConfigurationLoader.java | 16 ++++---
.../shardingsphere/agent/core/yaml/YamlEngine.java | 51 ----------------------
2 files changed, 11 insertions(+), 56 deletions(-)
diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/PluginConfigurationLoader.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/PluginConfigurationLoader.java
index 9bc0a241ea9..61fcd5c7d2c 100644
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/PluginConfigurationLoader.java
+++ b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/config/loader/PluginConfigurationLoader.java
@@ -21,13 +21,15 @@ import com.google.common.base.Preconditions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.agent.config.plugin.PluginConfiguration;
-import org.apache.shardingsphere.agent.core.path.AgentPathBuilder;
import org.apache.shardingsphere.agent.core.config.yaml.entity.YamlPluginsConfiguration;
import org.apache.shardingsphere.agent.core.config.yaml.swapper.YamlPluginsConfigurationSwapper;
-import org.apache.shardingsphere.agent.core.yaml.YamlEngine;
+import org.apache.shardingsphere.agent.core.path.AgentPathBuilder;
+import org.yaml.snakeyaml.Yaml;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.Map;
/**
@@ -50,8 +52,12 @@ public final class PluginConfigurationLoader {
}
private static YamlPluginsConfiguration load(final File yamlFile) throws IOException {
- YamlPluginsConfiguration result = YamlEngine.unmarshal(yamlFile, YamlPluginsConfiguration.class);
- Preconditions.checkNotNull(result, "Agent configuration file `%s` is invalid.", yamlFile.getName());
- return result;
+ try (
+ FileInputStream fileInputStream = new FileInputStream(yamlFile);
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
+ YamlPluginsConfiguration result = new Yaml().loadAs(inputStreamReader, YamlPluginsConfiguration.class);
+ Preconditions.checkNotNull(result, "Agent configuration file `%s` is invalid.", yamlFile.getName());
+ return result;
+ }
}
}
diff --git a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/yaml/YamlEngine.java b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/yaml/YamlEngine.java
deleted file mode 100644
index 605a89cb932..00000000000
--- a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/yaml/YamlEngine.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.agent.core.yaml;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-/**
- * YAML engine.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class YamlEngine {
-
- /**
- * Unmarshal YAML.
- *
- * @param yamlFile YAML file
- * @param classType class type
- * @param <T> type of class
- * @return object from YAML
- * @throws IOException IO Exception
- */
- public static <T> T unmarshal(final File yamlFile, final Class<T> classType) throws IOException {
- try (
- FileInputStream fileInputStream = new FileInputStream(yamlFile);
- InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream)) {
- return new Yaml().loadAs(inputStreamReader, classType);
- }
- }
-}