Search in sources :

Example 1 with ModuleLifecycleAdapter

use of com.shulie.instrument.simulator.api.ModuleLifecycleAdapter in project LinkAgent by shulieTech.

the class DefaultEnhanceTemplate method enhance.

@Override
public InstrumentClass enhance(ExtensionModule module, String className, EnhanceCallback callback) {
    IClassMatchBuilder iClassMatchBuilder = new EventWatchBuilder(moduleEventWatcher).onClass(className);
    final DefaultInstrumentClass instrumentClass = new DefaultInstrumentClass(iClassMatchBuilder);
    callback.doEnhance(instrumentClass);
    if (module instanceof ModuleLifecycleAdapter) {
        ((ModuleLifecycleAdapter) module).addReleaseResource(new InstrumentClassResource(instrumentClass));
    }
    instrumentClass.execute();
    return instrumentClass;
}
Also used : InstrumentClassResource(com.shulie.instrument.simulator.api.resource.InstrumentClassResource) IClassMatchBuilder(com.shulie.instrument.simulator.api.listener.ext.IClassMatchBuilder) ModuleLifecycleAdapter(com.shulie.instrument.simulator.api.ModuleLifecycleAdapter) EventWatchBuilder(com.shulie.instrument.simulator.api.listener.ext.EventWatchBuilder)

Example 2 with ModuleLifecycleAdapter

use of com.shulie.instrument.simulator.api.ModuleLifecycleAdapter in project LinkAgent by shulieTech.

the class DefaultEnhanceTemplate method enhanceWithInterface.

@Override
public InstrumentClass enhanceWithInterface(ExtensionModule module, String interfaceClassName, EnhanceCallback callback) {
    IClassMatchBuilder iClassMatchBuilder = new EventWatchBuilder(moduleEventWatcher).onAnyClass().hasInterfaceTypes(interfaceClassName);
    final DefaultInstrumentClass instrumentClass = new DefaultInstrumentClass(iClassMatchBuilder);
    callback.doEnhance(instrumentClass);
    if (module instanceof ModuleLifecycleAdapter) {
        ((ModuleLifecycleAdapter) module).addReleaseResource(new InstrumentClassResource(instrumentClass));
    }
    instrumentClass.execute();
    return instrumentClass;
}
Also used : InstrumentClassResource(com.shulie.instrument.simulator.api.resource.InstrumentClassResource) IClassMatchBuilder(com.shulie.instrument.simulator.api.listener.ext.IClassMatchBuilder) ModuleLifecycleAdapter(com.shulie.instrument.simulator.api.ModuleLifecycleAdapter) EventWatchBuilder(com.shulie.instrument.simulator.api.listener.ext.EventWatchBuilder)

Example 3 with ModuleLifecycleAdapter

use of com.shulie.instrument.simulator.api.ModuleLifecycleAdapter in project LinkAgent by shulieTech.

the class DefaultEnhanceTemplate method enhanceWithSuperClass.

@Override
public InstrumentClass enhanceWithSuperClass(ExtensionModule module, EnhanceCallback callback, String... superClassNames) {
    IClassMatchBuilder iClassMatchBuilder = new EventWatchBuilder(moduleEventWatcher).onAnyClass().withSuperClass(superClassNames);
    final DefaultInstrumentClass instrumentClass = new DefaultInstrumentClass(iClassMatchBuilder);
    callback.doEnhance(instrumentClass);
    if (module instanceof ModuleLifecycleAdapter) {
        ((ModuleLifecycleAdapter) module).addReleaseResource(new InstrumentClassResource(instrumentClass));
    }
    instrumentClass.execute();
    return instrumentClass;
}
Also used : InstrumentClassResource(com.shulie.instrument.simulator.api.resource.InstrumentClassResource) IClassMatchBuilder(com.shulie.instrument.simulator.api.listener.ext.IClassMatchBuilder) ModuleLifecycleAdapter(com.shulie.instrument.simulator.api.ModuleLifecycleAdapter) EventWatchBuilder(com.shulie.instrument.simulator.api.listener.ext.EventWatchBuilder)

Aggregations

ModuleLifecycleAdapter (com.shulie.instrument.simulator.api.ModuleLifecycleAdapter)3 EventWatchBuilder (com.shulie.instrument.simulator.api.listener.ext.EventWatchBuilder)3 IClassMatchBuilder (com.shulie.instrument.simulator.api.listener.ext.IClassMatchBuilder)3 InstrumentClassResource (com.shulie.instrument.simulator.api.resource.InstrumentClassResource)3