Annotation Interface Part
Part is used in the ClassTransaction.naming() and MethodTransaction.naming() parameters,
either as a single instance that defines the entire name or an annotation array with the syntax
{@Part(...), @Part(...), @Part(...)} where the concatenation of all parts determines the
name of the transaction.
Part concatenation adds no whitespace between parts, so you might have to introduce text parts for separation, like in
{@Part(Type.CLASS), @Part(text = " "), @Part(Type.PARAMETER)}
To reduce the number of parts, you can add text parameters to non-text parts. In that case, the text will always be appended as a suffix. The example above can be replaced with
{@Part(Type.CLASS, text = " "), @Part(Type.PARAMETER)}-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies the way package names are treated when adding class names to a transaction name.static enumThe kind of information that is added by aPart. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies a getter chain that should be called on an object for name parts of the typesPart.Type.PARAMETERandPart.Type.INSTANCE.Specifies the way packages names are converted to text for name parts of the typesPart.Type.CLASSandPart.Type.INSTANCE_CLASS.intSpecifies the index of the desired parameter name for parts of typePart.Type.PARAMETER.Specifies the text for a name part of typePart.Type.TEXTand a suffix for other part types.The type of the name part.
-
Element Details
-
value
Part.Type valueThe type of the name part. Different types require different parameters. Since the default type isPart.Type.TEXT, a fixed text name part can be written simply as@Part(text = "Some text")
For other parts types, if there are no further parameters, call
@Part(Type.CLASS)
If other parameters are required, you must specify
valuefor the type:@Part(value = Type.CLASS, packageMode = PackageMode.ABBREVIATED)
- See Also:
- Default:
TEXT
-
text
String textSpecifies the text for a name part of typePart.Type.TEXTand a suffix for other part types. For types other thanPart.Type.TEXT, you can add a text suffix to the value of the part. This can help you to reduce the number of parts. For example:@MethodTransaction(naming = {@Part(Type.CLASS, text="."), @Part(Type.METHOD)})- Default:
""
-
packageMode
Part.PackageMode packageModeSpecifies the way packages names are converted to text for name parts of the typesPart.Type.CLASSandPart.Type.INSTANCE_CLASS. For other types, the parameter has no effect and should not be specified.By default, package names are not added and only simple class names are used. This serves to keep transaction names short.
- See Also:
- Default:
NONE
-
getterChain
String getterChainSpecifies a getter chain that should be called on an object for name parts of the typesPart.Type.PARAMETERandPart.Type.INSTANCE. For other types, the parameter has no effect and should not be specified.Without a getter chain, the
toString()method of the parameter (for Part.Type#PARAMETER) or the instance of the instrumented method (Part.Type#INSTANCE) are called and the result is the value of the name part. With a getter chain, you can call any number of parameter-less methods or fields to replace the original object with the result of the getter chain.Usage:
- For a single field, specify the plain field name, e.g. "fieldName"
- For a single method call, specify the method name with parentheses, e.g. "getterName()"
-
For a chain of method calls and field accesses, concatenate them with a dot, e.g.
"getterNameOne().field.getterNameTwo()".
For an invocation of
getClass(), there are two special fields that are added by jvmguard to get the same result as for thePart.Type.CLASSandPart.Type.INSTANCE_CLASSnaming parts with their differentpackage modes:- With
getClass().simpleName, the simple name of the class is added. For example,com.mycorp.MyClassbecomesMyClass. -
With
getClass().abbrevName, the abbreviated package names are added. For example,com.mycorp.MyClassbecomesc.m.MyClass.
Exceptional circumstances:
-
If part of a getter chain operates on a primitive type (like an
intvalue), the method will be called on the primitive wrapper class (likejava.lang.Integer). -
If part of a getter chain operates on a
nullvalue, processing of the getter chain will stop and the value of the name part will be set to the string "null". -
If an exception occurs while a getter chain is evaluated, the name part will be set to the empty value.
The exception will not be logged unless you pass the system property
jvmguard.logUser=10in the monitored VM. See the debug section in the package overview for more information on logging.
- Default:
""
-
parameterIndex
int parameterIndexSpecifies the index of the desired parameter name for parts of typePart.Type.PARAMETER. For other types, the parameter has no effect and should not be specified.By default, the first parameter is used, to use another parameter specify the zero-based index of the parameter.
- Default:
0
-