33import org .springframework .boot .SpringApplication ;
44import org .springframework .boot .autoconfigure .SpringBootApplication ;
55import org .springframework .context .annotation .Bean ;
6- import org .springframework .expression .Expression ;
7- import org .springframework .expression .ExpressionParser ;
8- import org .springframework .expression .spel .SpelParserConfiguration ;
9- import org .springframework .expression .spel .standard .SpelExpressionParser ;
10- import org .springframework .expression .spel .support .SimpleEvaluationContext ;
11- import org .springframework .expression .spel .support .StandardEvaluationContext ;
126
13- import io .micrometer .common .annotation .ValueExpressionResolver ;
147import io .micrometer .core .aop .CountedAspect ;
158import io .micrometer .core .aop .CountedMeterTagAnnotationHandler ;
169import io .micrometer .core .aop .MeterTagAnnotationHandler ;
1710import io .micrometer .core .aop .TimedAspect ;
1811
1912@ SpringBootApplication
20- public class Application {
13+ class Application {
2114
2215 public static void main (String [] args ) {
2316 SpringApplication .run (Application .class , args );
@@ -34,32 +27,10 @@ public MeterTagAnnotationHandler meterTagAnnotationHandler() {
3427 public CountedAspect countedAspect () {
3528 CountedAspect aspect = new CountedAspect ();
3629 CountedMeterTagAnnotationHandler tagAnnotationHandler = new CountedMeterTagAnnotationHandler (
37- aClass -> o -> new SpelValueExpressionResolver (). resolve ( o . toString (), null ) ,
38- aClass -> new SpelValueExpressionResolver () );
30+ aClass -> Object :: toString ,
31+ aClass -> ( exp , param ) -> "" );
3932 aspect .setMeterTagAnnotationHandler (tagAnnotationHandler );
4033 return aspect ;
4134 }
4235
43- public static class SpelValueExpressionResolver implements ValueExpressionResolver {
44-
45- @ Override
46- public String resolve (String expression , Object parameter ) {
47- try {
48- SpelParserConfiguration config = new SpelParserConfiguration (true , true );
49- StandardEvaluationContext context = new StandardEvaluationContext (parameter );
50-
51- ExpressionParser expressionParser = new SpelExpressionParser (config );
52- return expressionParser .parseExpression (expression )
53- .getValue (context , String .class );
54-
55- // ExpressionParser expressionParser = new SpelExpressionParser();
56- // Expression expressionToEvaluate = expressionParser.parseExpression(expression);
57- // return expressionToEvaluate.getValue(parameter, String.class);
58- }
59- catch (Exception ex ) {
60- ex .printStackTrace (); // todo: proper logging
61- }
62- return String .valueOf (parameter );
63- }
64- }
6536}
0 commit comments