use of com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy in project aws-xray-sdk-java by aws.
the class AWSXRayServletAsyncListener method init.
/**
* @param config
* the filter configuration. There are various init-params which may be passed on initialization. The values in init-params will create segment naming strategies which override those passed in constructors.
*
* <ul>
*
* <li>
* <b>fixedName</b> A String value used as the fixedName parameter for a created {@link com.amazonaws.xray.strategy.FixedSegmentNamingStrategy}. Used only if the {@code dynamicNamingFallbackName} init-param is not set.
* </li>
*
* <li>
* <b>dynamicNamingFallbackName</b> A String value used as the fallbackName parameter for a created {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}.
* </li>
*
* <li>
* <b>dynamicNamingRecognizedHosts</b> A String value used as the recognizedHosts parameter for a created {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}.
* </li>
*
* </ul>
*
* @throws ServletException
* when a segment naming strategy is not provided in constructor arguments nor in init-params.
*/
@Override
public void init(FilterConfig config) throws ServletException {
String fixedName = config.getInitParameter("fixedName");
String dynamicNamingFallbackName = config.getInitParameter("dynamicNamingFallbackName");
String dynamicNamingRecognizedHosts = config.getInitParameter("dynamicNamingRecognizedHosts");
if (StringValidator.isNotNullOrBlank(dynamicNamingFallbackName)) {
if (StringValidator.isNotNullOrBlank(dynamicNamingRecognizedHosts)) {
segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName, dynamicNamingRecognizedHosts);
} else {
segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName);
}
} else if (StringValidator.isNotNullOrBlank(fixedName)) {
segmentNamingStrategy = new FixedSegmentNamingStrategy(fixedName);
} else if (null == segmentNamingStrategy) {
throw new ServletException("The AWSXRayServletFilter requires either a fixedName init-param or an instance of SegmentNamingStrategy. Add an init-param tag to the AWSXRayServletFilter's declaration in web.xml, using param-name: 'fixedName'. Alternatively, pass an instance of SegmentNamingStrategy to the AWSXRayServletFilter constructor.");
}
}
use of com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy in project aws-xray-sdk-java by aws.
the class AWSXRayServletFilter method init.
/**
* @param config
* the filter configuration. There are various init-params which may be passed on initialization. The values in init-params
* will create segment naming strategies which override those passed in constructors.
*
* <ul>
*
* <li>
* <b>fixedName</b> A String value used as the fixedName parameter for a created
* {@link com.amazonaws.xray.strategy.FixedSegmentNamingStrategy}. Used only if the {@code dynamicNamingFallbackName}
* init-param is not set.
* </li>
*
* <li>
* <b>dynamicNamingFallbackName</b> A String value used as the fallbackName parameter for a created
* {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}.
* </li>
*
* <li>
* <b>dynamicNamingRecognizedHosts</b> A String value used as the recognizedHosts parameter for a created
* {@link com.amazonaws.xray.strategy.DynamicSegmentNamingStrategy}.
* </li>
*
* </ul>
*
* @throws ServletException
* when a segment naming strategy is not provided in constructor arguments nor in init-params.
*/
@Override
public void init(FilterConfig config) throws ServletException {
String fixedName = config.getInitParameter("fixedName");
String dynamicNamingFallbackName = config.getInitParameter("dynamicNamingFallbackName");
String dynamicNamingRecognizedHosts = config.getInitParameter("dynamicNamingRecognizedHosts");
if (StringValidator.isNotNullOrBlank(dynamicNamingFallbackName)) {
if (StringValidator.isNotNullOrBlank(dynamicNamingRecognizedHosts)) {
segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName, dynamicNamingRecognizedHosts);
} else {
segmentNamingStrategy = new DynamicSegmentNamingStrategy(dynamicNamingFallbackName);
}
} else if (StringValidator.isNotNullOrBlank(fixedName)) {
segmentNamingStrategy = new FixedSegmentNamingStrategy(fixedName);
} else if (null == segmentNamingStrategy) {
throw new ServletException("The AWSXRayServletFilter requires either a fixedName init-param or an instance of SegmentNamingStrategy. " + "Add an init-param tag to the AWSXRayServletFilter's declaration in web.xml, using param-name: 'fixedName'. " + "Alternatively, pass an instance of SegmentNamingStrategy to the AWSXRayServletFilter constructor.");
}
}
Aggregations