use of com.shulie.instrument.simulator.api.listener.ext.IBehaviorMatchBuilder in project LinkAgent by shulieTech.
the class MockPlugin method enhanceClassMethod.
public Map<String, EventWatcher> enhanceClassMethod(Map<String, Set<MockConfig>> configs) {
if (configs == null || configs.isEmpty()) {
return Collections.EMPTY_MAP;
}
Map<String, EventWatcher> watchers = new HashMap<String, EventWatcher>();
for (Map.Entry<String, Set<MockConfig>> entry : configs.entrySet()) {
if (LOGGER.isInfoEnabled()) {
LOGGER.info("pre enhance class:{} ,configs:{}", entry.getKey(), entry.getValue());
}
for (MockConfig mockConfig : entry.getValue()) {
IClassMatchBuilder buildingForClass = new EventWatchBuilder(moduleEventWatcher).onClass(entry.getKey());
IBehaviorMatchBuilder buildingForBehavior = buildingForClass.onAnyBehavior(mockConfig.getMethodName());
if (mockConfig.getMethodArgClasses() != null && !mockConfig.getMethodArgClasses().isEmpty()) {
buildingForBehavior.withParameterTypes(mockConfig.getMethodArgClasses().toArray(new String[mockConfig.getMethodArgClasses().size()]));
}
buildingForBehavior.onListener(Listeners.of(MockAdviceListener.class, new Object[] { mockConfig.getCodeScript() }));
watchers.put(mockConfig.getKey(), buildingForClass.onWatch());
}
}
return watchers;
}
Aggregations