cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r600283 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne: gen/ tools/
Date Sun, 02 Dec 2007 13:14:48 GMT
Author: aadamchik
Date: Sun Dec  2 05:14:48 2007
New Revision: 600283

URL: http://svn.apache.org/viewvc?rev=600283&view=rev
Log:
CAY-926 Refactoring class generator classes
(making AntClassgenerator non-public)

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/AntClassGenerator.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/AntClassGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerator.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/AntClassGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/AntClassGenerator.java?rev=600283&r1=600282&r2=600283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/AntClassGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/AntClassGenerator.java
Sun Dec  2 05:14:48 2007
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.gen;
 
 import java.io.File;
@@ -25,33 +24,31 @@
 import org.apache.tools.ant.Task;
 
 /**
- * Ant-specific extension of DefaultClassGenerator that provides logging
- * functions.
+ * Ant-specific extension of DefaultClassGenerator that provides logging functions.
  * 
  * @author Andrus Adamchik
+ * @deprecated since 3.0 this class is replaced with a non-public class in the tools
+ *             package.
  */
 public class AntClassGenerator extends DefaultClassGenerator {
 
     protected Task parentTask;
 
-    protected File fileForSuperclass(String pkgName, String className)
-            throws Exception {
+    protected File fileForSuperclass(String pkgName, String className) throws Exception {
 
         File outFile = super.fileForSuperclass(pkgName, className);
         if (outFile != null) {
             parentTask.log("Generating superclass file: " + outFile.getCanonicalPath());
         }
-        
+
         return outFile;
     }
 
-    protected File fileForClass(String pkgName, String className)
-            throws Exception {
+    protected File fileForClass(String pkgName, String className) throws Exception {
 
         File outFile = super.fileForClass(pkgName, className);
         if (outFile != null) {
-            parentTask.log("Generating class file: "
-                    + outFile.getCanonicalPath());
+            parentTask.log("Generating class file: " + outFile.getCanonicalPath());
         }
         return outFile;
     }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerator.java?rev=600283&r1=600282&r2=600283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerator.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGenerator.java
Sun Dec  2 05:14:48 2007
@@ -63,7 +63,7 @@
     public ClassGenerator(String template, String versionString) throws Exception {
         this.versionString = versionString;
 
-        if (false == VERSION_1_1.equals(versionString)) {
+        if (!VERSION_1_1.equals(versionString)) {
             throw new IllegalStateException(
                     "Illegal Version in generateClass(Writer,ObjEntity): "
                             + versionString);
@@ -146,7 +146,8 @@
      * Generates Java code for the ObjEntity. Output is written to the provided Writer.
      */
     public void generateClass(Writer out, ObjEntity entity) throws Exception {
-        if (false == VERSION_1_1.equals(versionString)) {
+        
+        if (!VERSION_1_1.equals(versionString)) {
             throw new IllegalStateException(
                     "Illegal Version in generateClass(Writer,ObjEntity): "
                             + versionString);
@@ -166,7 +167,8 @@
             String fqnBaseClass,
             String fqnSuperClass,
             String fqnSubClass) throws Exception {
-        if (false == VERSION_1_2.equals(versionString)) {
+        
+        if (!VERSION_1_2.equals(versionString)) {
             throw new IllegalStateException(
                     "Illegal Version in generateClass(Writer,ObjEntity,String,String,String):
"
                             + versionString);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java?rev=600283&r1=600282&r2=600283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/gen/ClassGeneratorResourceLoader.java
Sun Dec  2 05:14:48 2007
@@ -35,6 +35,8 @@
  * @since 1.2
  * @author Andrus Adamchik
  */
+// must be public top-level class as it is
+// instantiated via reflection by Velocity
 public class ClassGeneratorResourceLoader extends FileResourceLoader {
 
     /**

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/AntClassGenerator.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/AntClassGenerator.java?rev=600283&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/AntClassGenerator.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/AntClassGenerator.java
Sun Dec  2 05:14:48 2007
@@ -0,0 +1,67 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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 org.apache.cayenne.tools;
+
+import java.io.File;
+
+import org.apache.cayenne.gen.DefaultClassGenerator;
+import org.apache.tools.ant.Task;
+
+/**
+ * Ant-specific extension of the class generation controller.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+class AntClassGenerator extends DefaultClassGenerator {
+
+    private Task parentTask;
+
+    protected File fileForSuperclass(String pkgName, String className) throws Exception {
+
+        File outFile = super.fileForSuperclass(pkgName, className);
+        if (outFile != null) {
+            parentTask.log("Generating superclass file: " + outFile.getCanonicalPath());
+        }
+
+        return outFile;
+    }
+
+    protected File fileForClass(String pkgName, String className) throws Exception {
+
+        File outFile = super.fileForClass(pkgName, className);
+        if (outFile != null) {
+            parentTask.log("Generating class file: " + outFile.getCanonicalPath());
+        }
+        return outFile;
+    }
+
+    Task getParentTask() {
+        return parentTask;
+    }
+
+    /**
+     * Sets the Ant task that uses this generator.
+     * 
+     * @param parentTask An Ant task that provides Ant context to this generator.
+     */
+    void setParentTask(Task parentTask) {
+        this.parentTask = parentTask;
+    }
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java?rev=600283&r1=600282&r2=600283&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/tools/CayenneGeneratorTask.java
Sun Dec  2 05:14:48 2007
@@ -20,7 +20,6 @@
 
 import java.io.File;
 
-import org.apache.cayenne.gen.AntClassGenerator;
 import org.apache.cayenne.gen.ClassGenerator;
 import org.apache.cayenne.gen.DefaultClassGenerator;
 import org.apache.tools.ant.BuildException;
@@ -66,7 +65,7 @@
         validateAttributes();
 
         // Take care of setting up VPP for the generator.
-        if (false == ClassGenerator.VERSION_1_1.equals(generator.getVersionString())) {
+        if (!ClassGenerator.VERSION_1_1.equals(generator.getVersionString())) {
             initializeVppConfig();
             generator.setVppConfig(vppConfig);
         }
@@ -88,7 +87,7 @@
     }
 
     /**
-     * Validates atttributes that are not related to internal DefaultClassGenerator.
+     * Validates attributes that are not related to internal DefaultClassGenerator.
      * Throws BuildException if attributes are invalid.
      */
     protected void validateAttributes() throws BuildException {



Mime
View raw message