Setup

In proparse/setup/setup.p and associated programs you create instances of
com.joanju.proparse.Environment
org.prorefactor.core.schema.Schema
org.prorefactor.refactor.RefactorSession
references to which are not passed anywhere. Each appears to be static
in that you obtain the reference via getInstance() rather than newing
it. Am I correct that this is just "priming the pump" to create a
reference base which the rest of the Proparse objects refer and that it
is OK for these to persist?

Right now, I am starting a new AVM for each trial so I am always
starting with a clean slate, but if these should get cleaned up
normally, then that would be nice to know ... assuming that one *can*
clean them up!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
john's picture

Re: setup

Here's the code in question:

/** Configures Proparse with schema and propath.
 *
 * May 2011 by John Green.
 *
 */

ROUTINE-LEVEL ON ERROR UNDO, THROW.

DEF VAR i AS INT NO-UNDO.

DEF VAR proparseEnv AS CLASS com.joanju.proparse.Environment NO-UNDO.
proparseEnv = com.joanju.proparse.Environment:instance().

DEF VAR proparseSchema AS CLASS org.prorefactor.core.schema.Schema NO-UNDO.
proparseSchema = org.prorefactor.core.schema.Schema:getInstance().

DEF VAR refactorSession AS CLASS org.prorefactor.refactor.RefactorSession NO-UNDO.
refactorSession = org.prorefactor.refactor.RefactorSession:getInstance().

refactorSession:setContextDirName(SESSION:TEMP-DIRECTORY + "/").
proparseEnv:configSet("batch-mode", STRING(SESSION:BATCH-MODE, "true/false")).
proparseEnv:configSet("opsys", OPSYS).
proparseEnv:configSet("propath", PROPATH).
proparseEnv:configSet("proversion", PROVERSION).
proparseEnv:configSet("window-system", SESSION:WINDOW-SYSTEM).

DEF VAR schemaDumpFile AS CHAR NO-UNDO.
proparseSchema:clear().
IF NUM-DBS > 0 THEN 
DO:
  schemaDumpFile = SESSION:TEMP-DIRECTORY + "proparse.schema".
  RUN proparse/setup/schemadump1.p (schemaDumpFile).
  proparseSchema:loadSchema(schemaDumpFile).
  OS-DELETE schemaDumpFile.
END.

proparseSchema:aliasDelete("").
REPEAT i=1 TO NUM-ALIASES:
  IF ALIAS(i)>? AND LDBNAME(ALIAS(i))>? THEN
    proparseSchema:aliasCreate(ALIAS(i),LDBNAME(ALIAS(i))).
END.

RETURN.

Those are 'singleton' objects in Proparse. My code here is just fetching references to them, then using them.