/** * Checks if the {@link SensorInstrumentationPoint} exists in the * {@link MethodInstrumentationConfig}. If not new one is created, registered with registration * service and saved in the {@link MethodInstrumentationConfig}. * * @param agentConfiguration * {@link AgentConfig} to read platform id. * @param methodType * {@link MethodType} in question. * @param methodInstrumentationConfig * {@link MethodInstrumentationConfig}. * @return {@link SensorInstrumentationPoint} for the {@link MethodInstrumentationConfig}. */ protected SpecialInstrumentationPoint getOrCreateSpecialInstrumentationPoint(AgentConfig agentConfiguration, MethodType methodType, MethodInstrumentationConfig methodInstrumentationConfig) { // check for existing SpecialInstrumentationPoint specialInstrumentationPoint = methodInstrumentationConfig.getSpecialInstrumentationPoint(); // if not create new one if (null == specialInstrumentationPoint) { // if not create new and register long id = registerMethod(agentConfiguration, methodType, methodInstrumentationConfig); specialInstrumentationPoint = new SpecialInstrumentationPoint(); specialInstrumentationPoint.setId(id); // set to method instrumentation methodInstrumentationConfig.setSpecialInstrumentationPoint(specialInstrumentationPoint); } return specialInstrumentationPoint; }
SpecialInstrumentationPoint specialInstrumentationPoint = config.getSpecialInstrumentationPoint(); if (null == specialInstrumentationPoint) { return null;
when(methodInstrumentationConfig.getReturnType()).thenReturn("void"); when(methodInstrumentationConfig.getAllInstrumentationPoints()).thenReturn(Collections.<IMethodInstrumentationPoint> singleton(specialInstrumentationPoint)); when(methodInstrumentationConfig.getSpecialInstrumentationPoint()).thenReturn(specialInstrumentationPoint);
assertThat(rsc.getSensorIds().length, is(0)); assertThat(rsc.isConstructor(), is(false)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint(); assertThat(ssc.getId(), is(methodId)); assertThat(ssc.getSensorId(), is(0L));
assertThat(rsc.getSensorIds().length, is(0)); assertThat(rsc.isConstructor(), is(true)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint(); assertThat(ssc.getId(), is(methodId)); assertThat(ssc.getSensorId(), is(0L));
assertThat(rsc.getSensorIds()[0], is(sensorId)); assertThat(rsc.getSettings(), is(settings)); assertThat(instrumentationConfig.getSpecialInstrumentationPoint(), is(nullValue()));
assertThat(rsc.getSensorIds()[0], is(sensorId)); assertThat(rsc.getSettings(), is(settings)); assertThat(instrumentationConfig.getSpecialInstrumentationPoint(), is(nullValue()));
assertThat(instrumentationConfig.getParameterTypes(), is(parameters)); assertThat(instrumentationConfig.getAllInstrumentationPoints(), hasSize(1)); SpecialInstrumentationPoint ssc = instrumentationConfig.getSpecialInstrumentationPoint(); assertThat(ssc.getId(), is(methodId)); assertThat(ssc.getSensorId(), is(sensorId));
SpecialInstrumentationPoint specialInstrumentationPoint = config.getSpecialInstrumentationPoint(); hookDispatcherMapper.addMapping(specialSensorConfig.getId(), specialSensorConfig); methodToSensorMap.put(Long.valueOf(specialSensorConfig.getId()), new long[] { specialInstrumentationPoint.getSensorId() });