RE: Tapestry decorator with marker

Labhesh Ramchandani <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <[email protected]>
Minor correction:

I meant to type:

@Marker(TimeIt.class)
public class ASpecificManagerImpl implements ASpecificManager {...}

in my email.. (and not Timer.class...)

(My question is still the same...thanks)


From: Labhesh Ramchandani
Sent: Sunday, September 02, 2018 8:56 PM
To: '[email protected]'
Subject: Tapestry decorator with marker

Hi,

I've written a simple decorator as follows (in my app module):
  @Decorate
  @TimeIt
  public static <T> T decorateTimer(Class<T> serviceInterface, T delegate,
      String serviceId, Logger logger,
      TimerDecorator decorator) {
    return decorator.build(serviceInterface, delegate, serviceId, logger);
  }

With the marker definition as:

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@UseWith(AnnotationUseContext.SERVICE)
public @interface TimeIt {
}


And here's how I use it:

@Marker(Timer.class)
public class ASpecificManagerImpl implements ASpecificManager {

public void methodA() {...}

public void methodB() {...}
}

Is there a way to annotate just the specific method? I don't want to time all methods...just the ones that have the marker on them?
In the example above; I'd like to decorate (and time) just method A and not B; how can I do that? Also how do I get the methodReciever to log the name of the specific methodA being timed?

My timing advisor looks like this

  public <T> void addTimingAdvice(MethodAdviceReceiver methodAdviceReceiver, Class<T> serviceInterface, Logger logger) {
    MethodAdvice advice = invocation -> {
      long start = System.currentTimeMillis();
      invocation.proceed();
      long end = System.currentTimeMillis();
      logger.info(serviceInterface.getName() + " took: " + (end - start) + " [ms]");
    };
    methodAdviceReceiver.adviseAllMethods(advice);
  }

Thanks


________________________________

Disclaimer: This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please notify the sender immediately and destroy/delete this e-mail. You are hereby notified that any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly prohibited.

AQR Capital Management, LLC, along with its affiliates (collectively "AQR") may collect certain personal information from you. AQR operates pursuant to a Global Privacy Policy which describes the types of personal information we obtain, how we use the information, with whom we share it and the choices available to you regarding our use of the information. We also describe the measures we take to protect the security of the information and how you can contact us about our privacy practices. By providing your personal information you agree to do so pursuant to the Global Privacy Policy. For a copy of the Global Privacy Policy please click here<https://www.aqr.com/Privacy-Policy>.

This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All information contained in this communication is not warranted as to completeness or accuracy and is subject to change without notice. Any comments or statements made in this communication do not necessarily reflect those of AQR Capital Management, LLC and its affiliates.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.