JsTopicInterceptor implements Serializable { String getDynamicTopic(Method method, Object[] parameters) { int idx = 0; Annotation[][] parametersAnnotations = method.getParameterAnnotations(); for (Annotation[] parameterAnnotations : parametersAnnotations) { JsTopicName jsTopicName = getJsTopicNameAnnotation(parameterAnnotations); if (jsTopicName != null) { return computeTopic(jsTopicName, parameters[idx].toString()); } idx++; } return null; }  @AroundInvoke Object processJsTopic(InvocationContext ctx);  }
@Test public void testGetDynamicTopic() throws Exception { System.out.println("getDynamicTopic"); Method method = this.getClass().getMethod("methodWithJsTopicAndWithJsTopicName", new Class[] {Integer.class, String.class}); Object[] parameters = new Object[] {5, "TOPICNAME"}; String result = instance.getDynamicTopic(method, parameters); assertThat(result).isEqualTo("TOPICNAME"); method = this.getClass().getMethod("methodWithJsTopicAndWithoutJsTopicName", new Class[] {Integer.class, String.class}); result = instance.getDynamicTopic(method, parameters); assertThat(result).isNull(); }