Project

General

Profile

6371.diff

Minor refactoring - Boris Schegolev, 07/14/2022 05:12 PM

Download (5.4 KB)

View differences:

src/com/goldencode/p2j/persist/ConversionPool.java 2022-07-14 21:09:53 +0000
184 184
         }
185 185
         catch (AstException | ConfigurationException exc)
186 186
         {
187
            pristineDbAsts = null; // helping GC
188
            
189 187
            String msg = "Failed to load the pristine '" + schema + "' schema information from file.";
190 188
            
191 189
            if (LOG.isLoggable(Level.WARNING))
......
335 333
      Stack<PatternEngine> stack;
336 334
      synchronized (pool)
337 335
      {
338
         stack = pool.get(profile);
339
         if (stack == null)
340
         {
341
            stack = new Stack<>();
342
         }
343
         pool.put(profile, stack);
336
         stack = pool.computeIfAbsent(profile, conversionProfile -> new Stack<>());
344 337
      }
345 338
      
346 339
      synchronized (stack)
src/com/goldencode/p2j/persist/DynamicTablesHelper.java 2022-07-14 19:55:43 +0000
177 177
   private final Object cacheLock = new Object();
178 178
   
179 179
   /** Containers for context-specific data. */
180
   private final ContextLocal<Context> context = new ContextLocal<Context>()
180
   private final ContextLocal<Context> context = new ContextLocal<>()
181 181
   {
182
      public WeightFactor getWeight() { return WeightFactor.LEVEL_8; };
182
      public WeightFactor getWeight() { return WeightFactor.LEVEL_8; }
183 183
      public Context initialValue() { return new Context(); }
184 184
      protected void cleanup(Context ctx) { ctx.cleanup(); }
185 185
   };
......
573 573
      
574 574
      // check the cache first
575 575
      CacheKey cacheKey = new CacheKey(allFields, allIndexes);
576
      CacheData cacheData = null;
576
      CacheData cacheData;
577 577
      
578 578
      synchronized (cacheLock)
579 579
      {
580 580
         cacheData = cache.get(cacheKey);
581 581
      }
582
      
583
      String fullIfaceName = null;
584
      String fullIfaceBufName = null;
585
      String fullImplClassName = null;
586
      String sqlTableName = null;
582

  
587 583
      DmoMeta dmoMeta = null;
588 584
      Class<? extends DataModelObject> dmoIface = null;
589 585
      Class<? extends TempTableBuffer> dmoBufIface = null;
......
603 599
            clsFieldsORMTo4GL = new HashMap<>();
604 600
            
605 601
            long tableId = tableCounter.getAndIncrement();
606
            sqlTableName = "dtt" + tableId;
602
            String sqlTableName = "dtt" + tableId;
607 603
            
608 604
            String ifaceName = "DynamicRecord" + tableId;
609 605
            
......
639 635
               // generate interface Java ASTs
640 636
               results = ConversionPool.runTask(ConversionProfile.JAVA_DMO, root);
641 637
               Aast iface = (Aast) results.getStoredObject(DMO_IFACE_CATEGORY, ifaceName);
642
               fullIfaceName = DMO_BASE_PACKAGE + "." + DatabaseManager.TEMP_TABLE_SCHEMA + "." + ifaceName;
643
               fullIfaceBufName = fullIfaceName + "$Buf";
638
               String fullIfaceName = DMO_BASE_PACKAGE + "." + DatabaseManager.TEMP_TABLE_SCHEMA + "." + ifaceName;
639
               String fullIfaceBufName = fullIfaceName + "$Buf";
644 640
               
645 641
               // generate bytecode from Java ASTs
646 642
               results = ConversionPool.runTask(ConversionProfile.BREW_DMO_ASM, iface);
......
676 672
                     dmoMeta = DmoMetadataManager.registerDmo(dmoIface);
677 673
                     extractIndexes(dmoMeta, fwdIndexes);
678 674
                     dmoClass = dmoMeta.getImplementationClass();
679
                     fullImplClassName = dmoClass.getName();
675
                     String fullImplClassName = dmoClass.getName();
680 676
                     classes.put(fullImplClassName, dmoClass);
681 677
                     
682 678
                     dmoInfo = new DMOInfo(classes.values(), clsFields4GLtoORM, clsFieldsORMTo4GL);
......
704 700
         if (cacheData != null)
705 701
         {
706 702
            dmoInfo = cacheData.getDMOInfo();
707
            fullIfaceName = cacheData.getDMOIfaceName();
708
            fullIfaceBufName = fullIfaceName + "$Buf";
709
            fullImplClassName = cacheData.getDMOClassName();
710
            sqlTableName = cacheData.getSqlTableName();
711
            fwdIndexes = cacheData.getFwdIndices();
703
            String fullIfaceName = cacheData.getDMOIfaceName();
704
            String fullIfaceBufName = fullIfaceName + "$Buf";
712 705
            classes = cacheData.getClasses();
713
            clsFields4GLtoORM = dmoInfo.getLegacyToDmoNames();
714
            clsFieldsORMTo4GL = dmoInfo.getDmoToLegacyNames();
715 706
            dmoIface = (Class<? extends DataModelObject>) classes.get(fullIfaceName);
716 707
            dmoBufIface = (Class<? extends TempTableBuffer>) classes.get(fullIfaceBufName);
717 708
            dmoMeta = DmoMetadataManager.getDmoInfo(dmoIface);
718
            dmoClass = dmoMeta.getImplementationClass();
719 709
         }
720 710
         
721 711
         if (local.registerDMOInfo(dmoIface, dmoInfo))
src/com/goldencode/p2j/persist/TempTableBuilder.java 2022-07-14 19:50:27 +0000
172 172
import com.goldencode.p2j.persist.orm.*;
173 173
import com.goldencode.p2j.ui.client.format.*;
174 174
import com.goldencode.p2j.util.*;
175
import java.lang.reflect.*;
176 175
import java.util.*;
177 176
import java.util.function.*;
178 177