db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1148410 - in /db/torque/torque4/trunk/torque-templates/src/main: java/org/apache/torque/templates/transformer/om/ resources/org/apache/torque/templates/om/outlets/ resources/org/apache/torque/templates/om/templates/dbObject/base/bean/ reso...
Date Tue, 19 Jul 2011 15:45:56 GMT
Author: tfischer
Date: Tue Jul 19 15:45:53 2011
New Revision: 1148410

URL: http://svn.apache.org/viewvc?rev=1148410&view=rev
Log:
TORQUE-166: remove the getOMClass() method, the CLASS_DEFAULT constant and the initClass()
method in the generated peers
and generate new getDbObjectInstance() method instead

Added:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getDbObjectInstance.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/inheritanceClasskeyConstants.vm
      - copied, changed from r1103197, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getDbObjectInstance.vm
Removed:
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/classMethods.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getOMClass.vm
Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/InheritanceAttributeName.java
Tue Jul 19 15:45:53 2011
@@ -34,18 +34,6 @@ public enum InheritanceAttributeName imp
     CLASSKEY_CONSTANT("classkeyConstant"),
 
     /**
-     * The name of the constant in the peer which contains the name
-     * for the processed inheritance class.
-     */
-    CLASSNAME_CONSTANT("classnameConstant"),
-
-    /**
-     * The name of the constant in the peer which contains the class object
-     * for the processed inheritance class.
-     */
-    CLASS_CONSTANT("classConstant"),
-
-    /**
      * The name of the class created from this inheritance element.
      */
     CLASS_NAME("className"),

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMInheritanceTransformer.java
Tue Jul 19 15:45:53 2011
@@ -54,12 +54,6 @@ public class OMInheritanceTransformer
         inheritanceElement.setAttribute(
                 InheritanceAttributeName.CLASSKEY_CONSTANT,
                 "CLASSKEY_" + key.toUpperCase());
-        inheritanceElement.setAttribute(
-                InheritanceAttributeName.CLASSNAME_CONSTANT,
-                "CLASSNAME_" + key.toUpperCase());
-        inheritanceElement.setAttribute(
-                InheritanceAttributeName.CLASS_CONSTANT,
-                "CLASS_" + key.toUpperCase());
 
         SourceElement tableElement
                 = inheritanceElement.getParent().getParent();

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
Tue Jul 19 15:45:53 2011
@@ -88,8 +88,8 @@
     <mergepoint name="doSelect">
       <action xsi:type="applyAction" outlet="torque.om.peer.impl.base.doSelect"/>
     </mergepoint>
-    <mergepoint name="getOMClass">
-      <action xsi:type="applyAction" outlet="torque.om.peer.impl.base.getOMClass"/>
+    <mergepoint name="getDbObjectInstance">
+      <action xsi:type="applyAction" outlet="torque.om.peer.impl.base.getDbObjectInstance"/>
     </mergepoint>
     <mergepoint name="doUpdate">
       <action xsi:type="applyAction" outlet="torque.om.peer.impl.base.doUpdate"/>
@@ -188,9 +188,9 @@
       path="peer/impl/base/doSelect.vm">
   </outlet>
 
-  <outlet name="torque.om.peer.impl.base.getOMClass"
+  <outlet name="torque.om.peer.impl.base.getDbObjectInstance"
       xsi:type="velocityOutlet"
-      path="peer/impl/base/getOMClass.vm">
+      path="peer/impl/base/getDbObjectInstance.vm">
   </outlet>
 
   <outlet name="torque.om.peer.impl.base.doUpdate"
@@ -307,11 +307,8 @@
     <mergepoint name="numColumnConstant">
       <action xsi:type="applyAction" outlet="torque.om.peer.base.numColumnConstant"/>
     </mergepoint>
-    <mergepoint name="dbObjectClassConstants">
-      <action xsi:type="applyAction" outlet="torque.om.peer.base.dbObjectClassConstants"/>
-    </mergepoint>
-    <mergepoint name="classMethods">
-      <action xsi:type="applyAction" outlet="torque.om.peer.base.classMethods"/>
+    <mergepoint name="inheritanceClasskeyConstants">
+      <action xsi:type="applyAction" outlet="torque.om.peer.base.inheritanceClasskeyConstants"/>
     </mergepoint>
     <mergepoint name="resultSet2Objects">
       <action xsi:type="applyAction" outlet="torque.om.peer.base.resultSet2Objects"/>
