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 2020/11/23 12:47:03 UTC
[GitHub] [shardingsphere] dmsolr opened a new pull request #8307: feature: introduce shardingsphere agent
dmsolr opened a new pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307
Fixes #8206.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on a change in pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
yu199195 commented on a change in pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#discussion_r528681211
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundAdvice.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the static methods of target class.
+ */
+public interface StaticMethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ * @param klass the target class
Review comment:
param may be a space
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-io commented on pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#issuecomment-732185069
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=h1) Report
> Merging [#8307](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=desc) (1700cbd) into [master](https://codecov.io/gh/apache/shardingsphere/commit/c038bddaa6806812c05824ff596f4cc4d72fb6cf?el=desc) (c038bdd) will **decrease** coverage by `0.68%`.
> The diff coverage is `0.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/8307/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8307 +/- ##
============================================
- Coverage 74.73% 74.04% -0.69%
Complexity 599 599
============================================
Files 1483 1494 +11
Lines 23424 23642 +218
Branches 4170 4179 +9
============================================
Hits 17505 17505
- Misses 4770 4988 +218
Partials 1149 1149
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...ingsphere/agent/bootstrap/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9hZ2VudC9ib290c3RyYXAvU2hhcmRpbmdTcGhlcmVBZ2VudC5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...che/shardingsphere/agent/core/LoggingListener.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9Mb2dnaW5nTGlzdGVuZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ngsphere/agent/core/ShardingSphereTransformer.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9TaGFyZGluZ1NwaGVyZVRyYW5zZm9ybWVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ngsphere/agent/core/plugin/PluginAdviceDefine.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luQWR2aWNlRGVmaW5lLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...shardingsphere/agent/core/plugin/PluginLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...re/plugin/advice/ConstructorMethodInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL0NvbnN0cnVjdG9yTWV0aG9kSW50ZXJjZXB0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...nt/core/plugin/advice/MethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL01ldGhvZEFyb3VuZEludGVyY2VwdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ent/core/plugin/advice/MethodInvocationResult.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL01ldGhvZEludm9jYXRpb25SZXN1bHQuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/plugin/advice/StaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL1N0YXRpY01ldGhvZEFyb3VuZEludGVyY2VwdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...gent/core/plugin/point/ClassStaticMethodPoint.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vcG9pbnQvQ2xhc3NTdGF0aWNNZXRob2RQb2ludC5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| ... and [13 more](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=footer). Last update [c038bdd...724a9e8](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on a change in pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
yu199195 commented on a change in pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#discussion_r528699659
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
Review comment:
Configurer ---> builder
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
Review comment:
remove a
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
Review comment:
remove a
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
Review comment:
Plugin --> plugin
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder overrideArgs(final boolean overrideArgs) {
+ this.overrideArgs = overrideArgs;
+ return this;
+ }
+
+ /**
+ * to build instance methods configuration.
+ *
+ * @return Plugin advice builder.
+ */
+ public Builder build() {
+ builder.instanceMethodPoints.add(new InstanceMethodPoint(matcher, classNameOfAdvice, overrideArgs));
+ return builder;
+ }
+ }
+
+ /**
+ * Static method intercepting point configuration builder.
+ */
+ public static final class StaticMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private StaticMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = ElementMatchers.isStatic().and(matcher);
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Static method point configurer.
+ */
+ public StaticMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
Review comment:
to configure --> Configure
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder overrideArgs(final boolean overrideArgs) {
+ this.overrideArgs = overrideArgs;
+ return this;
+ }
+
+ /**
+ * to build instance methods configuration.
+ *
+ * @return Plugin advice builder.
+ */
+ public Builder build() {
+ builder.instanceMethodPoints.add(new InstanceMethodPoint(matcher, classNameOfAdvice, overrideArgs));
+ return builder;
+ }
+ }
+
+ /**
+ * Static method intercepting point configuration builder.
+ */
+ public static final class StaticMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private StaticMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = ElementMatchers.isStatic().and(matcher);
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Static method point configurer.
+ */
+ public StaticMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Static method point configurer.
Review comment:
Static method point configurer. -- > static method point builder.
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
Review comment:
Configuration --> configuration
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
Review comment:
remove a
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
Review comment:
remove a
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
Review comment:
Configuration --> configuration
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
Review comment:
build --> Build
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
Review comment:
Configuration --> configuration
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
Review comment:
to configure implementation for intercepting point --> Configure implementation for interceptor point
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
Review comment:
Instance -- > instance
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
Review comment:
to configure whether or not override the origin method arguments. -- > Configure whether or not override the origin method arguments.
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder overrideArgs(final boolean overrideArgs) {
+ this.overrideArgs = overrideArgs;
+ return this;
+ }
+
+ /**
+ * to build instance methods configuration.
+ *
+ * @return Plugin advice builder.
Review comment:
Plugin-- > plugin
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder overrideArgs(final boolean overrideArgs) {
+ this.overrideArgs = overrideArgs;
+ return this;
+ }
+
+ /**
+ * to build instance methods configuration.
Review comment:
to build instance methods configuration. -- > Build instance methods configuration
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 merged pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
yu199195 merged pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on a change in pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
yu199195 commented on a change in pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#discussion_r528681470
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.advice;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.implementation.bind.annotation.AllArguments;
+import net.bytebuddy.implementation.bind.annotation.Origin;
+import net.bytebuddy.implementation.bind.annotation.RuntimeType;
+import net.bytebuddy.implementation.bind.annotation.This;
+import net.bytebuddy.implementation.bind.annotation.SuperCall;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+
+/**
+ * A proxy class for ByteBuddy to intercept methods of target and weave pre- and post-method around the target method.
+ */
+@Slf4j
+public class MethodAroundInterceptor {
+ private final MethodAroundAdvice advice;
+
+ public MethodAroundInterceptor(final MethodAroundAdvice advice) {
+ this.advice = advice;
+ }
+
+ /**
+ * Only intercept instance method.
+ * @param target the target object
+ * @param method the intercepted method
+ * @param args the all arguments of method
Review comment:
keep a space
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/LoggingListener.java
##########
@@ -0,0 +1,58 @@
+/*
+ * 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;
+
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.agent.builder.AgentBuilder;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.dynamic.DynamicType;
+import net.bytebuddy.utility.JavaModule;
+
+/**
+ * A listener to log what is informed about events that occur during an instrumentation process.
Review comment:
remove A
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundInterceptor.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.advice;
+
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.implementation.bind.annotation.AllArguments;
+import net.bytebuddy.implementation.bind.annotation.Origin;
+import net.bytebuddy.implementation.bind.annotation.RuntimeType;
+import net.bytebuddy.implementation.bind.annotation.This;
+import net.bytebuddy.implementation.bind.annotation.SuperCall;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+
+/**
+ * A proxy class for ByteBuddy to intercept methods of target and weave pre- and post-method around the target method.
Review comment:
remove A
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundAdvice.java
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the target method.
+ */
+public interface MethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void beforeMethod(TargetObject target, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Intercept the target method and weave the method after origin method. It will invoke after the origin calling.
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void afterMethod(TargetObject target, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Weaving the method after origin method throwing.
+ * @param target the target object
+ * @param method the target method
Review comment:
keep a space
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/ShardingSphereTransformer.java
##########
@@ -0,0 +1,103 @@
+/*
+ * 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;
+
+import lombok.extern.slf4j.Slf4j;
+import net.bytebuddy.agent.builder.AgentBuilder;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.dynamic.DynamicType;
+import net.bytebuddy.implementation.FieldAccessor;
+import net.bytebuddy.implementation.MethodDelegation;
+import net.bytebuddy.implementation.SuperMethodCall;
+import net.bytebuddy.jar.asm.Opcodes;
+import net.bytebuddy.utility.JavaModule;
+import org.apache.shardingsphere.agent.core.plugin.PluginAdviceDefine;
+import org.apache.shardingsphere.agent.core.plugin.PluginLoader;
+import org.apache.shardingsphere.agent.core.plugin.advice.ConstructorMethodInterceptor;
+import org.apache.shardingsphere.agent.core.plugin.advice.MethodAroundInterceptor;
+import org.apache.shardingsphere.agent.core.plugin.advice.StaticMethodAroundInterceptor;
+import org.apache.shardingsphere.agent.core.plugin.advice.TargetObject;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.Map;
+
+@Slf4j
Review comment:
add doc
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLoader.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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 lombok.SneakyThrows;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Plugins loader.
+ * TODO not-implemented yet
+ */
+public class PluginLoader extends ClassLoader {
+
+ private final ConcurrentHashMap<String, Object> objectPool = new ConcurrentHashMap<>();
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ /**
+ * to find all intercepting target classes then to build TypeMatcher.
+ *
+ * @return TypeMatcher
+ */
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ return null;
+ }
+
+ /**
+ * to detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true.
+ */
+ public boolean containsType(final TypeDescription typeDescription) {
+ return false;
+ }
+
+ /**
+ * Load the definition configuration by TypeDescription.
+ *
+ * @param typeDescription TypeDescription
+ * @return the plugin definition configurations.
+ */
+ public PluginAdviceDefine loadPluginAdviceDefine(final TypeDescription typeDescription) {
+ return null;
+ }
+
+ /**
+ * get or create instance of the advice class. Create new one and caching when it is not exist.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @param <T> the advice type.
Review comment:
keep a space
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/ConstructorAdvice.java
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.advice;
+
+/**
+ * Weaving the advice around the constructor of target class.
+ */
+public interface ConstructorAdvice {
+
+ /**
+ * Intercept the target's constructor. This method is weaved after the constructor execution.
+ * @param target Intercepted target object
Review comment:
keep a space
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] codecov-io edited a comment on pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
codecov-io edited a comment on pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#issuecomment-732185069
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=h1) Report
> Merging [#8307](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=desc) (724a9e8) into [master](https://codecov.io/gh/apache/shardingsphere/commit/c038bddaa6806812c05824ff596f4cc4d72fb6cf?el=desc) (c038bdd) will **decrease** coverage by `0.71%`.
> The diff coverage is `0.00%`.
[![Impacted file tree graph](https://codecov.io/gh/apache/shardingsphere/pull/8307/graphs/tree.svg?width=650&height=150&src=pr&token=ZvlXpWa7so)](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=tree)
```diff
@@ Coverage Diff @@
## master #8307 +/- ##
============================================
- Coverage 74.73% 74.02% -0.72%
Complexity 599 599
============================================
Files 1483 1494 +11
Lines 23424 23642 +218
Branches 4170 4179 +9
============================================
- Hits 17505 17500 -5
- Misses 4770 4991 +221
- Partials 1149 1151 +2
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...ingsphere/agent/bootstrap/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9hZ2VudC9ib290c3RyYXAvU2hhcmRpbmdTcGhlcmVBZ2VudC5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (ø)` | |
| [...che/shardingsphere/agent/core/LoggingListener.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9Mb2dnaW5nTGlzdGVuZXIuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ngsphere/agent/core/ShardingSphereTransformer.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9TaGFyZGluZ1NwaGVyZVRyYW5zZm9ybWVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ngsphere/agent/core/plugin/PluginAdviceDefine.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luQWR2aWNlRGVmaW5lLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...shardingsphere/agent/core/plugin/PluginLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vUGx1Z2luTG9hZGVyLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...re/plugin/advice/ConstructorMethodInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL0NvbnN0cnVjdG9yTWV0aG9kSW50ZXJjZXB0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...nt/core/plugin/advice/MethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL01ldGhvZEFyb3VuZEludGVyY2VwdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...ent/core/plugin/advice/MethodInvocationResult.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL01ldGhvZEludm9jYXRpb25SZXN1bHQuamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...e/plugin/advice/StaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vYWR2aWNlL1N0YXRpY01ldGhvZEFyb3VuZEludGVyY2VwdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| [...gent/core/plugin/point/ClassStaticMethodPoint.java](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree#diff-c2hhcmRpbmdzcGhlcmUtYWdlbnQvc2hhcmRpbmdzcGhlcmUtYWdlbnQtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vcG9pbnQvQ2xhc3NTdGF0aWNNZXRob2RQb2ludC5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
| ... and [16 more](https://codecov.io/gh/apache/shardingsphere/pull/8307/diff?src=pr&el=tree-more) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=footer). Last update [c038bdd...724a9e8](https://codecov.io/gh/apache/shardingsphere/pull/8307?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] yu199195 commented on a change in pull request #8307: feature: introduce shardingsphere agent
Posted by GitBox <gi...@apache.org>.
yu199195 commented on a change in pull request #8307:
URL: https://github.com/apache/shardingsphere/pull/8307#discussion_r528695254
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginLoader.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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 lombok.SneakyThrows;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+
+/**
+ * Plugins loader.
+ * TODO not-implemented yet
+ */
+public class PluginLoader extends ClassLoader {
+
+ private final ConcurrentHashMap<String, Object> objectPool = new ConcurrentHashMap<>();
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ /**
+ * To find all intercepting target classes then to build TypeMatcher.
+ *
+ * @return TypeMatcher
+ */
+ public ElementMatcher<? super TypeDescription> typeMatcher() {
+ return null;
+ }
+
+ /**
+ * To detect the type whether or not exists.
+ *
+ * @param typeDescription TypeDescription
+ * @return contains when it is true.
+ */
+ public boolean containsType(final TypeDescription typeDescription) {
+ return false;
+ }
+
+ /**
+ * Load the definition configuration by TypeDescription.
Review comment:
type description.
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/PluginAdviceDefine.java
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.Lists;
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+import org.apache.shardingsphere.agent.core.plugin.point.ClassStaticMethodPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.ConstructorPoint;
+import org.apache.shardingsphere.agent.core.plugin.point.InstanceMethodPoint;
+
+import java.util.List;
+
+/**
+ * The advice of plugin configurer.
+ *
+ * <code>
+ * PluginAdviceDefine.intercept("Target.class")
+ * .onConstructor(ElementMatchers.any()).implement("Advice.class").build()
+ * .method(ElementMatchers.named("greet").implement("Advice.class").build()
+ * .staticMethod(ElementMatchers.named("of").implement("OfAdvice.class").build()
+ * .install();
+ * </code>
+ */
+public final class PluginAdviceDefine {
+
+ private final List<ConstructorPoint> constructorPoints;
+
+ private final List<InstanceMethodPoint> instanceMethodPoints;
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints;
+
+ private PluginAdviceDefine(final List<ConstructorPoint> constructorPoints,
+ final List<InstanceMethodPoint> instanceMethodPoints,
+ final List<ClassStaticMethodPoint> classStaticMethodPoints) {
+ this.constructorPoints = constructorPoints;
+ this.instanceMethodPoints = instanceMethodPoints;
+ this.classStaticMethodPoints = classStaticMethodPoints;
+ }
+
+ /**
+ * Intercept target class.
+ *
+ * @param classNameOfTarget a class name of wanted advice target.
+ * @return Configurer.
+ */
+ public static Builder intercept(final String classNameOfTarget) {
+ return new Builder(classNameOfTarget);
+ }
+
+ /**
+ * To get static method point configurations.
+ *
+ * @return a series of static method point configuration.
+ */
+ public List<ClassStaticMethodPoint> getClassStaticMethodPoints() {
+ return classStaticMethodPoints;
+ }
+
+ /**
+ * To get constructor point configurations.
+ *
+ * @return a series of constructor point configuration.
+ */
+ public List<ConstructorPoint> getConstructorPoints() {
+ return constructorPoints;
+ }
+
+ /**
+ * To get instance point configurations.
+ *
+ * @return a series of instance method point configuration.
+ */
+ public List<InstanceMethodPoint> getInstanceMethodPoints() {
+ return instanceMethodPoints;
+ }
+
+ /**
+ * Plugin advice configuration builder.
+ */
+ public static final class Builder {
+ private final List<ConstructorPoint> constructorPoints = Lists.newArrayList();
+
+ private final List<InstanceMethodPoint> instanceMethodPoints = Lists.newArrayList();
+
+ private final List<ClassStaticMethodPoint> classStaticMethodPoints = Lists.newArrayList();
+
+ private final String classNameOfTarget;
+
+ private Builder(final String classNameOfTarget) {
+ this.classNameOfTarget = classNameOfTarget;
+ }
+
+ /**
+ * Intercept the new target.
+ *
+ * @param classNameOfTarget the class name of target.
+ * @return Configuration builder.
+ */
+ public Builder intercept(final String classNameOfTarget) {
+ // TODO not-implemented yet
+ return this;
+ }
+
+ /**
+ * to configure the intercepting point on constructor.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public ConstructorPointBuilder onConstructor(final ElementMatcher<? super MethodDescription> matcher) {
+ return new ConstructorPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public InstanceMethodPointBuilder method(final ElementMatcher<? super MethodDescription> matcher) {
+ return new InstanceMethodPointBuilder(this, matcher);
+ }
+
+ /**
+ * to configure the intercepting point around instance method.
+ *
+ * @param matcher constraints
+ * @return Configuration builder
+ */
+ public StaticMethodPointBuilder staticMethod(final ElementMatcher<? super MethodDescription> matcher) {
+ return new StaticMethodPointBuilder(this, matcher);
+ }
+
+
+ /**
+ * build configuration.
+ *
+ * @return Plugin advice definition.
+ */
+ public PluginAdviceDefine install() {
+ return new PluginAdviceDefine(constructorPoints, instanceMethodPoints, classStaticMethodPoints);
+ }
+
+ /**
+ * Instance method intercepting point configuration builder.
+ */
+ public static final class InstanceMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private InstanceMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = matcher;
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder implement(final String classNameOfAdvice) {
+ this.classNameOfAdvice = classNameOfAdvice;
+ return this;
+ }
+
+ /**
+ * to configure whether or not override the origin method arguments.
+ *
+ * @param overrideArgs whether to override origin method arguments.
+ * @return Instance method point configurer.
+ */
+ public InstanceMethodPointBuilder overrideArgs(final boolean overrideArgs) {
+ this.overrideArgs = overrideArgs;
+ return this;
+ }
+
+ /**
+ * to build instance methods configuration.
+ *
+ * @return Plugin advice builder.
+ */
+ public Builder build() {
+ builder.instanceMethodPoints.add(new InstanceMethodPoint(matcher, classNameOfAdvice, overrideArgs));
+ return builder;
+ }
+ }
+
+ /**
+ * Static method intercepting point configuration builder.
+ */
+ public static final class StaticMethodPointBuilder {
+ private final Builder builder;
+
+ private String classNameOfAdvice;
+
+ private boolean overrideArgs;
+
+ private ElementMatcher<? super MethodDescription> matcher;
+
+ private StaticMethodPointBuilder(final Builder builder, final ElementMatcher<? super MethodDescription> matcher) {
+ this.builder = builder;
+ this.matcher = ElementMatchers.isStatic().and(matcher);
+ }
+
+ /**
+ * to configure implementation for intercepting point.
+ *
+ * @param classNameOfAdvice the class name of advice
+ * @return Static method point configurer.
Review comment:
Static method point builder
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundAdvice.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the static methods of target class.
+ */
+public interface StaticMethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ *
+ * @param klass the target class
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void beforeMethod(Class<?> klass, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Intercept the target method and weave the method after origin method. It will invoke after the origin calling.
+ *
+ * @param klass the target class
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void afterMethod(Class<?> klass, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Weaving the method after origin method throwing.
+ *
+ * @param klass the target class
+ * @param method the target method
+ * @param args the all method arguments
+ * @param throwable an exception from target method.
Review comment:
remove an
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/OverrideArgsInvoker.java
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.advice;
+
+/**
+ * Super(origin) method invoker for ByteBuddy only.
+ */
+public interface OverrideArgsInvoker {
+
+ /**
+ * invocation origin method.
Review comment:
invocation may be Invocation
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/StaticMethodAroundAdvice.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the static methods of target class.
+ */
+public interface StaticMethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ *
+ * @param klass the target class
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void beforeMethod(Class<?> klass, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Intercept the target method and weave the method after origin method. It will invoke after the origin calling.
+ *
+ * @param klass the target class
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
Review comment:
remove A
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundAdvice.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the target method.
+ */
+public interface MethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ *
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void beforeMethod(TargetObject target, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Intercept the target method and weave the method after origin method. It will invoke after the origin calling.
+ *
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void afterMethod(TargetObject target, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Weaving the method after origin method throwing.
+ *
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param throwable an exception from target method.
Review comment:
remove an
##########
File path: shardingsphere-agent/shardingsphere-agent-core/src/main/java/org/apache/shardingsphere/agent/core/plugin/advice/MethodAroundAdvice.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.advice;
+
+import java.lang.reflect.Method;
+
+/**
+ * Weaving the advice around the target method.
+ */
+public interface MethodAroundAdvice {
+
+ /**
+ * Intercept the target method and weave the method before origin method. It will invoke before the origin calling.
+ *
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
+ */
+ void beforeMethod(TargetObject target, Method method, Object[] args, MethodInvocationResult result);
+
+ /**
+ * Intercept the target method and weave the method after origin method. It will invoke after the origin calling.
+ *
+ * @param target the target object
+ * @param method the target method
+ * @param args the all method arguments
+ * @param result A wrapped class of result to detect whether or not to execute the origin method.
Review comment:
remove A worlds
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org