Permalink
Browse files

Drop old @Timed support

  • Loading branch information...
1 parent 3248fa6 commit c4e544670cc44cce725302d994ce8365b4e69bb9 @jdillon jdillon committed Apr 16, 2013
View
5 nexus-core/pom.xml
@@ -253,11 +253,6 @@
</dependency>
<dependency>
- <groupId>org.javasimon</groupId>
- <artifactId>javasimon-core</artifactId>
- </dependency>
-
- <dependency>
<groupId>com.yammer.metrics</groupId>
<artifactId>metrics-core</artifactId>
</dependency>
View
3 nexus-core/src/main/java/org/sonatype/nexus/guice/NexusModules.java
@@ -17,8 +17,6 @@
import com.yammer.metrics.guice.InstrumentationModule;
import org.apache.shiro.guice.aop.ShiroAopModule;
-import com.google.inject.AbstractModule;
-
/**
* Nexus guice modules.
*
@@ -35,7 +33,6 @@
@Override
protected void configure() {
install(new ShiroAopModule());
- //install(new TimingModule());
install(new InstrumentationModule());
}
}
View
39 nexus-core/src/main/java/org/sonatype/nexus/timing/Timed.java
@@ -1,39 +0,0 @@
-/*
- * Sonatype Nexus (TM) Open Source Version
- * Copyright (c) 2007-2012 Sonatype, Inc.
- * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
- *
- * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
- * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
- * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
- * Eclipse Foundation. All other trademarks are the property of their respective owners.
- */
-package org.sonatype.nexus.timing;
-
-import javax.inject.Qualifier;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-/**
- * Marker for methods which should have timing details sampled.
- *
- * @since 2.4
- */
-@Qualifier
-@Target({METHOD})
-@Retention(RUNTIME)
-public @interface Timed
-{
- String DEFAULT_VALUE = "";
-
- /**
- * The name of the timing metric. If left as {@link #DEFAULT_VALUE} or a blank/empty string,
- * then a name will be determined from the aspect context around the method being woven.
- */
- String value() default DEFAULT_VALUE;
-}
View
104 nexus-core/src/main/java/org/sonatype/nexus/timing/TimedInterceptor.java
@@ -1,104 +0,0 @@
-/*
- * Sonatype Nexus (TM) Open Source Version
- * Copyright (c) 2007-2012 Sonatype, Inc.
- * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
- *
- * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
- * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
- * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
- * Eclipse Foundation. All other trademarks are the property of their respective owners.
- */
-package org.sonatype.nexus.timing;
-
-import org.aopalliance.intercept.MethodInterceptor;
-import org.aopalliance.intercept.MethodInvocation;
-import org.javasimon.SimonManager;
-import org.javasimon.Split;
-import org.javasimon.Stopwatch;
-import org.jsoup.helper.StringUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Marker;
-import org.slf4j.MarkerFactory;
-
-import java.lang.reflect.Method;
-
-/**
- * Handles {@link Timed} method invocation timing.
- *
- * @since 2.4
- */
-public class TimedInterceptor
- implements MethodInterceptor
-{
- private static final Marker TIMING = MarkerFactory.getMarker("TIMING");
-
- private static final Logger log = LoggerFactory.getLogger(TimedInterceptor.class);
-
- // TODO: Sort out javasimon configuration, JMX and callbacks to handling logging or not, etc.
- // TODO: Probably want to do all of this ^^^ in a helper class
-
- // TODO: Could potentially implement a simple cache here if we think perf of name calculation is too high
-
- /**
- * Construct name from a {@link MethodInvocation}. If {@link Timed#value()} is default/blank, then
- * a name will be constructed from the given {@link Method}.
- *
- * @see #nameOf(Method)
- */
- private String nameOf(final MethodInvocation invocation) {
- Method method = invocation.getMethod();
- Timed annotation = method.getAnnotation(Timed.class);
- String name = Timed.DEFAULT_VALUE;
-
- // This should not happen, as we only intercept methods which have @Timed on them, but just in-case
- if (annotation == null) {
- log.error("Missing @Timed annotation on method: {}", method);
- // will construct an automatic name
- }
- else {
- name = annotation.value();
- }
-
- // autodetect a name if needed
- if (StringUtil.isBlank(name)) {
- name = nameOf(method);
- }
-
- return name;
- }
-
- /**
- * Construct name from a {@link Method}.
- */
- private String nameOf(final Method method) {
- return String.format("%s.%s-%s",
- method.getDeclaringClass().getName(),
- method.getName(),
- method.getParameterTypes().length);
- }
-
- /**
- * Wrap method invocation with a Javasimon {@link Stopwatch} to capture timing metrics.
- */
- @Override
- public Object invoke(final MethodInvocation invocation) throws Throwable {
- String name = nameOf(invocation);
- log.trace("Timing invocation: [{}] {}", name, invocation.getMethod());
-
- // TODO: Sort out how best to use javasimon here for core + plugins, etc.
- Stopwatch watch = SimonManager.getStopwatch(name);
- Split split = watch.start();
- try {
- return invocation.proceed();
- }
- finally {
- split.stop();
-
- // TODO: Remove logging here and handle by a callback or only expose via JMX?
- log.trace(TIMING, "{}", watch);
- }
- }
-}
View
36 nexus-core/src/main/java/org/sonatype/nexus/timing/TimingModule.java
@@ -1,36 +0,0 @@
-/*
- * Sonatype Nexus (TM) Open Source Version
- * Copyright (c) 2007-2012 Sonatype, Inc.
- * All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
- *
- * This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
- * which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
- * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
- * Eclipse Foundation. All other trademarks are the property of their respective owners.
- */
-package org.sonatype.nexus.timing;
-
-import javax.inject.Named;
-
-import org.sonatype.nexus.guice.AbstractInterceptorModule;
-
-import com.google.inject.matcher.Matchers;
-
-/**
- * Adds support for {@link Timed} method invocations.
- *
- * @see TimedInterceptor
- *
- * @since 2.4
- */
-@Named
-public class TimingModule
- extends AbstractInterceptorModule
-{
- @Override
- protected void configure() {
- bindInterceptor(Matchers.any(), Matchers.annotatedWith(Timed.class), new TimedInterceptor());
- }
-}
View
2 ...siesta-test-plugin/src/main/java/org/sonatype/nexus/plugins/siesta/test/TestResource.java
@@ -12,11 +12,11 @@
*/
package org.sonatype.nexus.plugins.siesta.test;
+import com.yammer.metrics.annotation.Timed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.nexus.configuration.application.ApplicationConfiguration;
import org.sonatype.nexus.plugins.siesta.test.model.UserXO;
-import org.sonatype.nexus.timing.Timed;
import org.sonatype.sisu.siesta.common.Resource;
import org.apache.shiro.authz.annotation.RequiresPermissions;

0 comments on commit c4e5446

Please sign in to comment.