openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1091279 - in /openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src: main/java/org/apache/openjpa/tools/maven/ test/java/org/apache/openjpa/tools/maven/
Date Tue, 12 Apr 2011 03:17:17 GMT
Author: mikedd
Date: Tue Apr 12 03:17:16 2011
New Revision: 1091279

URL: http://svn.apache.org/viewvc?rev=1091279&view=rev
Log:
OPENJPA-1934: Cleanup compiler warnings.

Modified:
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
    openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java

Modified: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java?rev=1091279&r1=1091278&r2=1091279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
(original)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaEnhancerMojo.java
Tue Apr 12 03:17:16 2011
@@ -26,6 +26,7 @@ import org.codehaus.plexus.util.FileUtil
 import org.apache.openjpa.enhance.PCEnhancer;
 import org.apache.openjpa.lib.util.Options;
 
+import java.io.File;
 import java.util.List;
 
 /**
@@ -89,7 +90,7 @@ public abstract class AbstractOpenJpaEnh
             FileUtils.mkdir(getEntityClasses().getAbsolutePath());
         }
 
-        List entities = findEntityClassFiles();
+        List<File> entities = findEntityClassFiles();
 
         enhance(entities);
     }
@@ -117,7 +118,7 @@ public abstract class AbstractOpenJpaEnh
      * @param files class file resources to enhance.
      * @throws MojoExecutionException if the enhancer encountered a failure
      */