@@ -328,8 +325,8 @@
     <mergepoint name="doSelect">
       <action xsi:type="applyAction" outlet="torque.om.peer.base.doSelect"/>
     </mergepoint>
-    <mergepoint name="getOMClass">
-      <action xsi:type="applyAction" outlet="torque.om.peer.base.getOMClass"/>
+    <mergepoint name="getDbObjectInstance">
+      <action xsi:type="applyAction" outlet="torque.om.peer.base.getDbObjectInstance"/>
     </mergepoint>
     <mergepoint name="doUpdate">
       <action xsi:type="applyAction" outlet="torque.om.peer.base.doUpdate"/>
@@ -467,14 +464,9 @@
       path="peer/base/numColumnConstant.vm">
   </outlet>
 
-  <outlet name="torque.om.peer.base.dbObjectClassConstants"
-      xsi:type="velocityOutlet"
-      path="peer/base/dbObjectClassConstants.vm">
-  </outlet>
-
-  <outlet name="torque.om.peer.base.classMethods"
+  <outlet name="torque.om.peer.base.inheritanceClasskeyConstants"
       xsi:type="velocityOutlet"
-      path="peer/base/classMethods.vm">
+      path="peer/base/inheritanceClasskeyConstants.vm">
   </outlet>
 
   <outlet name="torque.om.peer.base.resultSet2Objects"
@@ -502,9 +494,9 @@
       path="peer/base/doSelect.vm">
   </outlet>
 
-  <outlet name="torque.om.peer.base.getOMClass"
+  <outlet name="torque.om.peer.base.getDbObjectInstance"
       xsi:type="velocityOutlet"
-      path="peer/base/getOMClass.vm">
+      path="peer/base/getDbObjectInstance.vm">
   </outlet>
 
   <outlet name="torque.om.peer.base.doUpdate"

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
Tue Jul 19 15:45:53 2011
@@ -156,18 +156,7 @@
             return result;
         }
 #if ($abstract == "true")
-        try
-        {
-            result = ($javaName) ${peerClassName}.getOMClass().newInstance();
-        }
-        catch (InstantiationException e)
-        {
-            throw new TorqueException(e);
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new TorqueException(e);
-        }
+        result = ${peerClassName}.getDbObjectInstance();
 #else
         result = new ${javaName}();
 #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm
Tue Jul 19 15:45:53 2011
@@ -28,19 +28,7 @@
 ## OmTransformer 
 ##
 #if ($abstract == "true")
-        $dbObjectClassName $field;
-        try
-        {
-            $field = ($dbObjectClassName) ${peerClassName}.getOMClass().newInstance();
-        }
-        catch (InstantiationException e)
-        {
-            throw new TorqueException(e);
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new TorqueException(e);
-        }
+        $dbObjectClassName $field = ${peerClassName}.getDbObjectInstance();
 #else
         $dbObjectClassName $field = new ${dbObjectClassName}();
 #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
