Project

General

Profile

6479_patch1.txt

Constantin Asofiei, 05/31/2022 03:23 PM

Download (6.58 KB)

 
1
### Eclipse Workspace Patch 1.0
2
#P p2j6129a
3
Index: src/com/goldencode/p2j/persist/RecordBuffer.java
4
===================================================================
5
--- src/com/goldencode/p2j/persist/RecordBuffer.java	(revision 3647)
6
+++ src/com/goldencode/p2j/persist/RecordBuffer.java	(working copy)
7
@@ -2089,6 +2089,52 @@
8
     * buffer is permanently associated with the specified database. It will
9
     * be registered with the transaction manager under the specified variable
10
     * name.
11
+    *
12
+    * @param   <T>
13
+    *          Record type.
14
+    * @param   def
15
+    *          The currently executing OE class or external program.
16
+    * @param   dmoBufIface
17
+    *          Interface which defines DMO's public API plus all {@link
18
+    *          Buffer} methods.
19
+    * @param   database
20
+    *          Name of the database which will be associated with the new
21
+    *          record buffer.
22
+    * @param   variable
23
+    *          Name of the variable with which the record buffer is associated
24
+    *          for the purposes of differentiating multiple buffers backed by
25
+    *          the same DMO type.
26
+    * @param   legacyName
27
+    *          Legacy name of the buffer.
28
+    * @param   isStatic
29
+    *          Flag indicating this is a static buffer.
30
+    *          
31
+    * @return  An object which implements the specified interface, but which
32
+    *          initially has no backing data record.
33
+    */
34
+   @SuppressWarnings("unchecked")
35
+   public static <T extends Buffer> T define(Class<?> def,
36
+                                             Class<T> dmoBufIface,
37
+                                             String database,
38
+                                             String variable,
39
+                                             String legacyName,
40
+                                             boolean isStatic)
41
+   {
42
+      T buf = define(def, dmoBufIface, database, variable, legacyName, -1);
43
+      
44
+      if (isStatic)
45
+      {
46
+         ConnectionManager.addStaticReference(database);
47
+      }
48
+      
49
+      return buf;
50
+   }
51
+
52
+   /**
53
+    * Define a new buffer which is based upon the specified interface. The
54
+    * buffer is permanently associated with the specified database. It will
55
+    * be registered with the transaction manager under the specified variable
56
+    * name.
57
     * 
58
     * @param   <T> 
59
     *          Record type.
60
Index: src/com/goldencode/p2j/persist/ConnectionManager.java
61
===================================================================
62
--- src/com/goldencode/p2j/persist/ConnectionManager.java	(revision 3647)
63
+++ src/com/goldencode/p2j/persist/ConnectionManager.java	(working copy)
64
@@ -356,6 +356,8 @@
65
    
66
    /** Next available connect ID for metadata updates */
67
    private static long nextConnectID = 0L;
68
+
69
+   private static Set<String> staticReferences = new HashSet<>();
70
    
71
    /** Set of locked database. */
72
    private final Set<String> locked = new HashSet<>();
73
@@ -694,6 +696,12 @@
74
       return new OptionsParser(dboptions, options, args.iterator(), new HashSet<String>(), false).
75
             parse() ? dboptions : null;
76
    }
77
+   
78
+   public static void addStaticReference(String ldbName)
79
+   {
80
+      get().staticReferences.add(ldbName.toLowerCase());
81
+   }
82
+   
83
    /**
84
     * Request a disconnect from a logical database.  This does not actually
85
     * perform the disconnect immediately, but registers <code>ldbName</code>
86
@@ -2861,13 +2869,18 @@
87
     */
88
    private void disconnectImmediately(Database database, boolean sessionCleanup)
89
    {
90
-      if (sessionCleanup)
91
+      String ldbName = ldbMap.get(database);
92
+      if (ldbName != null)
93
       {
94
-         String ldbName = ldbMap.get(database);
95
-         if (ldbName != null)
96
+         if (sessionCleanup)
97
          {
98
             removeConnected(ldbName, sessionCleanup);
99
          }
100
+         else if (staticReferences.contains(ldbName.toLowerCase()))
101
+         {
102
+            // do nothing
103
+            return;
104
+         }
105
       }
106
       
107
       if (!database.isLocal())
108
@@ -3645,6 +3658,12 @@
109
          throw new PersistenceException("DISCONNECT:  Database " + ldbName + " is not open or unknown", 1009);
110
       }
111
       
112
+      if (staticReferences.contains(ldbName.toLowerCase()) || staticReferences.contains(ldb.toLowerCase()))
113
+      {
114
+         // do nothing
115
+         return;
116
+      }
117
+      
118
       // remove the database from the connected map whether or not the disconnect can occur immediately
119
       Database database = removeConnected(ldb, false);
120
       
121
Index: rules/convert/buffer_definitions.rules
122
===================================================================
123
--- rules/convert/buffer_definitions.rules	(revision 3647)
124
+++ rules/convert/buffer_definitions.rules	(working copy)
125
@@ -260,6 +260,7 @@
126
    <variable name="toplvlref"     type="com.goldencode.ast.Aast" />
127
    <variable name="lastthparam"   type="com.goldencode.ast.Aast" />
128
    <variable name="pref"          type="com.goldencode.ast.Aast" />
129
+   <variable name="defref"        type="com.goldencode.ast.Aast" />
130
    <variable name="clinitref"     type="com.goldencode.ast.Aast" />
131
    <variable name="bufinitref"    type="com.goldencode.ast.Aast" />
132
    <variable name="explicit"      type="java.lang.Boolean" />
133
@@ -1033,6 +1034,27 @@
134
                   <action>
135
                      createJavaAst(java.reference, sprintf("%s.class", baseClass), ref3, 0)
136
                   </action>
137
+                  <rule>getNoteString("dbname") != ""
138
+                     <rule>pref.downPath("KW_STATIC")
139
+                        <action>createJavaAst(java.bool_true, "true", ref3)</action>
140
+                        
141
+                        <rule on="false">true
142
+                           <action>defref = pref.getAncestor(-1, prog.method_def)</action>
143
+                           <rule>defref != null
144
+                              <action>defref = defref.getImmediateChild(prog.kw_method, null)</action>
145
+                              
146
+                              <action on="false">defref = pref.getAncestor(-1, prog.constructor)</action>
147
+                              <rule on="false">defref != null
148
+                                 <action>defref = defref.getImmediateChild(prog.kw_construc, null)</action>
149
+                              </rule>
150
+                           </rule>
151
+                           
152
+                           <rule>defref != null and defref.downPath("KW_STATIC")
153
+                              <action>createJavaAst(java.bool_true, "true", ref3)</action>
154
+                           </rule>
155
+                        </rule>
156
+                     </rule>
157
+                  </rule>
158
                </rule>
159
                
160
                <rule>child != null
161