/** * Determines the business transaction name for the given {@link InvocationSequenceData} using * the passed {@link BusinessTransactionDefinition}. * * @param invocSequence * {@link InvocationSequenceData} to determine the business transaction name for. * @param cachedDataService * {@link ICachedDataService} instance for retrieving method names, etc. * @return a business transaction name */ public String determineBusinessTransactionName(InvocationSequenceData invocSequence, ICachedDataService cachedDataService) { String businessTxName; if (dynamicNameExtractionActive()) { businessTxName = extractNameDynamically(invocSequence, cachedDataService, 0); if (null == businessTxName) { businessTxName = getBusinessTransactionDefinitionName() + NameExtractionExpression.UNKNOWN_DYNAMIC_BUSINESS_TRANSACTION_POSTFIX; } else if (StringUtils.isEmpty(businessTxName)) { businessTxName = getBusinessTransactionDefinitionName() + NameExtractionExpression.EMPTY_DYNAMIC_BUSINESS_TRANSACTION_POSTFIX; } } else { businessTxName = getBusinessTransactionDefinitionName(); } return businessTxName; }
/** * Extracts the business transaction name dynamically from the {@link InvocationSequenceData} by * recursively iterating over the invocation sequence. * * @param invocSequence * {@link InvocationSequenceData} to extract the business transaction from. * @param cachedDataService * {@link ICachedDataService} instance for retrieving method names, etc. * @param depth * current recursion depth. THis is used stop the recursion at a specified maximum * search depth. * @return extracted name */ private String extractNameDynamically(InvocationSequenceData invocSequence, ICachedDataService cachedDataService, int depth) { String name = getNameExtractionExpression().extractName(invocSequence, cachedDataService); if ((null == name) && (null != invocSequence.getNestedSequences())) { if ((getNameExtractionExpression().getMaxSearchDepth() < 0) || (depth < getNameExtractionExpression().getMaxSearchDepth())) { for (InvocationSequenceData child : invocSequence.getNestedSequences()) { name = extractNameDynamically(child, cachedDataService, depth + 1); if (null != name) { return name; } } } } return name; }