You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/15 09:21:17 UTC
[GitHub] [shardingsphere] dachuan9e opened a new pull request #12448: Refactor plugin loader
dachuan9e opened a new pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448
Changes proposed in this pull request:
- Refactor plugin loader
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709153151
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/Loader.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.plugin;
+
+import net.bytebuddy.description.type.TypeDescription;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+
+public interface Loader {
+ /**
+ * To detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true
+ */
+ boolean containsType(TypeDescription typeDescription);
+
+ /**
+ * Load plugin interceptor point by TypeDescription.
+ *
+ * @param typeDescription TypeDescription
Review comment:
`@param typeDescription TypeDescription` should rewrite to `@param typeDescription type description`
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/Loader.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.plugin;
+
+import net.bytebuddy.description.type.TypeDescription;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+
+public interface Loader {
Review comment:
`Loader` is too generic, `PluginLoader` is better
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/Loader.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.plugin;
+
+import net.bytebuddy.description.type.TypeDescription;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+
+public interface Loader {
+ /**
+ * To detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true
+ */
+ boolean containsType(TypeDescription typeDescription);
+
+ /**
+ * Load plugin interceptor point by TypeDescription.
+ *
+ * @param typeDescription TypeDescription
+ * @return plugin interceptor point
+ */
+ PluginInterceptorPoint loadPluginInterceptorPoint(TypeDescription typeDescription);
+
+ /**
+ * To get or create instance of the advice class. Create new one and caching when it is not exist.
+ *
+ * @param classNameOfAdvice class name of advice
+ * @param <T> advice type
+ * @return instance of advice
+ */
+ <T> T getOrCreateInstance(String classNameOfAdvice);
Review comment:
It is better to rename `classNameOfAdvice` to `adviceClassName`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709799646
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -178,4 +169,22 @@
}
return result;
}
+
+ private ShardingSphereTransformationPoint<?> getInstanceMethodTransformationPoint(final MethodDescription.InDefinedShape md, final List<InstanceMethodPoint> instanceMethodAroundPoints) {
Review comment:
Please do not use inline import, just use `InDefinedShape`.
By the way, `md` is not match to `InDefinedShape`, is it?
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginApmLoader.java
##########
@@ -0,0 +1,289 @@
+/*
+ * 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.plugin;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.io.ByteStreams;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatcher.Junction;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.apache.shardingsphere.agent.config.AgentConfiguration;
+import org.apache.shardingsphere.agent.core.config.path.AgentPathBuilder;
+import org.apache.shardingsphere.agent.core.config.registry.AgentConfigurationRegistry;
+import org.apache.shardingsphere.agent.core.spi.PluginServiceLoader;
+import org.apache.shardingsphere.agent.spi.definition.AbstractPluginDefinitionService;
+import org.apache.shardingsphere.agent.spi.definition.PluginDefinitionService;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * Plugin loader.
+ */
+@Slf4j
+public final class PluginApmLoader extends ClassLoader implements Closeable, PluginLoader {
Review comment:
`PluginApmLoader` or `ApmPluginLoader`?
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginApmLoader.java
##########
@@ -0,0 +1,289 @@
+/*
+ * 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.plugin;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.io.ByteStreams;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatcher.Junction;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.apache.shardingsphere.agent.config.AgentConfiguration;
+import org.apache.shardingsphere.agent.core.config.path.AgentPathBuilder;
+import org.apache.shardingsphere.agent.core.config.registry.AgentConfigurationRegistry;
+import org.apache.shardingsphere.agent.core.spi.PluginServiceLoader;
+import org.apache.shardingsphere.agent.spi.definition.AbstractPluginDefinitionService;
+import org.apache.shardingsphere.agent.spi.definition.PluginDefinitionService;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * Plugin loader.
+ */
+@Slf4j
+public final class PluginApmLoader extends ClassLoader implements Closeable, PluginLoader {
+
+ static {
+ registerAsParallelCapable();
+ }
+
+ private static volatile PluginApmLoader pluginLoader;
+
+ private final ConcurrentHashMap<String, Object> objectPool = new ConcurrentHashMap<>();
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ private final List<PluginJar> jars = new ArrayList<>();
+
+ private Map<String, PluginInterceptorPoint> interceptorPointMap;
+
+ private PluginApmLoader() {
+ super(PluginApmLoader.class.getClassLoader());
+ }
+
+ /**
+ * Get plugin loader instance.
+ *
+ * @return plugin loader instance
+ */
+ public static PluginApmLoader getInstance() {
+ if (null == pluginLoader) {
+ synchronized (PluginApmLoader.class) {
+ if (null == pluginLoader) {
+ pluginLoader = new PluginApmLoader();
+ }
+ }
+ }
+ return pluginLoader;
+ }
+
+ /**
+ * Load all plugins.
+ *
+ * @throws IOException IO exception
+ */
+ public void loadAllPlugins() throws IOException {
+ File[] jarFiles = AgentPathBuilder.getPluginPath().listFiles(file -> file.getName().endsWith(".jar"));
+ if (null == jarFiles) {
+ return;
+ }
+ Map<String, PluginInterceptorPoint> pointMap = new HashMap<>();
+ Set<String> ignoredPluginNames = AgentConfigurationRegistry.INSTANCE.get(AgentConfiguration.class).getIgnoredPluginNames();
+ try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+ for (File each : jarFiles) {
+ outputStream.reset();
+ JarFile jar = new JarFile(each, true);
+ jars.add(new PluginJar(jar, each));
+ log.info("Loaded jar {}", each.getName());
+ }
+ }
+ loadPluginDefinitionServices(ignoredPluginNames, pointMap);
+ interceptorPointMap = ImmutableMap.<String, PluginInterceptorPoint>builder().putAll(pointMap).build();
+ }
+
+ /**
+ * To find all intercepting target classes then to build TypeMatcher.
+ *
+ * @return type matcher
+ */
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ return new Junction<TypeDescription>() {
+
+ @Override
+ public boolean matches(final TypeDescription target) {
+ return interceptorPointMap.containsKey(target.getTypeName());
+ }
+
+ @Override
+ public <U extends TypeDescription> Junction<U> and(final ElementMatcher<? super U> other) {
+ return null;
+ }
+
+ @Override
+ public <U extends TypeDescription> Junction<U> or(final ElementMatcher<? super U> other) {
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public boolean containsType(final TypeDescription typeDescription) {
+ return interceptorPointMap.containsKey(typeDescription.getTypeName());
+ }
+
+ @Override
+ public PluginInterceptorPoint loadPluginInterceptorPoint(final TypeDescription typeDescription) {
+ return interceptorPointMap.getOrDefault(typeDescription.getTypeName(), PluginInterceptorPoint.createDefault());
+ }
+
+ @Override
+ @SneakyThrows({ClassNotFoundException.class, IllegalAccessException.class, InstantiationException.class})
+ @SuppressWarnings("unchecked")
+ public <T> T getOrCreateInstance(final String adviceClassName) {
+ if (objectPool.containsKey(adviceClassName)) {
+ return (T) objectPool.get(adviceClassName);
+ }
+ lock.lock();
+ try {
+ Object inst = objectPool.get(adviceClassName);
+ if (Objects.isNull(inst)) {
+ inst = Class.forName(adviceClassName, true, this).newInstance();
+ objectPool.put(adviceClassName, inst);
+ }
+ return (T) inst;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ protected Class<?> findClass(final String name) throws ClassNotFoundException {
+ String path = classNameToPath(name);
+ for (PluginJar each : jars) {
+ ZipEntry entry = each.jarFile.getEntry(path);
+ if (Objects.nonNull(entry)) {
+ try {
+ int index = name.lastIndexOf('.');
+ if (index != -1) {
+ String packageName = name.substring(0, index);
+ definePackageInternal(packageName, each.jarFile.getManifest());
+ }
+ byte[] data = ByteStreams.toByteArray(each.jarFile.getInputStream(entry));
+ return defineClass(name, data, 0, data.length);
+ } catch (final IOException ex) {
+ log.error("Failed to load class {}", name, ex);
+ }
+ }
+ }
+ throw new ClassNotFoundException(String.format("Class name is %s not found", name));
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(final String name) {
+ Collection<URL> resources = new LinkedList<>();
+ for (PluginJar each : jars) {
+ JarEntry entry = each.jarFile.getJarEntry(name);
+ if (Objects.nonNull(entry)) {
+ try {
+ resources.add(new URL(String.format("jar:file:%s!/%s", each.sourcePath.getAbsolutePath(), name)));
+ } catch (final MalformedURLException ignored) {
+ }
+ }
+ }
+ return Collections.enumeration(resources);
+ }
+
+ @Override
+ protected URL findResource(final String name) {
+ for (PluginJar each : jars) {
+ JarEntry entry = each.jarFile.getJarEntry(name);
+ if (Objects.nonNull(entry)) {
+ try {
+ return new URL(String.format("jar:file:%s!/%s", each.sourcePath.getAbsolutePath(), name));
+ } catch (final MalformedURLException ignored) {
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void close() {
+ for (PluginJar each : jars) {
+ try {
+ each.jarFile.close();
+ } catch (final IOException ex) {
+ log.error("close is ", ex);
Review comment:
Error message "close is " is not clear
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -145,28 +132,32 @@
return result;
}
+ private ShardingSphereTransformationPoint<?> getStaticClassTransformationPoint(final MethodDescription.InDefinedShape md, final List<ClassStaticMethodPoint> classStaticMethodAroundPoints) {
+ List<ClassStaticMethodPoint> classStaticMethodPoints = classStaticMethodAroundPoints.stream().filter(point -> point.getMatcher().matches(md)).collect(Collectors.toList());
+ if (classStaticMethodPoints.isEmpty()) {
+ return null;
+ }
+ if (classStaticMethodPoints.size() == 1) {
+ return new ShardingSphereTransformationPoint<>(md, new ClassStaticMethodAroundInterceptor(pluginLoader.getOrCreateInstance(classStaticMethodPoints.get(0).getAdvice())));
+ } else {
+ Collection<ClassStaticMethodAroundAdvice> classStaticMethodAroundAdvices = new LinkedList<>();
+ for (ClassStaticMethodPoint point : classStaticMethodPoints) {
+ if (null != point.getAdvice()) {
+ classStaticMethodAroundAdvices.add(pluginLoader.getOrCreateInstance(point.getAdvice()));
+ }
+ }
+ return new ShardingSphereTransformationPoint<>(md, new ComposeClassStaticMethodAroundInterceptor(classStaticMethodAroundAdvices));
Review comment:
Please rename `md` to `methodDescription` too.
It is better to do the global search
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709808726
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginApmLoader.java
##########
@@ -0,0 +1,289 @@
+/*
+ * 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.plugin;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.io.ByteStreams;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatcher.Junction;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+import org.apache.shardingsphere.agent.config.AgentConfiguration;
+import org.apache.shardingsphere.agent.core.config.path.AgentPathBuilder;
+import org.apache.shardingsphere.agent.core.config.registry.AgentConfigurationRegistry;
+import org.apache.shardingsphere.agent.core.spi.PluginServiceLoader;
+import org.apache.shardingsphere.agent.spi.definition.AbstractPluginDefinitionService;
+import org.apache.shardingsphere.agent.spi.definition.PluginDefinitionService;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+/**
+ * Plugin loader.
+ */
+@Slf4j
+public final class PluginApmLoader extends ClassLoader implements Closeable, PluginLoader {
+
+ static {
+ registerAsParallelCapable();
+ }
+
+ private static volatile PluginApmLoader pluginLoader;
+
+ private final ConcurrentHashMap<String, Object> objectPool = new ConcurrentHashMap<>();
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ private final List<PluginJar> jars = new ArrayList<>();
+
+ private Map<String, PluginInterceptorPoint> interceptorPointMap;
+
+ private PluginApmLoader() {
+ super(PluginApmLoader.class.getClassLoader());
+ }
+
+ /**
+ * Get plugin loader instance.
+ *
+ * @return plugin loader instance
+ */
+ public static PluginApmLoader getInstance() {
+ if (null == pluginLoader) {
+ synchronized (PluginApmLoader.class) {
+ if (null == pluginLoader) {
+ pluginLoader = new PluginApmLoader();
+ }
+ }
+ }
+ return pluginLoader;
+ }
+
+ /**
+ * Load all plugins.
+ *
+ * @throws IOException IO exception
+ */
+ public void loadAllPlugins() throws IOException {
+ File[] jarFiles = AgentPathBuilder.getPluginPath().listFiles(file -> file.getName().endsWith(".jar"));
+ if (null == jarFiles) {
+ return;
+ }
+ Map<String, PluginInterceptorPoint> pointMap = new HashMap<>();
+ Set<String> ignoredPluginNames = AgentConfigurationRegistry.INSTANCE.get(AgentConfiguration.class).getIgnoredPluginNames();
+ try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
+ for (File each : jarFiles) {
+ outputStream.reset();
+ JarFile jar = new JarFile(each, true);
+ jars.add(new PluginJar(jar, each));
+ log.info("Loaded jar {}", each.getName());
+ }
+ }
+ loadPluginDefinitionServices(ignoredPluginNames, pointMap);
+ interceptorPointMap = ImmutableMap.<String, PluginInterceptorPoint>builder().putAll(pointMap).build();
+ }
+
+ /**
+ * To find all intercepting target classes then to build TypeMatcher.
+ *
+ * @return type matcher
+ */
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ return new Junction<TypeDescription>() {
+
+ @Override
+ public boolean matches(final TypeDescription target) {
+ return interceptorPointMap.containsKey(target.getTypeName());
+ }
+
+ @Override
+ public <U extends TypeDescription> Junction<U> and(final ElementMatcher<? super U> other) {
+ return null;
+ }
+
+ @Override
+ public <U extends TypeDescription> Junction<U> or(final ElementMatcher<? super U> other) {
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public boolean containsType(final TypeDescription typeDescription) {
+ return interceptorPointMap.containsKey(typeDescription.getTypeName());
+ }
+
+ @Override
+ public PluginInterceptorPoint loadPluginInterceptorPoint(final TypeDescription typeDescription) {
+ return interceptorPointMap.getOrDefault(typeDescription.getTypeName(), PluginInterceptorPoint.createDefault());
+ }
+
+ @Override
+ @SneakyThrows({ClassNotFoundException.class, IllegalAccessException.class, InstantiationException.class})
+ @SuppressWarnings("unchecked")
+ public <T> T getOrCreateInstance(final String adviceClassName) {
+ if (objectPool.containsKey(adviceClassName)) {
+ return (T) objectPool.get(adviceClassName);
+ }
+ lock.lock();
+ try {
+ Object inst = objectPool.get(adviceClassName);
+ if (Objects.isNull(inst)) {
+ inst = Class.forName(adviceClassName, true, this).newInstance();
+ objectPool.put(adviceClassName, inst);
+ }
+ return (T) inst;
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ protected Class<?> findClass(final String name) throws ClassNotFoundException {
+ String path = classNameToPath(name);
+ for (PluginJar each : jars) {
+ ZipEntry entry = each.jarFile.getEntry(path);
+ if (Objects.nonNull(entry)) {
+ try {
+ int index = name.lastIndexOf('.');
+ if (index != -1) {
+ String packageName = name.substring(0, index);
+ definePackageInternal(packageName, each.jarFile.getManifest());
+ }
+ byte[] data = ByteStreams.toByteArray(each.jarFile.getInputStream(entry));
+ return defineClass(name, data, 0, data.length);
+ } catch (final IOException ex) {
+ log.error("Failed to load class {}", name, ex);
+ }
+ }
+ }
+ throw new ClassNotFoundException(String.format("Class name is %s not found", name));
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(final String name) {
+ Collection<URL> resources = new LinkedList<>();
+ for (PluginJar each : jars) {
+ JarEntry entry = each.jarFile.getJarEntry(name);
+ if (Objects.nonNull(entry)) {
+ try {
+ resources.add(new URL(String.format("jar:file:%s!/%s", each.sourcePath.getAbsolutePath(), name)));
+ } catch (final MalformedURLException ignored) {
+ }
+ }
+ }
+ return Collections.enumeration(resources);
+ }
+
+ @Override
+ protected URL findResource(final String name) {
+ for (PluginJar each : jars) {
+ JarEntry entry = each.jarFile.getJarEntry(name);
+ if (Objects.nonNull(entry)) {
+ try {
+ return new URL(String.format("jar:file:%s!/%s", each.sourcePath.getAbsolutePath(), name));
+ } catch (final MalformedURLException ignored) {
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void close() {
+ for (PluginJar each : jars) {
+ try {
+ each.jarFile.close();
+ } catch (final IOException ex) {
+ log.error("close is ", ex);
Review comment:
will change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#issuecomment-920024056
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12448](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (952640e) into [master](https://codecov.io/gh/apache/shardingsphere/commit/46aeeff1b2e837fe514df3097e4945057b911e7a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (46aeeff) will **increase** coverage by `0.16%`.
> The diff coverage is `0.61%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12448/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #12448 +/- ##
============================================
+ Coverage 63.44% 63.61% +0.16%
- Complexity 1295 1304 +9
============================================
Files 2391 2399 +8
Lines 36345 36502 +157
Branches 6308 6337 +29
============================================
+ Hits 23059 23219 +160
+ Misses 11430 11409 -21
- Partials 1856 1874 +18
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ingsphere/agent/bootstrap/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9hZ2VudC9ib290c3RyYXAvU2hhcmRpbmdTcGhlcmVBZ2VudC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...tebuddy/transformer/ShardingSphereTransformer.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvU2hhcmRpbmdTcGhlcmVUcmFuc2Zvcm1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...rmer/advice/ComposeInstanceMethodAroundAdvice.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvYWR2aWNlL0NvbXBvc2VJbnN0YW5jZU1ldGhvZEFyb3VuZEFkdmljZS5qYXZh) | `0.00% <ø> (ø)` | |
| [...rdingsphere/agent/core/plugin/ApmPluginLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vQXBtUGx1Z2luTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...nterceptor/ClassStaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvQ2xhc3NTdGF0aWNNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...n/interceptor/InstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...ompose/ComposeInstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvY29tcG9zZS9Db21wb3NlSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <ø> (ø)` | |
| [...rdingsphere/agent/core/spi/AgentServiceLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9zcGkvQWdlbnRTZXJ2aWNlTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...dingsphere/agent/core/spi/PluginServiceLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9zcGkvUGx1Z2luU2VydmljZUxvYWRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...trics/prometheus/collector/ProxyInfoCollector.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLXByb21ldGhldXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2FnZW50L21ldHJpY3MvcHJvbWV0aGV1cy9jb2xsZWN0b3IvUHJveHlJbmZvQ29sbGVjdG9yLmphdmE=) | `86.66% <100.00%> (ø)` | |
| ... and [65 more](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [46aeeff...952640e](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu merged pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
terrymanu merged pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] terrymanu commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709154279
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -112,27 +113,13 @@
}
private Builder<?> interceptorClassStaticMethodPoint(final TypeDescription description, final List<ClassStaticMethodPoint> classStaticMethodAroundPoints, final Builder<?> builder) {
- List<ShardingSphereTransformationPoint<? extends ClassStaticMethodAroundInterceptor>> classStaticMethodAdvicePoints = description.getDeclaredMethods().stream()
+ List<ShardingSphereTransformationPoint<?>> classStaticMethodAdvicePoints = description.getDeclaredMethods().stream()
.filter(each -> each.isStatic() && !(each.isAbstract() || each.isSynthetic()))
- .map(md -> {
- List<ClassStaticMethodPoint> classStaticMethodPoints = classStaticMethodAroundPoints.stream().filter(point -> point.getMatcher().matches(md)).collect(Collectors.toList());
- if (classStaticMethodPoints.isEmpty()) {
- return null;
- }
- if (classStaticMethodPoints.size() == 1) {
- return new ShardingSphereTransformationPoint<>(md, new ClassStaticMethodAroundInterceptor(pluginLoader.getOrCreateInstance(classStaticMethodPoints.get(0).getAdvice())));
- } else {
- Collection<ClassStaticMethodAroundAdvice> classStaticMethodAroundAdvices = classStaticMethodPoints.stream()
- .map(ClassStaticMethodPoint::getAdvice)
- .map(advice -> (ClassStaticMethodAroundAdvice) pluginLoader.getOrCreateInstance(advice))
- .collect(Collectors.toList());
- return new ShardingSphereTransformationPoint<>(md, new ComposeClassStaticMethodAroundInterceptor(classStaticMethodAroundAdvices));
- }
- })
+ .map(md -> getStaticClassTransformationPoint(md, classStaticMethodAroundPoints))
Review comment:
What is `md`? Is it better to change another name?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709808580
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -178,4 +169,22 @@
}
return result;
}
+
+ private ShardingSphereTransformationPoint<?> getInstanceMethodTransformationPoint(final MethodDescription.InDefinedShape md, final List<InstanceMethodPoint> instanceMethodAroundPoints) {
Review comment:
`IndefinedShape` extends the `MethodDescription`. It's ok for naming as `md` .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter commented on pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#issuecomment-920024056
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12448](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (318e372) into [master](https://codecov.io/gh/apache/shardingsphere/commit/46aeeff1b2e837fe514df3097e4945057b911e7a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (46aeeff) will **increase** coverage by `0.12%`.
> The diff coverage is `2.63%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12448/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #12448 +/- ##
============================================
+ Coverage 63.44% 63.56% +0.12%
- Complexity 1295 1303 +8
============================================
Files 2391 2396 +5
Lines 36345 36476 +131
Branches 6308 6332 +24
============================================
+ Hits 23059 23187 +128
+ Misses 11430 11415 -15
- Partials 1856 1874 +18
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...tebuddy/transformer/ShardingSphereTransformer.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvU2hhcmRpbmdTcGhlcmVUcmFuc2Zvcm1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...rmer/advice/ComposeInstanceMethodAroundAdvice.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvYWR2aWNlL0NvbXBvc2VJbnN0YW5jZU1ldGhvZEFyb3VuZEFkdmljZS5qYXZh) | `0.00% <ø> (ø)` | |
| [...shardingsphere/agent/core/plugin/PluginLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...nterceptor/ClassStaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvQ2xhc3NTdGF0aWNNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...n/interceptor/InstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...ompose/ComposeInstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvY29tcG9zZS9Db21wb3NlSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <ø> (ø)` | |
| [...trics/prometheus/collector/ProxyInfoCollector.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLXByb21ldGhldXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2FnZW50L21ldHJpY3MvcHJvbWV0aGV1cy9jb2xsZWN0b3IvUHJveHlJbmZvQ29sbGVjdG9yLmphdmE=) | `86.66% <100.00%> (ø)` | |
| [.../statement/impl/PostgreSQLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci9zaGFyZGluZ3NwaGVyZS1zcWwtcGFyc2VyLWRpYWxlY3Qvc2hhcmRpbmdzcGhlcmUtc3FsLXBhcnNlci1wb3N0Z3Jlc3FsL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcWwvcGFyc2VyL3Bvc3RncmVzcWwvdmlzaXRvci9zdGF0ZW1lbnQvaW1wbC9Qb3N0Z3JlU1FMU3RhdGVtZW50U1FMVmlzaXRvci5qYXZh) | `85.05% <0.00%> (-1.00%)` | :arrow_down: |
| [...pache/shardingsphere/encrypt/rule/EncryptRule.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZmVhdHVyZXMvc2hhcmRpbmdzcGhlcmUtZW5jcnlwdC9zaGFyZGluZ3NwaGVyZS1lbmNyeXB0LWNvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2VuY3J5cHQvcnVsZS9FbmNyeXB0UnVsZS5qYXZh) | `78.78% <0.00%> (-0.16%)` | :arrow_down: |
| [...fra/binder/statement/dml/CallStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtaW5mcmEvc2hhcmRpbmdzcGhlcmUtaW5mcmEtYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L2RtbC9DYWxsU3RhdGVtZW50Q29udGV4dC5qYXZh) | `100.00% <0.00%> (ø)` | |
| ... and [32 more](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [46aeeff...318e372](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709703531
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -112,27 +113,13 @@
}
private Builder<?> interceptorClassStaticMethodPoint(final TypeDescription description, final List<ClassStaticMethodPoint> classStaticMethodAroundPoints, final Builder<?> builder) {
- List<ShardingSphereTransformationPoint<? extends ClassStaticMethodAroundInterceptor>> classStaticMethodAdvicePoints = description.getDeclaredMethods().stream()
+ List<ShardingSphereTransformationPoint<?>> classStaticMethodAdvicePoints = description.getDeclaredMethods().stream()
.filter(each -> each.isStatic() && !(each.isAbstract() || each.isSynthetic()))
- .map(md -> {
- List<ClassStaticMethodPoint> classStaticMethodPoints = classStaticMethodAroundPoints.stream().filter(point -> point.getMatcher().matches(md)).collect(Collectors.toList());
- if (classStaticMethodPoints.isEmpty()) {
- return null;
- }
- if (classStaticMethodPoints.size() == 1) {
- return new ShardingSphereTransformationPoint<>(md, new ClassStaticMethodAroundInterceptor(pluginLoader.getOrCreateInstance(classStaticMethodPoints.get(0).getAdvice())));
- } else {
- Collection<ClassStaticMethodAroundAdvice> classStaticMethodAroundAdvices = classStaticMethodPoints.stream()
- .map(ClassStaticMethodPoint::getAdvice)
- .map(advice -> (ClassStaticMethodAroundAdvice) pluginLoader.getOrCreateInstance(advice))
- .collect(Collectors.toList());
- return new ShardingSphereTransformationPoint<>(md, new ComposeClassStaticMethodAroundInterceptor(classStaticMethodAroundAdvices));
- }
- })
+ .map(md -> getStaticClassTransformationPoint(md, classStaticMethodAroundPoints))
Review comment:
It's method description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-commenter edited a comment on pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#issuecomment-920024056
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#12448](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (ad298ed) into [master](https://codecov.io/gh/apache/shardingsphere/commit/46aeeff1b2e837fe514df3097e4945057b911e7a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (46aeeff) will **increase** coverage by `0.15%`.
> The diff coverage is `0.61%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/12448/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #12448 +/- ##
============================================
+ Coverage 63.44% 63.60% +0.15%
- Complexity 1295 1304 +9
============================================
Files 2391 2399 +8
Lines 36345 36502 +157
Branches 6308 6337 +29
============================================
+ Hits 23059 23216 +157
+ Misses 11430 11412 -18
- Partials 1856 1874 +18
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...ingsphere/agent/bootstrap/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9hZ2VudC9ib290c3RyYXAvU2hhcmRpbmdTcGhlcmVBZ2VudC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...tebuddy/transformer/ShardingSphereTransformer.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvU2hhcmRpbmdTcGhlcmVUcmFuc2Zvcm1lci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...rmer/advice/ComposeInstanceMethodAroundAdvice.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9ieXRlYnVkZHkvdHJhbnNmb3JtZXIvYWR2aWNlL0NvbXBvc2VJbnN0YW5jZU1ldGhvZEFyb3VuZEFkdmljZS5qYXZh) | `0.00% <ø> (ø)` | |
| [...rdingsphere/agent/core/plugin/PluginApmLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luQXBtTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...nterceptor/ClassStaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvQ2xhc3NTdGF0aWNNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...n/interceptor/InstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...ompose/ComposeInstanceMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvY29tcG9zZS9Db21wb3NlSW5zdGFuY2VNZXRob2RBcm91bmRJbnRlcmNlcHRvci5qYXZh) | `0.00% <ø> (ø)` | |
| [...rdingsphere/agent/core/spi/AgentServiceLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9zcGkvQWdlbnRTZXJ2aWNlTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | |
| [...dingsphere/agent/core/spi/PluginServiceLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9zcGkvUGx1Z2luU2VydmljZUxvYWRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...trics/prometheus/collector/ProxyInfoCollector.java](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtcGx1Z2lucy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1wbHVnaW4tbWV0cmljcy9zaGFyZGluZ3NwaGVyZS1hZ2VudC1tZXRyaWNzLXByb21ldGhldXMvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2FnZW50L21ldHJpY3MvcHJvbWV0aGV1cy9jb2xsZWN0b3IvUHJveHlJbmZvQ29sbGVjdG9yLmphdmE=) | `86.66% <100.00%> (ø)` | |
| ... and [64 more](https://codecov.io/gh/apache/shardingsphere/pull/12448/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [46aeeff...ad298ed](https://codecov.io/gh/apache/shardingsphere/pull/12448?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709809966
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/bytebuddy/transformer/ShardingSphereTransformer.java
##########
@@ -145,28 +132,32 @@
return result;
}
+ private ShardingSphereTransformationPoint<?> getStaticClassTransformationPoint(final MethodDescription.InDefinedShape md, final List<ClassStaticMethodPoint> classStaticMethodAroundPoints) {
+ List<ClassStaticMethodPoint> classStaticMethodPoints = classStaticMethodAroundPoints.stream().filter(point -> point.getMatcher().matches(md)).collect(Collectors.toList());
+ if (classStaticMethodPoints.isEmpty()) {
+ return null;
+ }
+ if (classStaticMethodPoints.size() == 1) {
+ return new ShardingSphereTransformationPoint<>(md, new ClassStaticMethodAroundInterceptor(pluginLoader.getOrCreateInstance(classStaticMethodPoints.get(0).getAdvice())));
+ } else {
+ Collection<ClassStaticMethodAroundAdvice> classStaticMethodAroundAdvices = new LinkedList<>();
+ for (ClassStaticMethodPoint point : classStaticMethodPoints) {
+ if (null != point.getAdvice()) {
+ classStaticMethodAroundAdvices.add(pluginLoader.getOrCreateInstance(point.getAdvice()));
+ }
+ }
+ return new ShardingSphereTransformationPoint<>(md, new ComposeClassStaticMethodAroundInterceptor(classStaticMethodAroundAdvices));
Review comment:
thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709693342
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/Loader.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.plugin;
+
+import net.bytebuddy.description.type.TypeDescription;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+
+public interface Loader {
+ /**
+ * To detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true
+ */
+ boolean containsType(TypeDescription typeDescription);
+
+ /**
+ * Load plugin interceptor point by TypeDescription.
+ *
+ * @param typeDescription TypeDescription
+ * @return plugin interceptor point
+ */
+ PluginInterceptorPoint loadPluginInterceptorPoint(TypeDescription typeDescription);
+
+ /**
+ * To get or create instance of the advice class. Create new one and caching when it is not exist.
+ *
+ * @param classNameOfAdvice class name of advice
+ * @param <T> advice type
+ * @return instance of advice
+ */
+ <T> T getOrCreateInstance(String classNameOfAdvice);
Review comment:
it's better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] dachuan9e commented on a change in pull request #12448: Refactor plugin loader
Posted by GitBox <gi...@apache.org>.
dachuan9e commented on a change in pull request #12448:
URL: https://github.com/apache/shardingsphere/pull/12448#discussion_r709694284
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/Loader.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.plugin;
+
+import net.bytebuddy.description.type.TypeDescription;
+import org.apache.shardingsphere.agent.api.point.PluginInterceptorPoint;
+
+public interface Loader {
+ /**
+ * To detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true
+ */
+ boolean containsType(TypeDescription typeDescription);
+
+ /**
+ * Load plugin interceptor point by TypeDescription.
+ *
+ * @param typeDescription TypeDescription
Review comment:
ok, thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org