public void map(LoggingInfo loggingInfo, Object target) { LoggingCustomData loggingCustomData = loggingInfo.getLoggingCustomData(); Class<?> targetClass = target.getClass(); Class<?> klass = targetClass; Map<Annotation, Method> customAnnotationMethodMap = new HashMap<Annotation, Method>(); Map<Annotation, Method> annotationMethodMap = new HashMap<Annotation, Method>(); while (klass != Object.class) { for (final Method method : klass.getDeclaredMethods()) { for (final Annotation annotation : method.getAnnotations()) { if (loggingCustomData != null && CUSTOM_ANNOTATIONS.contains(annotation.annotationType())) { if (method.getParameterTypes().length != 1) { if (log.isWarnEnabled()) { log.warn( "Please, check that annotated method '" + method.toGenericString() + "' is setter method!"); } } customAnnotationMethodMap.put(annotation, method); } if (MAPPING_ANNOTATIONS.contains(annotation.annotationType())) { if (method.getParameterTypes().length != 1) { if (log.isWarnEnabled()) { log.warn( "Please, check that annotated method '" + method.toGenericString() + "' is setter method!"); } } annotationMethodMap.put(annotation, method); } } } klass = klass.getSuperclass(); } for (Entry<Annotation, Method> entry : annotationMethodMap.entrySet()) { Annotation annotation = entry.getKey(); Method method = entry.getValue(); if (SetterIncomingTime.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingInfo.getIncomingMessageTime()); } if (SetterOutcomingTime.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingInfo.getOutcomingMessageTime()); } if (SetterInputName.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingInfo.getInputName()); } if (SetterServiceName.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingInfo.getServiceName()); } if (SetterPublisher.class.equals(annotation.annotationType())) { insertValue( loggingInfo, target, annotation, method, loggingInfo.getPublisherType().toString()); } if (loggingInfo.getRequestMessage() != null) { if (SetterUrl.class.equals(annotation.annotationType()) && loggingInfo.getRequestMessage().getAddress() != null) { insertValue( loggingInfo, target, annotation, method, loggingInfo.getRequestMessage().getAddress().toString()); } if (SetterRequest.class.equals(annotation.annotationType()) && loggingInfo.getResponseMessage().getPayload() != null) { insertValue( loggingInfo, target, annotation, method, loggingInfo.getRequestMessage().getPayload().toString()); } } else { log.error("Request message is not present!"); } if (loggingInfo.getResponseMessage() != null) { if (SetterResponse.class.equals(annotation.annotationType()) && loggingInfo.getResponseMessage().getPayload() != null) { insertValue( loggingInfo, target, annotation, method, loggingInfo.getResponseMessage().getPayload().toString()); } } else { log.error("Response message is not present!"); } if (UseLoggingInfoConvertor.class.equals(annotation.annotationType())) { useLoggingInfoInsertValue(loggingInfo, target, annotation, method); } } for (Entry<Annotation, Method> entry : customAnnotationMethodMap.entrySet()) { Annotation annotation = entry.getKey(); Method method = entry.getValue(); if (SetterCustomStringValue1.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue1()); } if (SetterCustomStringValue2.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue2()); } if (SetterCustomStringValue3.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue3()); } if (SetterCustomStringValue4.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue4()); } if (SetterCustomStringValue5.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getStringValue5()); } if (SetterCustomNumberValue1.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue1()); } if (SetterCustomNumberValue2.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue2()); } if (SetterCustomNumberValue3.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue3()); } if (SetterCustomNumberValue4.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue4()); } if (SetterCustomNumberValue5.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getNumberValue5()); } if (SetterCustomDateValue1.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue1()); } if (SetterCustomDateValue2.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue2()); } if (SetterCustomDateValue3.class.equals(annotation.annotationType())) { insertValue(loggingInfo, target, annotation, method, loggingCustomData.getDateValue3()); } } }