ProducerConstructorInterceptor implements InstanceConstructorInterceptor { @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { PulsarClientImpl pulsarClient = (PulsarClientImpl) allArguments[0]; String topic = (String) allArguments[1]; ProducerEnhanceRequiredInfo producerEnhanceRequiredInfo = new ProducerEnhanceRequiredInfo(); producerEnhanceRequiredInfo.setTopic(topic); producerEnhanceRequiredInfo.setServiceUrl(pulsarClient.getLookup().getServiceUrl()); objInst.setSkyWalkingDynamicField(producerEnhanceRequiredInfo); }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@Test public void testOnConsumer() { constructorInterceptor.onConstruct(enhancedInstance, new Object[] { pulsarClient, TOPIC_NAME }); ProducerEnhanceRequiredInfo requiredInfo = (ProducerEnhanceRequiredInfo) enhancedInstance.getSkyWalkingDynamicField(); assertThat(requiredInfo.getServiceUrl(), is(SERVICE_URL)); assertThat(requiredInfo.getTopic(), is(TOPIC_NAME)); }