tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject svn commit: r766299 - in /openejb/trunk/sandbox/openejb-eclipse-plugin: common/src/main/java/org/apache/openejb/plugins/common/ common/src/test/java/org/apache/openejb/plugins/common/ plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/op...
Date Sat, 18 Apr 2009 10:59:52 GMT
Author: jgallimore
Date: Sat Apr 18 10:59:52 2009
New Revision: 766299

URL: http://svn.apache.org/viewvc?rev=766299&view=rev
Log:
OEP-26 don't create annotations that already exist on methods and fields

Modified:
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
    openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/openejb/devtools/core/JDTFacade.java

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java?rev=766299&r1=766298&r2=766299&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
(original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/main/java/org/apache/openejb/plugins/common/IJDTFacade.java
Sat Apr 18 10:59:52 2009
@@ -23,8 +23,8 @@
 
 public interface IJDTFacade {
 	void addClassAnnotation(String targetClass, Class<? extends Annotation> annotation,
Map<String,Object> properties);
-	void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[] signature,
Class<?> annotationClass, Map<String, Object> properties);
-	void addFieldAnnotation(String targetClass, String targetField, Class<?> annotation,
Map<String, Object> properties);
+	void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[] signature,
Class<? extends Annotation> annotationClass, Map<String, Object> properties);
+	void addFieldAnnotation(String targetClass, String targetField, Class<? extends Annotation>
annotation, Map<String, Object> properties);
 	void removeInterface(String targetClass, String interfaceToRemove);
 	void removeAbstractModifierFromClass(String targetClass);
 	void removeAbstractModifierFromMethod(String targetClass, String methodName, String[] signature,
String methodBody);
@@ -32,7 +32,7 @@
 	boolean classImplements(String targetClass, String targetInterface);
 	String getMethodReturnType(String targetClass, String methodName, String[] signature);
 	void addField(String targetClass, String fieldName, String fieldType);
-	void addAnnotationToFieldsOfType(String targetClass, Class<?> annotation, Map<String,
Object> properties);
+	void addAnnotationToFieldsOfType(String targetClass, Class<? extends Annotation> annotation,
Map<String, Object> properties);
 	void addInterface(String ejbClass, String interfaceClass);
 	void addWarning(String warning);
 	public void convertMethodToConstructor(String className, String methodName, String[] signature);

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java?rev=766299&r1=766298&r2=766299&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
(original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/common/src/test/java/org/apache/openejb/plugins/common/JDTFacadeStub.java
Sat Apr 18 10:59:52 2009
@@ -24,7 +24,7 @@
 
 public class JDTFacadeStub implements IJDTFacade {
 
-	public void addAnnotationToFieldsOfType(String targetClass, Class<?> annotation, Map<String,
Object> properties) {
+	public void addAnnotationToFieldsOfType(String targetClass, Class<? extends Annotation>
annotation, Map<String, Object> properties) {
 		StringBuffer buffer = new StringBuffer();
 		buffer.append("[ADD ANNOTATIONS TO FIELDS OF TYPE] Target field type: ");
 		buffer.append(targetClass);
@@ -104,7 +104,7 @@
 		System.out.println(buffer.toString());
 	}
 
-	public void addFieldAnnotation(String targetClass, String targetField, Class<?> annotation,
Map<String, Object> properties) {
+	public void addFieldAnnotation(String targetClass, String targetField, Class<? extends
Annotation> annotation, Map<String, Object> properties) {
 		StringBuffer buffer = new StringBuffer();
 		buffer.append("[ADD FIELD ANNOTATION] Target field type: ");
 		buffer.append(targetClass);
@@ -124,7 +124,7 @@
 
 	}
 
-	public void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[]
signature, Class<?> annotationClass, Map<String, Object> properties) {
+	public void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[]
signature, Class<? extends Annotation> annotationClass, Map<String, Object> properties)
{
 		StringBuffer buffer = new StringBuffer();
 		buffer.append("[ADD METHOD ANNOTATION] Target field type: ");
 		buffer.append(fullyQualifiedClassName);

Modified: openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/openejb/devtools/core/JDTFacade.java
URL: http://svn.apache.org/viewvc/openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/openejb/devtools/core/JDTFacade.java?rev=766299&r1=766298&r2=766299&view=diff
==============================================================================
--- openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/openejb/devtools/core/JDTFacade.java
(original)
+++ openejb/trunk/sandbox/openejb-eclipse-plugin/plugins/org.apache.openejb.devtools.core/src/main/java/org/apache/openejb/devtools/core/JDTFacade.java
Sat Apr 18 10:59:52 2009
@@ -319,13 +319,19 @@
 		return expression;
 	}
 
-	public void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[]
signature, Class<?> annotationClass, Map<String, Object> properties) {
+	public void addMethodAnnotation(String fullyQualifiedClassName, String methodName, String[]
signature, Class<? extends java.lang.annotation.Annotation> annotationClass, Map<String,
Object> properties) {
 		try {
 			CompilationUnit cu = compilationUnitCache.getCompilationUnit(fullyQualifiedClassName);
 			MethodDeclaration method = compilationUnitCache.getMethodDeclaration(fullyQualifiedClassName,
methodName, signature);
 			if (method == null) {
 				return;
 			}
+			
+			if (isAnnotationAlreadyUsedOnDeclaration(annotationClass, method)) {
+				warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"),
annotationClass.getCanonicalName(), fullyQualifiedClassName + "." + methodName)); //$NON-NLS-1$
+				return;
+			}
+			
 			Annotation modifier = createModifier(cu.getAST(), annotationClass, properties, cu);
 			method.modifiers().add(0, modifier);
 
@@ -349,7 +355,7 @@
 
 	
 
-	public void addFieldAnnotation(String targetClass, String targetField, Class<?> annotation,
Map<String, Object> properties) {
+	public void addFieldAnnotation(String targetClass, String targetField, Class<? extends
java.lang.annotation.Annotation> annotation, Map<String, Object> properties) {
 		try {
 			CompilationUnit cu = compilationUnitCache.getCompilationUnit(targetClass);
 
@@ -363,6 +369,12 @@
 					continue;
 				}
 
+				if (isAnnotationAlreadyUsedOnDeclaration(annotation, field)) {
+					warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.1"),
annotation.getCanonicalName(), targetClass + "." + targetField)); //$NON-NLS-1$
+					return;
+				}
+
+				
 				VariableDeclarationFragment varibleDeclaration = (VariableDeclarationFragment) field.fragments().get(0);
 				if (varibleDeclaration.getName().toString().equals(targetField)) {
 					Annotation modifier = createModifier(cu.getAST(), annotation, properties, cu);
@@ -525,7 +537,7 @@
 
 	}
 
-	public void addAnnotationToFieldsOfType(String targetClass, Class<?> annotation, Map<String,
Object> properties) {
+	public void addAnnotationToFieldsOfType(String targetClass, Class<? extends java.lang.annotation.Annotation>
annotation, Map<String, Object> properties) {
 		try {
 			IType element = javaProject.findType(targetClass);
 



Mime
View raw message