Package org.apache.sirona.stopwatches

Examples of org.apache.sirona.stopwatches.StopWatch


    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        final String name = method.getName();
        if (name.startsWith("execute")) {
            final StopWatch stopWatch;
            if (name.endsWith("Batch") && (args == null || args.length == 0)) {
                stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, "batch")));
            } else {
                stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, (String) args[0])));
            }

            try {
                return doInvoke(method, args);
            } catch (final InvocationTargetException e) {
                throw extractSQLException(e);
            } finally {
                stopWatch.stop();
            }
        }
        return doInvoke(method, args);
    }
View Full Code Here


    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        final String name = method.getName();
        if ((args == null || args.length == 0) && name.startsWith("execute")) {
            final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, sql)));
            try {
                return method.invoke(statement, args);
            } catch (final InvocationTargetException e) {
                throw extractSQLException(e);
            } finally {
                stopWatch.stop();
            }
        }
        return super.invoke(proxy, method, args);
    }
View Full Code Here

    private CallableStatement monitor(final CallableStatement statement, final String sql) {
        return CallableStatement.class.cast(Proxy.newProxyInstance(ClassLoaders.current(), new Class<?>[]{CallableStatement.class}, new MonitoredPreparedStatement(statement, sql)));
    }

    public static Connection monitor(final Connection connection, final Counter counter) {
        final StopWatch stopWatch = new CounterStopWatch(counter);
        return Connection.class.cast(Proxy.newProxyInstance(ClassLoaders.current(), new Class<?>[]{Connection.class}, new MonitoredConnection(connection, stopWatch)));
    }
View Full Code Here

    protected Context before(final T invocation, final String name) {
        final ActivationContext context = doFindContext(invocation);

        try
        {
            final StopWatch stopwatch;
            if (context.shouldExecute()) {
                Repository repository =  Repository.INSTANCE;
                if (repository==null){
                    System.out.println("repository is null");
                }
                final Counter monitor = repository.getCounter(getKey(invocation, name));
                if ( monitor == null){
                    System.out.println("monitor is null");
                }
                stopwatch = Repository.INSTANCE.start(monitor);
            } else {
                stopwatch = null;
            }

            return newContext(invocation, context, stopwatch);
        }
        catch ( Exception e )
        {
            //e.printStackTrace();
            // ignore and return a fake context can happen on start when intercepting some classes
            // and all agent classes not really loaded
            return newContext( invocation, context, new StopWatch()
            {
                @Override
                public long getElapsedTime()
                {
                    return 0;
View Full Code Here

     *
     * @see javax.servlet.jsp.tagext.TagSupport#doStartTag()
     */
    @Override
    public int doStartTag() throws JspException {
        StopWatch stopWatch;
        if (scope != null) {
            stopWatch = (StopWatch) pageContext.getAttribute(id, getScope(scope));
        } else {
            stopWatch = (StopWatch) pageContext.getAttribute(id);
        }
        if (stopWatch == null) {
            throw new JspException("No StopWatch under ID " + id + " and scope " + scope);
        }
        stopWatch.stop();
        return EVAL_PAGE;
    }
View Full Code Here

        this.id = id;
    }

    @Override
    public int doStartTag() throws JspException {
        final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JSP, name)));
        if (scope != null) {
            pageContext.setAttribute(id, stopWatch, getScope(scope));
        } else {
            pageContext.setAttribute(id, stopWatch);
        }
View Full Code Here

    private Counter counter;
    private SessionGauge gauge;

    @Override
    public void sessionCreated(final HttpSessionEvent httpSessionEvent) {
        final StopWatch watch = Repository.INSTANCE.start(counter);
        watches.put(httpSessionEvent.getSession().getId(), watch);
        sessionNumber.incrementAndGet();
    }
View Full Code Here

        sessionNumber.incrementAndGet();
    }

    @Override
    public void sessionDestroyed(final HttpSessionEvent httpSessionEvent) {
        final StopWatch watch = watches.remove(httpSessionEvent.getSession().getId());
        if (watch != null) {
            watch.stop();
        }
        sessionNumber.decrementAndGet();
    }
View Full Code Here

    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        final String name = method.getName();
        if ((args == null || args.length == 0) && name.startsWith("execute")) {
            final StopWatch stopWatch = Repository.INSTANCE.start(Repository.INSTANCE.getCounter(new Counter.Key(Role.JDBC, sql)));
            try {
                return method.invoke(statement, args);
            } catch (final InvocationTargetException e) {
                throw extractSQLException(e);
            } finally {
                stopWatch.stop();
            }
        }
        return super.invoke(proxy, method, args);
    }
View Full Code Here

    private CallableStatement monitor(final CallableStatement statement, final String sql) {
        return CallableStatement.class.cast(Proxy.newProxyInstance(ClassLoaders.current(), new Class<?>[]{CallableStatement.class}, new MonitoredPreparedStatement(statement, sql)));
    }

    public static Connection monitor(final Connection connection, final Counter counter) {
        final StopWatch stopWatch = new CounterStopWatch(counter);
        return Connection.class.cast(Proxy.newProxyInstance(ClassLoaders.current(), new Class<?>[]{Connection.class}, new MonitoredConnection(connection, stopWatch)));
    }
View Full Code Here

TOP

Related Classes of org.apache.sirona.stopwatches.StopWatch

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.