Package com.brienwheeler.lib.monitor.work

Examples of com.brienwheeler.lib.monitor.work.WorkMonitor


    ValidationUtils.assertTrue(joinPoint.getTarget() instanceof IWorkMonitorProvider,
        "@MonitoredWork target must be subclass of IWorkMonitorProvider");
    ValidationUtils.assertTrue(joinPoint.getSignature() instanceof MethodSignature,
        "@MonitoredWork signature must be a method");
   
        final WorkMonitor workMonitor = ((IWorkMonitorProvider) joinPoint.getTarget()).getWorkMonitor();
    MethodSignature signature = (MethodSignature) joinPoint.getSignature();
    MonitoredWork annotation = signature.getMethod().getAnnotation(MonitoredWork.class);
   
    final String workName = annotation != null && !annotation.value().isEmpty() ? annotation.value() : signature.getName();

        long start = System.currentTimeMillis();
        try {
            Object ret = joinPoint.proceed();
            workMonitor.recordWorkOk(workName, System.currentTimeMillis() - start);
            return ret;
        }
        catch (InterruptedException e) {
            workMonitor.recordWorkError(workName, System.currentTimeMillis() - start);
            Thread.currentThread().interrupt();
            throw e;
        }
        catch (RuntimeException e) {
            workMonitor.recordWorkError(workName, System.currentTimeMillis() - start);
            throw e;
        }
        catch (Error e) {
            workMonitor.recordWorkError(workName, System.currentTimeMillis() - start);
            throw e;
        }
        catch (Throwable e) {
            workMonitor.recordWorkError(workName, System.currentTimeMillis() - start);
            throw new RuntimeException(e);
        }
    }
View Full Code Here

TOP

Related Classes of com.brienwheeler.lib.monitor.work.WorkMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.