-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.sermant.flowcontrol; | ||
|
||
import io.sermant.core.plugin.agent.declarer.AbstractPluginDeclarer; | ||
import io.sermant.core.plugin.agent.declarer.InterceptDeclarer; | ||
import io.sermant.core.plugin.agent.matcher.ClassMatcher; | ||
import io.sermant.core.plugin.agent.matcher.MethodMatcher; | ||
|
||
public class FilterExtendDeclare extends AbstractPluginDeclarer { | ||
private static final String ENHANCE_CLASS = "org.apache.dubbo.rpc.BaseFilter"; | ||
|
||
private static final String INTERCEPT_CLASS = FilterExtendTestInterceptor.class.getCanonicalName(); | ||
|
||
@Override | ||
public ClassMatcher getClassMatcher() { | ||
return ClassMatcher.isExtendedFrom(ENHANCE_CLASS); | ||
} | ||
|
||
@Override | ||
public InterceptDeclarer[] getInterceptDeclarers(ClassLoader classLoader) { | ||
return new InterceptDeclarer[]{ | ||
InterceptDeclarer.build(MethodMatcher.nameEquals("invoke"), INTERCEPT_CLASS) | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.sermant.flowcontrol; | ||
Check failure on line 1 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
|
||
import java.util.logging.Logger; | ||
|
||
import org.apache.dubbo.common.Version; | ||
Check failure on line 5 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
|
||
import io.sermant.core.common.LoggerFactory; | ||
Check failure on line 7 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
import io.sermant.core.plugin.agent.entity.ExecuteContext; | ||
import io.sermant.core.plugin.agent.interceptor.Interceptor; | ||
|
||
public class FilterExtendTestInterceptor implements Interceptor { | ||
Check failure on line 11 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(); | ||
Check failure on line 12 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
|
||
@Override | ||
Check failure on line 14 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
public ExecuteContext before(ExecuteContext context) throws Exception { | ||
Object invoke = context.getArguments()[0]; | ||
Check failure on line 16 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
String currentVersion = invoke.getClass().getPackage().getImplementationVersion(); | ||
Check failure on line 17 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java
|
||
if (currentVersion == null) { | ||
currentVersion = Version.getVersion(); | ||
} | ||
LOGGER.info("===========================>find version:" + currentVersion); | ||
String className = context.getObject().getClass().getCanonicalName(); | ||
LOGGER.info("===========================>current filter name:" + className); | ||
return context; | ||
} | ||
|
||
@Override | ||
public ExecuteContext after(ExecuteContext context) throws Exception { | ||
return context; | ||
} | ||
|
||
@Override | ||
public ExecuteContext onThrow(ExecuteContext context) throws Exception { | ||
return context; | ||
} | ||
} |