Search in sources :

Example 1 with ShutdownHookRegisterProvider

use of com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider in project pinpoint by naver.

the class DefaultAgent method registerStopHandler.

@Override
public void registerStopHandler() {
    if (applicationContext instanceof DefaultApplicationContext) {
        logger.info("registerStopHandler");
        DefaultApplicationContext context = (DefaultApplicationContext) applicationContext;
        ShutdownHookRegisterProvider shutdownHookRegisterProvider = context.getShutdownHookRegisterProvider();
        ShutdownHookRegister shutdownHookRegister = shutdownHookRegisterProvider.get();
        PinpointThreadFactory pinpointThreadFactory = new PinpointThreadFactory("Pinpoint-shutdown-hook", false);
        Thread shutdownThread = pinpointThreadFactory.newThread(new Runnable() {

            @Override
            public void run() {
                logger.info("stop() started. threadName:" + Thread.currentThread().getName());
                DefaultAgent.this.stop();
            }
        });
        shutdownHookRegister.register(shutdownThread);
    }
}
Also used : DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) ShutdownHookRegisterProvider(com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider) PinpointThreadFactory(com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)

Example 2 with ShutdownHookRegisterProvider

use of com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider in project pinpoint by naver.

the class ConfigModule method bindShutdownHook.

private void bindShutdownHook(ContextConfig contextConfig) {
    // for lazy init
    ShutdownHookRegisterProvider instance = new ShutdownHookRegisterProvider(contextConfig);
    bind(ShutdownHookRegisterProvider.class).toInstance(instance);
}
Also used : ShutdownHookRegisterProvider(com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider)

Aggregations

ShutdownHookRegisterProvider (com.navercorp.pinpoint.profiler.context.provider.ShutdownHookRegisterProvider)2 PinpointThreadFactory (com.navercorp.pinpoint.common.profiler.concurrent.PinpointThreadFactory)1 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)1