Tue Jul 19 15:45:53 2011
@@ -42,19 +42,18 @@ $torqueGen.mergepoint("serialVersionUid"
 $torqueGen.mergepoint("tableDatabaseNameConstants")
 $torqueGen.mergepoint("columnConstants")
 $torqueGen.mergepoint("numColumnConstant")
-$torqueGen.mergepoint("dbObjectClassConstants")
+$torqueGen.mergepoint("inheritanceClasskeyConstants")
 $torqueGen.mergepoint("peerImplField")
 $torqueGen.mergepoint("staticInit")
 $torqueGen.mergepoint("peerImplCreator")
 $torqueGen.mergepoint("peerImplGetter")
 $torqueGen.mergepoint("peerImplSetter")
 $torqueGen.mergepoint("mapBuilderGetter")
-$torqueGen.mergepoint("classMethods")
 $torqueGen.mergepoint("resultSet2Objects")
 $torqueGen.mergepoint("addSelectColumns")
 $torqueGen.mergepoint("correctBooleans")
 $torqueGen.mergepoint("doSelect")
-$torqueGen.mergepoint("getOMClass")
+$torqueGen.mergepoint("getDbObjectInstance")
 $torqueGen.mergepoint("doInsert")
 $torqueGen.mergepoint("doUpdate")
 $torqueGen.mergepoint("doDelete")

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getDbObjectInstance.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getDbObjectInstance.vm?rev=1148410&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getDbObjectInstance.vm
(added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getDbObjectInstance.vm
Tue Jul 19 15:45:53 2011
@@ -0,0 +1,37 @@
+## 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.
+##
+######
+##
+## version $Id: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer
$
+##
+## Creates the getDbObjectInstance method for the base peer.
+## 
+## This template expects the current source element to be a "table" element 
+## from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The options and the attributes of the current source element must be set
+## as velocity variables.  
+##
+    /**
+     * Returns a new instance of the Data object class
+     */
+    public static ${dbObjectClassName} getDbObjectInstance()
+    {
+        return ${peerImplGetter}().getDbObjectInstance();
+    }
+

Copied: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/inheritanceClasskeyConstants.vm
(from r1103197, db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm)
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/inheritanceClasskeyConstants.vm?p2=db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/inheritanceClasskeyConstants.vm&p1=db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm&r1=1103197&r2=1148410&rev=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/inheritanceClasskeyConstants.vm
Tue Jul 19 15:45:53 2011
@@ -27,13 +27,6 @@
 ## The options and the attributes of the current source element must be set
 ## as velocity variables.  
 ##
-    /** A class that can be returned by this peer. */
-    protected static final String CLASSNAME_DEFAULT =
-        "${dbObjectPackage}.${dbObjectClassName}";
-
-    /** A class that can be returned by this peer. */
-    protected static final Class<?> CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
-
 #set ($inheritanceColumnBaseElement = $torqueGen.getChild("inheritance-column"))
 #if ($inheritanceColumnBaseElement)
   #set ( $columnElement = $inheritanceColumnBaseElement.getChild("column") )
@@ -55,14 +48,5 @@
     /** A key representing a particular subclass */
     public static final $columnFieldType $classkeyConstant =
         $quote$key$quote;
-
-    /** A class that can be returned by this peer. */
-    public static final String $classnameConstant =
-        "${dbObjectPackage}.$class";
-
-    /** A class that can be returned by this peer. */
-    public static final Class<?> $classConstant =
-        initClass($classnameConstant);
-
   #end
 #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm?rev=1148410&r1=1148409&r2=1148410&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/basePeerImpl.vm
Tue Jul 19 15:45:53 2011
@@ -46,7 +46,7 @@ $torqueGen.mergepoint("resultSet2Objects
 $torqueGen.mergepoint("addSelectColumns")
 $torqueGen.mergepoint("correctBooleans")
 $torqueGen.mergepoint("doSelect")
-$torqueGen.mergepoint("getOMClass")
+$torqueGen.mergepoint("getDbObjectInstance")
 $torqueGen.mergepoint("doInsert")
 $torqueGen.mergepoint("doUpdate")
 $torqueGen.mergepoint("doDelete")

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getDbObjectInstance.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getDbObjectInstance.vm?rev=1148410&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getDbObjectInstance.vm
(added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/getDbObjectInstance.vm
Tue Jul 19 15:45:53 2011
@@ -0,0 +1,47 @@
+## 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.
+##
+######
+##
+## version $Id: MultiExtendBean.vm 240328 2005-08-26 22:02:48 +0200 (Fr, 26 Aug 2005) tfischer
$
+##
+## Creates the getDbObjectInstance method for the base peer.
+## 
+## This template expects the current source element to be a "table" element 
+## from the torque schema.
+## The schema needs to be processed by the OMTransformer.
+## The options and the attributes of the current source element must be set
+## as velocity variables.  
+##
+    /**
+     * Returns a new instance of the Data object class
+#if ($abstract == "true")
+     * This method needs to be overwritten to return instances of the
+     * db object.
+     *
+     * @throws UnsupportedOperationException always.
+#end
+     */
+    public ${dbObjectClassName} getDbObjectInstance()
+    {
+#if ($abstract == "true")
+        throw new UnsupportedOperationException("This method needs to be overwritten");
+#else
+        return new ${dbObjectClassName}();
+#end
+    }
+



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message