-    private void enhance(List files) throws MojoExecutionException {
+    private void enhance(List<File> files) throws MojoExecutionException {
         Options opts = getOptions();
 
         // list of input files

Modified: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java?rev=1091279&r1=1091278&r2=1091279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
(original)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMappingToolMojo.java
Tue Apr 12 03:17:16 2011
@@ -19,10 +19,15 @@
 package org.apache.openjpa.tools.maven;
 
 
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.List;
+
+import javax.persistence.Entity;
+
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.FileUtils;
-
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
@@ -31,14 +36,7 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.meta.MetaDataRepository;
-
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.persistence.Entity;
+import org.codehaus.plexus.util.FileUtils;
 
 /**
  * Processes Application model classes and generate the DDL by running the 
@@ -78,7 +76,7 @@ public abstract class AbstractOpenJpaMap
             FileUtils.mkdir(getEntityClasses().getAbsolutePath());
         }
 
-        List entities = findEntityClassFiles();
+        List<File> entities = findEntityClassFiles();
 
         mappingTool(entities);
     }
@@ -90,7 +88,7 @@ public abstract class AbstractOpenJpaMap
      * @param files class file resources to map.
      * @throws MojoExecutionException if the MappingTool detected an error
      */
-    private void mappingTool(List files) throws MojoExecutionException {
+    private void mappingTool(List<File> files) throws MojoExecutionException {
         extendRealmClasspath();
 
         Options opts = getOptions();
@@ -126,23 +124,20 @@ public abstract class AbstractOpenJpaMap
      * @param files List with classPath Files; non persistence classes will be removed
      * @param opts  filled configuration Options
      */
-    private void filterPersistenceCapable(List files, Options opts) {
+    private void filterPersistenceCapable(List<File> files, Options opts) {
         JDBCConfiguration conf = new JDBCConfigurationImpl();
         Configurations.populateConfiguration(conf, opts);
         MetaDataRepository repo = conf.newMetaDataRepositoryInstance();
         ClassArgParser cap = repo.getMetaDataFactory().newClassArgParser();
 
-        Iterator fileIt = files.iterator();
-        while (fileIt.hasNext()) {
-            File classPath = (File) fileIt.next();
-
-            Class[] classes = cap.parseTypes(classPath.getAbsolutePath());
+        for(File classPath : files) { 
+            Class<?>[] classes = cap.parseTypes(classPath.getAbsolutePath());
 
             if (classes == null) {
                 getLog().info("Found no classes for " + classPath.getAbsolutePath());
             } else {
                 for (int i = 0; i < classes.length; i++) {
-                    Class cls = classes[i];
+                    Class<?> cls = classes[i];
 
                     if (cls.getAnnotation(Entity.class) != null) {
                         getLog().debug("Found @Entity in class " + classPath);
@@ -151,7 +146,6 @@ public abstract class AbstractOpenJpaMap
                                 + PersistenceCapable.class.getName());
                     } else {
                         getLog().debug("Removing non-entity class " + classPath);
-                        fileIt.remove();
                     }
                 }
             }
@@ -163,9 +157,9 @@ public abstract class AbstractOpenJpaMap
      * @param cls the Class to check
      * @return <code>true</code> if the given Class cls implements the interface
{@link PersistenceCapable}
      */
-    private boolean implementsPersistenceCapable(Class cls) {
+    private boolean implementsPersistenceCapable(Class<?> cls) {
         boolean isPersistenceCapable = false;
-        Class[] interfaces = cls.getInterfaces();
+        Class<?>[] interfaces = cls.getInterfaces();
         for (int i = 0; i < interfaces.length; i++) {
             if (interfaces[i].getName().equals(PersistenceCapable.class.getName())) {
                 isPersistenceCapable = true;

Modified: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java?rev=1091279&r1=1091278&r2=1091279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
(original)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/AbstractOpenJpaMojo.java
Tue Apr 12 03:17:16 2011
@@ -25,16 +25,14 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.FileUtils;
-
 import org.apache.openjpa.lib.util.Options;
+import org.codehaus.plexus.util.FileUtils;
 
 /**
  * Base class for  OpenJPA maven tasks.
@@ -141,7 +139,7 @@ public abstract class AbstractOpenJpaMoj
      * @required
      * @readonly
      */
-    protected List compileClasspathElements;
+    protected List<String> compileClasspathElements;
     
     /**
      * Setting this parameter to <code>true</code> will force
@@ -199,7 +197,7 @@ public abstract class AbstractOpenJpaMoj
      * This function retrieves the injected classpath elements for the current mojo.
      * @return List of classpath elements for the compile phase
      */
-    protected List getClasspathElements() 
+    protected List<String> getClasspathElements() 
     {
         return compileClasspathElements;
     }
@@ -278,11 +276,10 @@ public abstract class AbstractOpenJpaMoj
     protected void extendRealmClasspath() 
         throws MojoExecutionException 
     { 
-        List urls = new ArrayList();
+        List<URL> urls = new ArrayList<URL>();
 
-        for ( Iterator itor = getClasspathElements().iterator(); itor.hasNext(); )
-        {
-            File pathElem = new File( (String) itor.next() );
+        for(String fileName: getClasspathElements()) { 
+            File pathElem = new File(fileName);
             try
             {
                 URL url = pathElem.toURI().toURL();
@@ -310,13 +307,13 @@ public abstract class AbstractOpenJpaMoj
      * @throws MojoExecutionException if there was an error scanning class file
      *             resources.
      */
-    protected List findEntityClassFiles() throws MojoExecutionException 
+    protected List<File> findEntityClassFiles() throws MojoExecutionException 
     {
-        List files = new ArrayList();
+        List<File> files = new ArrayList<File>();
     
         try
         {
-            files = FileUtils.getFiles( getEntityClasses(), includes, excludes );
+            files = (List<File>) FileUtils.getFiles( getEntityClasses(), includes,
excludes );
         }
         catch ( IOException e )
         {
@@ -331,12 +328,12 @@ public abstract class AbstractOpenJpaMoj
      * @param files List of files
      * @return the paths of the given files as String[]
      */
-    protected String[] getFilePaths( List files ) 
+    protected String[] getFilePaths( List<File> files ) 
     {
         String[] args = new String[ files.size() ];
         for ( int i = 0; i < files.size(); i++ )
         {
-            File file = (File) files.get( i );
+            File file = files.get( i );
     
             args[ i ] = file.getAbsolutePath();
         }

Modified: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java?rev=1091279&r1=1091278&r2=1091279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
(original)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/main/java/org/apache/openjpa/tools/maven/OpenJpaTestEnhancerMojo.java
Tue Apr 12 03:17:16 2011
@@ -43,7 +43,7 @@ public class OpenJpaTestEnhancerMojo ext
      * @required
      * @readonly
      */
-    protected List testClasspathElements;
+    protected List<String> testClasspathElements;
 
     /**
      * This is where compiled test classes go.
@@ -70,7 +70,7 @@ public class OpenJpaTestEnhancerMojo ext
      *
      * @return List of classpath elements for the test phase
      */
-    protected List getClasspathElements() {
+    protected List<String> getClasspathElements() {
         return testClasspathElements;
     }
 

Modified: openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java?rev=1091279&r1=1091278&r2=1091279&view=diff
==============================================================================
--- openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java
(original)
+++ openjpa/trunk/openjpa-tools/openjpa-maven-plugin/src/test/java/org/apache/openjpa/tools/maven/OpenJpaEnhancerMojoTest.java
Tue Apr 12 03:17:16 2011
@@ -42,7 +42,7 @@ public class OpenJpaEnhancerMojoTest ext
       assertNotNull( mojo );
       
       mojo.classes = new File( getBasedir(), "target/test-classes/" );
-      mojo.compileClasspathElements = new ArrayList();
+      mojo.compileClasspathElements = new ArrayList<String>();
       mojo.compileClasspathElements.add( mojo.classes.getAbsolutePath() );
       
       mojo.execute();



Mime
View raw message