1

I am using eclipse IDE to build a Spring project, that identifies the execution time of a module, to get that I am using jamonapi.monitorfactory, I added external jamonapi-all.jar in the project build, but still I get the import com.jamonapi .monitor cannot be resolved error.

 package com.blog.samples.aop;

 import java.util.Date;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.After;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
 import org.apache.log4j.Logger;

 import com.jamonapi.Monitor;
 import com.jamonapi.MonitorFactory;


 @Aspect
 public class PerformanceMonitor
 {
private static final Logger logger_c = Logger.getLogger(PerformanceMonitor.class);
private final String MONITOR = "PERFORMANCE_MONITOR";
private Monitor monitor_i;


@Before("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void startMonitor()
{
    monitor_i = MonitorFactory.start(MONITOR);
}


@After("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void stopMonitor()
{
    monitor_i.stop();
}

public Date getLastAccess()
{
    return monitor_i.getLastAccess();
}

public int getCallCount()
{
    return (int) monitor_i.getHits();
}

public double getAverageCallTime()
{
    return monitor_i.getAvg() / 1000;
}

public double getLastCallTime()
{
    return monitor_i.getLastValue() / 1000;
}

public double getMaximumCallTime()
{
    return monitor_i.getMax() / 1000;
}

public double getMinimumCallTime()
{
    return monitor_i.getMin() / 1000;
}
public double getTotalCallTime()
{
    return monitor_i.getTotal() / 1000;
}

@After("execution(*com.blog.samples.aop.CalculationService.dummyServiceMethod())")
public void log(JoinPoint joinPoint_p)
{
    StringBuffer sb = new StringBuffer();

    sb.append("\n");
    sb.append("*======================================");
    sb.append("\n");
    sb.append("*       PERFORMANCE STATISTICS        *");
    sb.append("\n");
    sb.append("*======================================");
    sb.append("\n");
    sb.append("*  Method Name: " + joinPoint_p.getSignature().getName());
    sb.append("\n");
    sb.append("*  Execution Date: ").append(this.getLastAccess());
    sb.append("\n");
    sb.append("*  Last Execution Time:  ").append(this.getLastCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*  Service Calls: ").append(((this.getCallCount())));
    sb.append("\n");
    sb.append("*  Avg Execution Time: ").append(this.getAverageCallTime()).append(" sec");
    sb.append("\n");
    sb.append("* TotalExecutionTIme:").append(this.getTotalCallTime()).append(" sec");
    sb.append("\n");
    sb.append("* MinExecutionTime:").append(this.getMinimumCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*  Max Execution Time: ").append(this.getMaximumCallTime()).append(" sec");
    sb.append("\n");
    sb.append("*======================================");

    logger_c.info(sb.toString());
}
Ralph
  • 118,862
  • 56
  • 287
  • 383
karthik
  • 15
  • 1
  • 4

2 Answers2

0

The correct import is like this:


    import org.jamon.api.*;

However, that Monitor class is nowhere to be found in that package.

  • i am a newbie to spring, so could u suggest any tutorial on installing jamon , and working on t...thanks – karthik Apr 07 '14 at 03:45
0
  • jamonapi-all.jar is not the jar that contains the jamon classes.
  • What you want is jamon-2.75.jar. It should be inside jamonapi-all.jar, or available via http://www.jamonapi.com
  • Alternatively you can use the maven dependency for jamon which you can get from the JAMon website.