Search in sources :

Example 1 with ModuleFactory

use of com.navercorp.pinpoint.profiler.context.module.ModuleFactory in project pinpoint by naver.

the class MockTraceContextFactory method newMockApplicationContext.

public static DefaultApplicationContext newMockApplicationContext(ProfilerConfig profilerConfig) {
    Module loggingModule = new LoggingModule();
    InterceptorRegistryBinder interceptorRegistryBinder = new EmptyInterceptorRegistryBinder();
    Module interceptorRegistryModule = InterceptorRegistryModule.wrap(interceptorRegistryBinder);
    ModuleFactory moduleFactory = new OverrideModuleFactory(loggingModule, interceptorRegistryModule);
    MockApplicationContextFactory factory = new MockApplicationContextFactory();
    return factory.build(profilerConfig, moduleFactory);
}
Also used : ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule)

Example 2 with ModuleFactory

use of com.navercorp.pinpoint.profiler.context.module.ModuleFactory in project pinpoint by naver.

the class OverrideModuleFactory method newModule.

@Override
public Module newModule(AgentOption agentOption) {
    DefaultProfilerConfig profilerConfig = (DefaultProfilerConfig) agentOption.getProfilerConfig();
    profilerConfig.setTransportModule(TransportModule.THRIFT.name());
    ModuleFactory moduleFactory = new ApplicationContextModuleFactory() {

        @Override
        protected Module newRpcModule(AgentOption agentOption) {
            logger.info("load {}", MockRpcModule.class.getName());
            return new MockRpcModule();
        }
    };
    Module module = moduleFactory.newModule(agentOption);
    return Modules.override(module).with(overrideModule);
}
Also used : ApplicationContextModuleFactory(com.navercorp.pinpoint.profiler.context.module.ApplicationContextModuleFactory) ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) ApplicationContextModuleFactory(com.navercorp.pinpoint.profiler.context.module.ApplicationContextModuleFactory) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) MockRpcModule(com.navercorp.pinpoint.test.rpc.MockRpcModule) Module(com.google.inject.Module) TransportModule(com.navercorp.pinpoint.bootstrap.config.TransportModule) MockRpcModule(com.navercorp.pinpoint.test.rpc.MockRpcModule)

Example 3 with ModuleFactory

use of com.navercorp.pinpoint.profiler.context.module.ModuleFactory in project pinpoint by naver.

the class PluginTestAgent method newApplicationContext.

@Override
protected ApplicationContext newApplicationContext(AgentOption agentOption) {
    PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
    ModuleFactory moduleFactory = new OverrideModuleFactory(pluginApplicationContextModule);
    DefaultApplicationContext applicationContext = new DefaultApplicationContext(agentOption, moduleFactory);
    exportVerifier(applicationContext);
    return applicationContext;
}
Also used : ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)

Example 4 with ModuleFactory

use of com.navercorp.pinpoint.profiler.context.module.ModuleFactory in project pinpoint by naver.

the class MockApplicationContextFactory method newModuleFactory.

private ModuleFactory newModuleFactory() {
    Module pluginModule = new MockApplicationContextModule();
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    Module interceptorRegistryModule = InterceptorRegistryModule.wrap(binder);
    ModuleFactory moduleFactory = new OverrideModuleFactory(pluginModule, interceptorRegistryModule);
    return moduleFactory;
}
Also used : ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) Module(com.google.inject.Module)

Example 5 with ModuleFactory

use of com.navercorp.pinpoint.profiler.context.module.ModuleFactory in project pinpoint by naver.

the class MockApplicationContextModuleTest method testMockApplicationContext.

@Test
public void testMockApplicationContext() {
    ProfilerConfig profilerConfig = spy(new DefaultProfilerConfig());
    when(profilerConfig.getStaticResourceCleanup()).thenReturn(true);
    Instrumentation instrumentation = Mockito.mock(Instrumentation.class);
    AgentOption agentOption = new DefaultAgentOption(instrumentation, "mockAgentId", "mockAgentName", "mockApplicationName", false, profilerConfig, Collections.<String>emptyList(), Collections.<String>emptyList());
    Module pluginModule = new PluginApplicationContextModule();
    InterceptorRegistryBinder interceptorRegistryBinder = new TestInterceptorRegistryBinder();
    Module testInterceptorRegistryModule = InterceptorRegistryModule.wrap(interceptorRegistryBinder);
    ModuleFactory moduleFactory = new OverrideModuleFactory(pluginModule, testInterceptorRegistryModule);
    DefaultApplicationContext applicationContext = new DefaultApplicationContext(agentOption, moduleFactory);
    Injector injector = applicationContext.getInjector();
    // singleton check
    AgentInfoSender instance1 = injector.getInstance(AgentInfoSender.class);
    AgentInfoSender instance2 = injector.getInstance(AgentInfoSender.class);
    Assert.assertSame(instance1, instance2);
    ClassFileTransformer instance4 = injector.getInstance(ClassFileTransformer.class);
    applicationContext.close();
}
Also used : ClassFileTransformer(java.lang.instrument.ClassFileTransformer) 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) Instrumentation(java.lang.instrument.Instrumentation) AgentInfoSender(com.navercorp.pinpoint.profiler.AgentInfoSender) ModuleFactory(com.navercorp.pinpoint.profiler.context.module.ModuleFactory) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) Injector(com.google.inject.Injector) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) Module(com.google.inject.Module) Test(org.junit.Test)

Aggregations

ModuleFactory (com.navercorp.pinpoint.profiler.context.module.ModuleFactory)8 Module (com.google.inject.Module)6 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)5 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)4 AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)3 DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)3 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)3 AbstractModule (com.google.inject.AbstractModule)2 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)2 InterceptorRegistryModule (com.navercorp.pinpoint.profiler.context.module.InterceptorRegistryModule)2 OverrideModuleFactory (com.navercorp.pinpoint.profiler.context.module.OverrideModuleFactory)2 Instrumentation (java.lang.instrument.Instrumentation)2 Injector (com.google.inject.Injector)1 GraphvizModule (com.google.inject.grapher.graphviz.GraphvizModule)1 TransportModule (com.navercorp.pinpoint.bootstrap.config.TransportModule)1 AgentInfoSender (com.navercorp.pinpoint.profiler.AgentInfoSender)1 ApplicationContextModuleFactory (com.navercorp.pinpoint.profiler.context.module.ApplicationContextModuleFactory)1 DefaultModuleFactoryResolver (com.navercorp.pinpoint.profiler.context.module.DefaultModuleFactoryResolver)1 ModuleFactoryResolver (com.navercorp.pinpoint.profiler.context.module.ModuleFactoryResolver)1 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)1