use of com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext in project pinpoint by naver.
the class MockApplicationContextModuleTest method test.
@Test
public void test() {
ProfilerConfig profilerConfig = new DefaultProfilerConfig();
AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
final PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
PluginTestAgent pluginTestAgent = new PluginTestAgent(agentOption) {
@Override
protected ApplicationContext newApplicationContext(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
ApplicationContext applicationContext = new DefaultApplicationContext(agentOption, interceptorRegistryBinder) {
@Override
protected Module newApplicationContextModule(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
Module applicationContextModule = super.newApplicationContextModule(agentOption, interceptorRegistryBinder);
// PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
return Modules.override(applicationContextModule).with(pluginApplicationContextModule);
}
};
return applicationContext;
}
};
try {
pluginTestAgent.start();
} finally {
pluginTestAgent.stop(true);
}
}
use of com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext in project pinpoint by naver.
the class PluginTestAgent method newApplicationContext.
@Override
protected ApplicationContext newApplicationContext(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
this.pluginApplicationContextModule = new PluginApplicationContextModule();
ApplicationContext applicationContext = new DefaultApplicationContext(agentOption, interceptorRegistryBinder) {
@Override
protected Module newApplicationContextModule(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
Module applicationContextModule = super.newApplicationContextModule(agentOption, interceptorRegistryBinder);
return Modules.override(applicationContextModule).with(pluginApplicationContextModule);
}
};
return applicationContext;
}
use of com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext in project pinpoint by naver.
the class MockApplicationContextModuleTest method testMockApplicationContext.
@Test
public void testMockApplicationContext() {
ProfilerConfig profilerConfig = new DefaultProfilerConfig();
InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
DefaultApplicationContext applicationContext = new DefaultApplicationContext(agentOption, binder) {
@Override
protected Module newApplicationContextModule(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
Module module = super.newApplicationContextModule(agentOption, interceptorRegistryBinder);
PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
return Modules.override(module).with(pluginApplicationContextModule);
}
};
Injector injector = applicationContext.getInjector();
// singleton check
AgentInfoSender instance1 = injector.getInstance(AgentInfoSender.class);
AgentInfoSender instance2 = injector.getInstance(AgentInfoSender.class);
Assert.assertSame(instance1, instance2);
ClassFileTransformerDispatcher instance4 = injector.getInstance(ClassFileTransformerDispatcher.class);
}
use of com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext in project pinpoint by naver.
the class DependencyGraph method newApplicationContext.
private DefaultApplicationContext newApplicationContext() {
ProfilerConfig profilerConfig = new DefaultProfilerConfig();
InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
Instrumentation instrumentation = mock(Instrumentation.class);
AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
return new DefaultApplicationContext(agentOption, binder);
}
use of com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext in project pinpoint by naver.
the class DependencyGraph method dumpDependencyGraph.
public void dumpDependencyGraph() throws IOException {
DefaultApplicationContext applicationContext = newApplicationContext();
try {
Injector injector = applicationContext.getInjector();
String path = currentWorkingDir();
String fileName = path + "../DependencyGraph.dot";
logger.debug("filename:{}", fileName);
Grapher grapher = new Grapher();
grapher.graph(fileName, injector);
} finally {
applicationContext.close();
}
}
Aggregations