Search in sources :

Example 1 with DefaultApplicationContext

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);
    }
}
Also used : InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) ApplicationContext(com.navercorp.pinpoint.profiler.context.module.ApplicationContext) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) Module(com.google.inject.Module) Test(org.junit.Test)

Example 2 with DefaultApplicationContext

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;
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) ApplicationContext(com.navercorp.pinpoint.profiler.context.module.ApplicationContext) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) DefaultInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) Module(com.google.inject.Module)

Example 3 with DefaultApplicationContext

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);
}
Also used : InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) AgentInfoSender(com.navercorp.pinpoint.profiler.AgentInfoSender) ClassFileTransformerDispatcher(com.navercorp.pinpoint.profiler.ClassFileTransformerDispatcher) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) Injector(com.google.inject.Injector) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) Module(com.google.inject.Module) Test(org.junit.Test)

Example 4 with DefaultApplicationContext

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);
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) Instrumentation(java.lang.instrument.Instrumentation) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)

Example 5 with DefaultApplicationContext

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();
    }
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) GraphvizGrapher(com.google.inject.grapher.graphviz.GraphvizGrapher) Injector(com.google.inject.Injector)

Aggregations

DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)5 AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)4 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)4 Module (com.google.inject.Module)3 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)3 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)3 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)3 DefaultAnnotationKeyRegistryService (com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)3 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)3 Injector (com.google.inject.Injector)2 ApplicationContext (com.navercorp.pinpoint.profiler.context.module.ApplicationContext)2 Test (org.junit.Test)2 GraphvizGrapher (com.google.inject.grapher.graphviz.GraphvizGrapher)1 AgentInfoSender (com.navercorp.pinpoint.profiler.AgentInfoSender)1 ClassFileTransformerDispatcher (com.navercorp.pinpoint.profiler.ClassFileTransformerDispatcher)1 DefaultInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder)1 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)1 Instrumentation (java.lang.instrument.Instrumentation)1