### Eclipse Workspace Patch 1.0 #P p2j6129a Index: src/com/goldencode/p2j/persist/RecordBuffer.java =================================================================== --- src/com/goldencode/p2j/persist/RecordBuffer.java (revision 3647) +++ src/com/goldencode/p2j/persist/RecordBuffer.java (working copy) @@ -2089,6 +2089,52 @@ * buffer is permanently associated with the specified database. It will * be registered with the transaction manager under the specified variable * name. + * + * @param + * Record type. + * @param def + * The currently executing OE class or external program. + * @param dmoBufIface + * Interface which defines DMO's public API plus all {@link + * Buffer} methods. + * @param database + * Name of the database which will be associated with the new + * record buffer. + * @param variable + * Name of the variable with which the record buffer is associated + * for the purposes of differentiating multiple buffers backed by + * the same DMO type. + * @param legacyName + * Legacy name of the buffer. + * @param isStatic + * Flag indicating this is a static buffer. + * + * @return An object which implements the specified interface, but which + * initially has no backing data record. + */ + @SuppressWarnings("unchecked") + public static T define(Class def, + Class dmoBufIface, + String database, + String variable, + String legacyName, + boolean isStatic) + { + T buf = define(def, dmoBufIface, database, variable, legacyName, -1); + + if (isStatic) + { + ConnectionManager.addStaticReference(database); + } + + return buf; + } + + /** + * Define a new buffer which is based upon the specified interface. The + * buffer is permanently associated with the specified database. It will + * be registered with the transaction manager under the specified variable + * name. * * @param * Record type. Index: src/com/goldencode/p2j/persist/ConnectionManager.java =================================================================== --- src/com/goldencode/p2j/persist/ConnectionManager.java (revision 3647) +++ src/com/goldencode/p2j/persist/ConnectionManager.java (working copy) @@ -356,6 +356,8 @@ /** Next available connect ID for metadata updates */ private static long nextConnectID = 0L; + + private static Set staticReferences = new HashSet<>(); /** Set of locked database. */ private final Set locked = new HashSet<>(); @@ -694,6 +696,12 @@ return new OptionsParser(dboptions, options, args.iterator(), new HashSet(), false). parse() ? dboptions : null; } + + public static void addStaticReference(String ldbName) + { + get().staticReferences.add(ldbName.toLowerCase()); + } + /** * Request a disconnect from a logical database. This does not actually * perform the disconnect immediately, but registers ldbName @@ -2861,13 +2869,18 @@ */ private void disconnectImmediately(Database database, boolean sessionCleanup) { - if (sessionCleanup) + String ldbName = ldbMap.get(database); + if (ldbName != null) { - String ldbName = ldbMap.get(database); - if (ldbName != null) + if (sessionCleanup) { removeConnected(ldbName, sessionCleanup); } + else if (staticReferences.contains(ldbName.toLowerCase())) + { + // do nothing + return; + } } if (!database.isLocal()) @@ -3645,6 +3658,12 @@ throw new PersistenceException("DISCONNECT: Database " + ldbName + " is not open or unknown", 1009); } + if (staticReferences.contains(ldbName.toLowerCase()) || staticReferences.contains(ldb.toLowerCase())) + { + // do nothing + return; + } + // remove the database from the connected map whether or not the disconnect can occur immediately Database database = removeConnected(ldb, false); Index: rules/convert/buffer_definitions.rules =================================================================== --- rules/convert/buffer_definitions.rules (revision 3647) +++ rules/convert/buffer_definitions.rules (working copy) @@ -260,6 +260,7 @@ + @@ -1033,6 +1034,27 @@ createJavaAst(java.reference, sprintf("%s.class", baseClass), ref3, 0) + getNoteString("dbname") != "" + pref.downPath("KW_STATIC") + createJavaAst(java.bool_true, "true", ref3) + + true + defref = pref.getAncestor(-1, prog.method_def) + defref != null + defref = defref.getImmediateChild(prog.kw_method, null) + + defref = pref.getAncestor(-1, prog.constructor) + defref != null + defref = defref.getImmediateChild(prog.kw_construc, null) + + + + defref != null and defref.downPath("KW_STATIC") + createJavaAst(java.bool_true, "true", ref3) + + + + child != null