Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

METRICS-2777: Modify Spring plugins endpoint analyzers to support @Co…

  • Loading branch information...
commit f4615f5869cc0e3bf0f218f1449ceb78ebc85c78 1 parent d7d1a58
@lgoldstein lgoldstein authored
View
29 ...ore/src/main/java/com/springsource/insight/plugin/springcore/ComponentMethodOperationCollectionAspect.aj
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2009-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.springsource.insight.plugin.springcore;
+
+import com.springsource.insight.collection.method.MethodOperationsCollected;
+
+import org.springframework.stereotype.Component;
+
+/**
+ * Causes all {@link Component} annotated classes to be instrumented
+ */
+public aspect ComponentMethodOperationCollectionAspect {
+ declare @type: @Component * : @MethodOperationsCollected;
+
+}
View
3  ...re/src/main/java/com/springsource/insight/plugin/springcore/RepositoryMethodOperationCollectionAspect.aj
@@ -20,6 +20,9 @@ import com.springsource.insight.collection.method.MethodOperationsCollected;
import org.springframework.stereotype.Repository;
+/**
+ * Causes all {@link Repository} annotated classes to be instrumented
+ */
public aspect RepositoryMethodOperationCollectionAspect {
declare @type: @Repository * : @MethodOperationsCollected;
}
View
3  ...-core/src/main/java/com/springsource/insight/plugin/springcore/ServiceMethodOperationCollectionAspect.aj
@@ -20,6 +20,9 @@ import org.springframework.stereotype.Service;
import com.springsource.insight.collection.method.MethodOperationsCollected;
+/**
+ * Causes all {@link Service} annotated classes to be instrumented
+ */
public aspect ServiceMethodOperationCollectionAspect {
declare @type: @Service * : @MethodOperationsCollected;
}
View
33 ...java/com/springsource/insight/plugin/springcore/AnnotationDrivenMethodOperationCollectionAspectTest.java
@@ -16,28 +16,41 @@
package com.springsource.insight.plugin.springcore;
+import org.junit.Assert;
import org.junit.Test;
+import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
-import static org.junit.Assert.*;
-
import com.springsource.insight.collection.method.MethodOperationsCollected;
-public class AnnotationDrivenMethodOperationCollectionAspectTest {
+public class AnnotationDrivenMethodOperationCollectionAspectTest extends Assert {
+ public AnnotationDrivenMethodOperationCollectionAspectTest () {
+ super();
+ }
@Test
public void methodOperationsCollectedAnnotationAppliedCorrectly() {
- Class<ExampleRepositoryThatIsAlsoService> exampleDualClass = ExampleRepositoryThatIsAlsoService.class;
- assertTrue(exampleDualClass.isAnnotationPresent(MethodOperationsCollected.class));
+ for (Class<?> testClass : new Class[] {
+ ExampleComponent.class,
+ ExampleService.class,
+ ExampleRepository.class,
+ ExampleRepositoryThatIsAlsoService.class }) {
+ assertIsMethodOperationsCollected(testClass);
+ }
+ }
- Class<ExampleService> exampleServiceClass = ExampleService.class;
- assertTrue(exampleServiceClass.isAnnotationPresent(MethodOperationsCollected.class));
+ private static void assertIsMethodOperationsCollected (Class<?> clazz) {
+ assertTrue(clazz.getSimpleName() + " not annotated", clazz.isAnnotationPresent(MethodOperationsCollected.class));
+ }
- Class<ExampleRepository> exampleRepositoryClass = ExampleRepository.class;
- assertTrue(exampleRepositoryClass.isAnnotationPresent(MethodOperationsCollected.class));
+ @Component
+ private static class ExampleComponent {
+ public void doIt () {
+ // do nothing
+ }
}
-
+
@Service
private static class ExampleService {
public void service() {
Please sign in to comment.
Something went wrong with that request. Please try again.