use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.
the class SpringBeansPlugin method addAbstractAutowireCapableBeanFactoryTransformer.
private void addAbstractAutowireCapableBeanFactoryTransformer(final ProfilerPluginSetupContext context) {
final ProfilerConfig config = context.getConfig();
final boolean errorMark = config.readBoolean(SPRING_BEANS_MARK_ERROR, false);
transformTemplate.transform("org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory", new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
final BeanMethodTransformer beanTransformer = new BeanMethodTransformer(errorMark);
final ObjectFactory beanFilterFactory = ObjectFactory.byStaticFactory("com.navercorp.pinpoint.plugin.spring.beans.interceptor.TargetBeanFilter", "of", config);
final InstrumentMethod createBeanInstance = target.getDeclaredMethod("createBeanInstance", "java.lang.String", "org.springframework.beans.factory.support.RootBeanDefinition", "java.lang.Object[]");
createBeanInstance.addInterceptor("com.navercorp.pinpoint.plugin.spring.beans.interceptor.CreateBeanInstanceInterceptor", va(beanTransformer, beanFilterFactory));
final InstrumentMethod postProcessor = target.getDeclaredMethod("applyBeanPostProcessorsBeforeInstantiation", "java.lang.Class", "java.lang.String");
postProcessor.addInterceptor("com.navercorp.pinpoint.plugin.spring.beans.interceptor.PostProcessorInterceptor", va(beanTransformer, beanFilterFactory));
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.
the class SpringBeansPlugin method addClassPathDefinitionScannerTransformer.
private void addClassPathDefinitionScannerTransformer(final ProfilerPluginSetupContext context) {
final ProfilerConfig config = context.getConfig();
final boolean errorMark = config.readBoolean(SPRING_BEANS_MARK_ERROR, false);
transformTemplate.transform("org.springframework.context.annotation.ClassPathBeanDefinitionScanner", new TransformCallback() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
final BeanMethodTransformer beanTransformer = new BeanMethodTransformer(errorMark);
final ObjectFactory beanFilterFactory = ObjectFactory.byStaticFactory("com.navercorp.pinpoint.plugin.spring.beans.interceptor.TargetBeanFilter", "of", context.getConfig());
final InstrumentMethod method = target.getDeclaredMethod("doScan", "java.lang.String[]");
method.addInterceptor("com.navercorp.pinpoint.plugin.spring.beans.interceptor.ClassPathDefinitionScannerDoScanInterceptor", va(loader, beanTransformer, beanFilterFactory));
return target.toBytecode();
}
});
}
use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method config.
@Test
public void config() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Repository");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(3, springBeansConfig.getTargets().size());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(1).getScope());
assertEquals(null, springBeansConfig.getTarget(1).getBasePackages());
assertEquals(1, springBeansConfig.getTarget(1).getNamePatterns().size());
assertEquals(1, springBeansConfig.getTarget(1).getAnnotations().size());
assertEquals(null, springBeansConfig.getTarget(1).getClassPatterns());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(2).getScope());
assertEquals(null, springBeansConfig.getTarget(2).getBasePackages());
assertEquals(null, springBeansConfig.getTarget(2).getNamePatterns());
assertEquals(1, springBeansConfig.getTarget(2).getAnnotations().size());
assertEquals(1, springBeansConfig.getTarget(2).getClassPatterns().size());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(3).getScope());
assertEquals(null, springBeansConfig.getTarget(3).getBasePackages());
assertEquals(null, springBeansConfig.getTarget(3).getNamePatterns());
assertEquals(1, springBeansConfig.getTarget(3).getAnnotations().size());
assertEquals(null, springBeansConfig.getTarget(3).getClassPatterns());
}
use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method empty.
@Test
public void empty() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 5 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 5 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(2, springBeansConfig.getTargets().size());
}
use of com.navercorp.pinpoint.bootstrap.config.ProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method scope.
@Test
public void scope() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "component-scan");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "component-scan");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_BASE_PACKAGES_POSTFIX, "com.navercorp");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "post-processor");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_BASE_PACKAGES_POSTFIX, "com.navercorp");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "post-processor");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(4, springBeansConfig.getTargets().size());
}
Aggregations