openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r618745 - /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
Date Tue, 05 Feb 2008 18:58:11 GMT
Author: mikedd
Date: Tue Feb  5 10:58:09 2008
New Revision: 618745

URL: http://svn.apache.org/viewvc?rev=618745&view=rev
Log:
OPENJPA-401 making temporary classloader optional for MappingTool ant task

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java?rev=618745&r1=618744&r2=618745&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
Tue Feb  5 10:58:09 2008
@@ -49,6 +49,7 @@
  * <li><code>file</code></li>
  * <li><code>schemaFile</code></li>
  * <li><code>sqlFile</code></li>
+ * <li><code>tmpClassLoader</code></li>
  * </ul> Of these arguments, only <code>action</code> is required.
  */
 public class MappingToolTask
@@ -61,6 +62,7 @@
     protected String file = null;
     protected String schemaFile = null;
     protected String sqlFile = null;
+    protected boolean tmpClassLoader = true;
 
     /**
      * Set the enumerated MappingTool action type.
@@ -176,21 +178,27 @@
         if (MappingTool.ACTION_IMPORT.equals(flags.action))
             assertFiles(files);
 
-        ClassLoader loader =
-            (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper
+        ClassLoader toolLoader = (ClassLoader) AccessController
+                .doPrivileged(J2DoPrivHelper
+                        .getClassLoaderAction(MappingTool.class));
+        ClassLoader loader = toolLoader;
+        MultiLoaderClassResolver resolver = new MultiLoaderClassResolver();
+
+        if (tmpClassLoader) {
+            loader = (ClassLoader) AccessController.doPrivileged(J2DoPrivHelper
                     .newTemporaryClassLoaderAction(getClassLoader()));
-        
+            resolver.addClassLoader(loader);
+        }
+        resolver.addClassLoader(toolLoader);
+            
         if (flags.meta && MappingTool.ACTION_ADD.equals(flags.action))
             flags.metaDataFile = Files.getFile(file, loader);
         else
             flags.mappingWriter = Files.getWriter(file, loader);
+
         flags.schemaWriter = Files.getWriter(schemaFile, loader);
         flags.sqlWriter = Files.getWriter(sqlFile, loader);
 
-        MultiLoaderClassResolver resolver = new MultiLoaderClassResolver();
-        resolver.addClassLoader(loader);
-        resolver.addClassLoader((ClassLoader) AccessController.doPrivileged(
-            J2DoPrivHelper.getClassLoaderAction(MappingTool.class)));
         JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
         conf.setClassResolver(resolver);
         
@@ -217,6 +225,19 @@
             actions[actions.length - 1] = "none";
             return actions;
         }
+    }
+
+    /**
+     * <P>
+     * Set whether a temporary ClassLoader should be used by the MappingTool.
+     * The default value is true
+     * </P>
+     * 
+     * @param tmpClassLoader
+     *            Whether the temporary ClassLoader should be used.
+     */
+    public void setTmpClassLoader(boolean tmpClassLoader) {
+        this.tmpClassLoader = tmpClassLoader;
     }
 }
 



Mime
View raw message