-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.7.6 Refactor + Enhancement (#5772)
* Polish /#5745 : Increasing the stack size in the start.sh * Polish /#5297 : Only one of the multiple registration centers using nacos can register * Polish /#5442 : VERSION_KEY和GROUP_KEY为空时,注册到NACOS的服务名与alibaba实现不一致,导致无法消费 * Polish /#5442 : Merge upstream/master * Polish /apache/dubbo##5239 : Mock字段注入异常 * Polish /apache/dubbo##5239 : Mock字段注入异常 * Polish /#5770 : Removing the interinal JDK API from FileSystemDynamicConfiguration * Polish /#5771 : [Enhancement] Refactor the APT test-cases implementation of dubbo-metadata-processor in Java 9+ * Bugfix for the test-cases
- Loading branch information
1 parent
12d99d6
commit 56f1c18
Showing
7 changed files
with
150 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...va/org/apache/dubbo/metadata/annotation/processing/AnnotationProcessingTestProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.dubbo.metadata.annotation.processing; | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.InvocationInterceptor; | ||
import org.junit.jupiter.api.extension.ReflectiveInvocationContext; | ||
|
||
import javax.annotation.processing.AbstractProcessor; | ||
import javax.annotation.processing.RoundEnvironment; | ||
import javax.annotation.processing.SupportedAnnotationTypes; | ||
import javax.lang.model.SourceVersion; | ||
import javax.lang.model.element.TypeElement; | ||
import java.lang.reflect.Method; | ||
import java.util.Set; | ||
|
||
import static javax.lang.model.SourceVersion.latestSupported; | ||
|
||
@SupportedAnnotationTypes("*") | ||
public class AnnotationProcessingTestProcessor extends AbstractProcessor { | ||
|
||
private final AbstractAnnotationProcessingTest abstractAnnotationProcessingTest; | ||
private final InvocationInterceptor.Invocation<Void> invocation; | ||
|
||
private final ReflectiveInvocationContext<Method> invocationContext; | ||
|
||
private final ExtensionContext extensionContext; | ||
|
||
public AnnotationProcessingTestProcessor(AbstractAnnotationProcessingTest abstractAnnotationProcessingTest, InvocationInterceptor.Invocation<Void> invocation, | ||
ReflectiveInvocationContext<Method> invocationContext, | ||
ExtensionContext extensionContext) { | ||
this.abstractAnnotationProcessingTest = abstractAnnotationProcessingTest; | ||
this.invocation = invocation; | ||
this.invocationContext = invocationContext; | ||
this.extensionContext = extensionContext; | ||
} | ||
|
||
@Override | ||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { | ||
if (!roundEnv.processingOver()) { | ||
prepare(); | ||
abstractAnnotationProcessingTest.beforeEach(); | ||
try { | ||
invocation.proceed(); | ||
} catch (Throwable throwable) { | ||
throw new RuntimeException(throwable); | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private void prepare() { | ||
abstractAnnotationProcessingTest.processingEnv = super.processingEnv; | ||
abstractAnnotationProcessingTest.elements = super.processingEnv.getElementUtils(); | ||
abstractAnnotationProcessingTest.types = super.processingEnv.getTypeUtils(); | ||
} | ||
|
||
@Override | ||
public SourceVersion getSupportedSourceVersion() { | ||
return latestSupported(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...t/java/org/apache/dubbo/metadata/annotation/processing/CompilerInvocationInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.dubbo.metadata.annotation.processing; | ||
|
||
import org.apache.dubbo.metadata.tools.Compiler; | ||
|
||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.InvocationInterceptor; | ||
import org.junit.jupiter.api.extension.ReflectiveInvocationContext; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import static org.apache.dubbo.metadata.annotation.processing.AbstractAnnotationProcessingTest.testInstanceHolder; | ||
|
||
public class CompilerInvocationInterceptor implements InvocationInterceptor { | ||
|
||
@Override | ||
public void interceptTestMethod(Invocation<Void> invocation, | ||
ReflectiveInvocationContext<Method> invocationContext, | ||
ExtensionContext extensionContext) throws Throwable { | ||
Set<Class<?>> classesToBeCompiled = new LinkedHashSet<>(); | ||
AbstractAnnotationProcessingTest abstractAnnotationProcessingTest = testInstanceHolder.get(); | ||
classesToBeCompiled.add(getClass()); | ||
abstractAnnotationProcessingTest.addCompiledClasses(classesToBeCompiled); | ||
Compiler compiler = new Compiler(); | ||
compiler.processors(new AnnotationProcessingTestProcessor(abstractAnnotationProcessingTest, invocation, invocationContext, extensionContext)); | ||
compiler.compile(classesToBeCompiled.toArray(new Class[0])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters