Example usage for javax.interceptor InvocationContext getClass

List of usage examples for javax.interceptor InvocationContext getClass

Introduction

In this page you can find the example usage for javax.interceptor InvocationContext getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:EmployeeBean.java

  @AroundInvoke
public Object TimerLog(InvocationContext ctx) throws Exception {
  String beanClassName = ctx.getClass().getName();
  String businessMethodName = ctx.getMethod().getName();
  String target = beanClassName + "." + businessMethodName;
  long startTime = System.currentTimeMillis();
  System.out.println("Invoking " + target);
  try {/*from   w  ww .j a v  a2 s. co  m*/
    return ctx.proceed();
  } finally {
    System.out.println("Exiting " + target);
    long totalTime = System.currentTimeMillis() - startTime;
    System.out.println("Business method " + businessMethodName + "in " + beanClassName + "takes "
        + totalTime + "ms to execute");
  }
}